How to Use Arduino Due: Getting Started and Basic Example
To use
Arduino Due, connect it to your computer via USB, select Arduino Due (Programming Port) board in the Arduino IDE, and write your code using setup() and loop() functions. Upload the code to the board and use its 3.3V logic pins carefully as it differs from 5V Arduino boards.Syntax
The basic Arduino Due program structure uses two main functions:
setup(): Runs once to initialize settings like pin modes.loop(): Runs repeatedly to perform the main tasks.
You write your code inside these functions. Use pinMode() to set pins as input or output, and digitalWrite() or digitalRead() to control or read pins.
Arduino Due uses 3.3V logic, so be careful with voltage levels.
arduino
void setup() { pinMode(13, OUTPUT); // Set pin 13 as output } void loop() { digitalWrite(13, HIGH); // Turn LED on delay(1000); // Wait 1 second digitalWrite(13, LOW); // Turn LED off delay(1000); // Wait 1 second }
Example
This example blinks the built-in LED on pin 13 every second. It shows how to set a pin as output and toggle it on and off with delays.
arduino
void setup() { pinMode(13, OUTPUT); // Initialize pin 13 as output } void loop() { digitalWrite(13, HIGH); // LED on delay(1000); // Wait 1 second digitalWrite(13, LOW); // LED off delay(1000); // Wait 1 second }
Output
The built-in LED on pin 13 blinks on and off every second.
Common Pitfalls
Many beginners make these mistakes when using Arduino Due:
- Using 5V logic: Arduino Due pins work at 3.3V. Applying 5V can damage the board.
- Wrong board selected: Always select
Arduino Due (Programming Port)in the Arduino IDE before uploading. - Not installing drivers: Some OS need drivers for Arduino Due USB connection.
- Confusing pins: Arduino Due has different pin numbering and features than Uno or Mega.
Example of wrong and right pin voltage usage:
arduino
/* WRONG: Applying 5V to Due pin (can damage board) */ // digitalWrite(13, HIGH); // HIGH is 3.3V on Due, but external 5V signals can harm /* RIGHT: Use 3.3V signals only */ // Use level shifters if interfacing 5V devices
Quick Reference
Here are quick tips for using Arduino Due:
- Use 3.3V logic levels only.
- Select
Arduino Due (Programming Port)in Arduino IDE. - Use
setup()andloop()functions for your code. - Use
pinMode(),digitalWrite(), anddigitalRead()to control pins. - Connect USB to programming port for uploading code.
Key Takeaways
Always select Arduino Due board in the Arduino IDE before uploading code.
Use 3.3V logic levels to avoid damaging the Arduino Due pins.
Write your code inside setup() for initialization and loop() for repeated actions.
Use pinMode(), digitalWrite(), and digitalRead() to control pins.
Connect the board via USB programming port for uploading and serial communication.