Arduino Due Original Component Documentation
The Arduino Due Original is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU. It is an advanced board that offers a significant increase in performance and functionality compared to other Arduino boards.
Microcontroller: Atmel SAM3X8E ARM Cortex-M3 CPU
Operating Voltage: 3.3V
Input Voltage: 7-12V
Digital I/O Pins: 54
Analog Input Pins: 12
Analog Output Pins: 2
Flash Memory: 512 KB
SRAM: 96 KB
Clock Speed: 84 MHz
### Example 1: Blinking an LED using Digital Pins
This example demonstrates how to use the Arduino Due Original's digital pins to control an LED.
```c++
const int ledPin = 13; // Pin 13 for the LED
void setup() {
pinMode(ledPin, OUTPUT); // Set the pin as an output
}
void loop() {
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(1000); // Wait for 1 second
digitalWrite(ledPin, LOW); // Turn the LED off
delay(1000); // Wait for 1 second
}
```
In this example, we define a constant `ledPin` to represent the digital pin 13, which is connected to an LED. In the `setup()` function, we set the pin as an output using `pinMode()`. In the `loop()` function, we use `digitalWrite()` to turn the LED on and off by setting the pin high and low, respectively.
### Example 2: Reading Analog Input from a Sensor
This example demonstrates how to use the Arduino Due Original's analog input pins to read data from a sensor.
```c++
const int sensorPin = A0; // Pin A0 for the sensor
int sensorValue = 0; // Variable to store the sensor reading
void setup() {
Serial.begin(9600); // Initialize serial communication at 9600 bps
}
void loop() {
sensorValue = analogRead(sensorPin); // Read the sensor value
Serial.print("Sensor Value: ");
Serial.println(sensorValue); // Print the sensor value to the serial monitor
delay(100); // Wait for 100 ms before taking the next reading
}
```
In this example, we define a constant `sensorPin` to represent the analog input pin A0, which is connected to a sensor. We also define a variable `sensorValue` to store the sensor reading. In the `setup()` function, we initialize serial communication at 9600 bps using `Serial.begin()`. In the `loop()` function, we use `analogRead()` to read the sensor value, and then print the value to the serial monitor using `Serial.print()` and `Serial.println()`.
### Example 3: Using the Due's Built-in Real-Time Clock (RTC)
This example demonstrates how to use the Arduino Due Original's built-in RTC to keep track of time.
```c++
#include <RTClib.h> // Include the RTC library
RTC_DS1307 rtc; // Create an instance of the RTC class
void setup() {
rtc.begin(); // Initialize the RTC
}
void loop() {
DateTime now = rtc.now(); // Get the current time
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
delay(1000); // Wait for 1 second before displaying the time again
}
```
In this example, we include the `RTClib` library and create an instance of the `RTC_DS1307` class to interact with the RTC. In the `setup()` function, we initialize the RTC using `rtc.begin()`. In the `loop()` function, we use `rtc.now()` to get the current time, and then print it to the serial monitor in the format `YYYY/MM/DD HH:MM:SS`.