DUE EXPS
DUE EXPS
1. Conduct the following experiments on an ARM CORTEX M3 evaluation board/ ARDUINO DUE Board (contains
ARM cortex M3) using evaluation version of Embedded 'C' &Keil uVision-5 tool/ ARDUINO IDE (or equivalent
software).
2. Femillarise with ARM CORTEX M3 evaluation board/ ARDUINO DUE Board (contains ARM cortex M3)
1. Write a C program for blinking LED/LEDs with a one second interval of time and Interface the LED/LEDs to ARM
CORTEX M3 controller/ ARDUINO DUE and test it.
2. Write a C program for switch Interface with ARM based microcontroller/ ARDUINO DUE to read status of
switch/switches and display the in LED/Relay/Buzzer. Interface the LED/Relay/Buzzer to ARM CORTEX M3 controller
and test it.
3. Write a C program to interface a 4x4 keypad and an LCD to display the keycode on an LCD Interface the keypad
and LCD to ARM CORTEX M3 controller/ ARDUINO DUE and test it.
4. Write a C program to rotate DC motor in clockwise and anticlockwise direction with different speed using ARM
based microcontroller. Interface the DC motor to ARM CORTEX M3 controller/ ARDUINO DUE and verify its working
5. Write a C program to control and run the stepper motor in half step and full step mode using ARM based
microcontroller. Interface the DC motor to ARM CORTEX M3 controller/ ARDUINO DUE and verify it's working.
6. Design and test a C program to display temperature (using DHT11 temperature& humidity sensor) on LCD by
interfacing temperature sensor using ARM based microcontroller/ ARDUINO DUE
7. Interface Flame sensor with ARDUINO DUE and turn on Buzzer when flame detected
8. Interface Ultrasonic sensor with ARDUINO DUE to measure the distance from the target
9. Interface RTC with ARDUINO DUE and display Date, Time on LCD display
Lab Manual: Blinking LED with Arduino Due
Objective
To interface an LED to Arduino Due and program it to blink with a one-second interval using Arduino IDE.
Components Required
1. Arduino Due board
2. USB cable (Type-B)
3. LED (1 unit)
4. Resistor (330Ω)
5. Breadboard
6. Connecting wires
Theory
An LED (Light Emitting Diode) emits light when a suitable voltage is applied across its terminals. By
controlling the voltage on the Arduino's digital pins, we can turn the LED on and off. The Arduino IDE
provides a delay() function that can create time intervals for blinking the LED.
The Arduino Due operates at 3.3V logic levels. Ensure the components are compatible to avoid damage.
Circuit Diagram
Connections:
1. Connect the longer leg (anode) of the LED to the digital pin 13 on the Arduino Due.
2. Connect a 330Ω resistor in series with the LED’s cathode and GND.
3. Use the USB cable to connect the Arduino Due to the computer.
Procedure
1. Hardware Setup
1. Copy and paste the following code into the Arduino IDE:
void setup() {
// Set the LED pin as OUTPUT
pinMode(LED_PIN, OUTPUT);
}
void loop() {
// Turn the LED on
digitalWrite(LED_PIN, HIGH);
// Wait for 1 second
delay(1000);
// Turn the LED off
digitalWrite(LED_PIN, LOW);
// Wait for 1 second
delay(1000);
}
Observations
Time Interval LED State
1 Second ON
Next 1 Second OFF
Result
The LED successfully blinked with a one-second interval, demonstrating the control of digital pins using
Arduino Due.
Viva Questions
1. What is the function of the resistor in the circuit?
2. Why do we use delay() in the program?
3. What is the difference between HIGH and LOW in digitalWrite()?
4. What would happen if the resistor value is too low or absent?
Conclusion
The experiment successfully demonstrated interfacing an LED to Arduino Due and programming it to blink
with a 1-second interval. This experiment highlights the basics of controlling GPIO pins and timing in
embedded systems.
Components Required
1. Arduino Due board
2. USB cable (Type-B)
3. Push-button switch (1 unit)
4. LED/Relay/Buzzer (choose one as output device)
5. Resistor (330Ω for LED or as per Relay/Buzzer requirements)
6. Breadboard
7. Connecting wires
Theory
A switch is a simple input device that can change its state between ON and OFF. Using a pull-up resistor,
the switch input pin is kept in a defined state when the switch is open. When the switch is pressed, it
changes the state to GND (LOW).
Output devices like LEDs, relays, or buzzers can be controlled using GPIO pins of the Arduino Due based
on the switch state. The Arduino IDE provides digitalRead() and digitalWrite() functions to read and
control pins, respectively.
Circuit Diagram
Connections
1. Switch:
o One terminal to digital pin 7.
o Other terminal to GND.
2. Output Device:
o Connect an LED with a 330Ω resistor to digital pin 13.
o For a relay or buzzer, connect to pin 13 through an appropriate driver circuit.
3. Power Supply:
o Connect the Arduino Due to the computer using the USB cable.
Procedure
1. Hardware Setup
2. Software Setup
1. Copy and paste the following code into the Arduino IDE:
void setup() {
// Set the switch pin as INPUT with an internal pull-up resistor
pinMode(SWITCH_PIN, INPUT_PULLUP);
void loop() {
// Read the state of the switch
int switchState = digitalRead(SWITCH_PIN);
Observations
Switch State Output Device State
Pressed (LOW) ON
Not Pressed (HIGH) OFF
Result
The switch was successfully interfaced with the Arduino Due. The status of the switch was read, and the
output device (LED/Relay/Buzzer) was controlled accordingly.
Viva Questions
1. What is the purpose of the pull-up resistor in the circuit?
2. Explain the difference between HIGH and LOW in digitalRead() and digitalWrite().
3. Why is it important to debounce a switch in real-world applications?
4. How would you modify the circuit to control multiple switches and output devices?
Conclusion
This experiment demonstrates the interfacing of a switch with Arduino Due to control an output device
based on the switch state. It highlights basic GPIO operations and the importance of proper pull-up resistors
in digital circuits.
c
Lab Manual: Interfacing DS1307 RTC with Arduino Due and
Displaying Date & Time on LCD
Objective:
To interface the DS1307 Real-Time Clock (RTC) Module with an Arduino Due and display the current
time and date on a 16x2 LCD I2C display.
Materials Required:
Theory:
The DS1307 RTC module is a low-power, real-time clock (RTC) that communicates with microcontrollers
via the I2C protocol. The 16x2 LCD I2C module allows easy display of text with just two data lines (SDA
and SCL) for communication. We use the RTClib library for controlling the RTC and LiquidCrystal_I2C
for controlling the LCD.
Connections:
Procedure:
1. Connect the DS1307 RTC module to the Arduino Due as shown in the wiring section.
2. Connect the 16x2 LCD I2C module to the Arduino Due as shown in the wiring section.
Step 3: Upload the Code
cpp
CopyEdit
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>
void setup() {
lcd.init();
lcd.backlight();
if (!rtc.begin()) {
lcd.print("RTC not found");
while (1);
}
if (!rtc.isrunning()) {
lcd.print("Setting time...");
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); // Set time to compile time
}
}
void loop() {
DateTime now = rtc.now();
// Display date
lcd.setCursor(0, 0);
lcd.print("Date: ");
lcd.print(now.day());
lcd.print("/");
lcd.print(now.month());
lcd.print("/");
lcd.print(now.year());
// Display time
lcd.setCursor(0, 1);
lcd.print("Time: ");
lcd.print(now.hour() < 10 ? "0" : ""); // Add leading zero if needed
lcd.print(now.hour());
lcd.print(":");
lcd.print(now.minute() < 10 ? "0" : "");
lcd.print(now.minute());
lcd.print(":");
lcd.print(now.second() < 10 ? "0" : "");
lcd.print(now.second());
Step 4: Testing
1. After uploading the code, open the Serial Monitor (set the baud rate to 9600).
2. The LCD 16x2 should display the current date and time in the format:
o Date: DD/MM/YYYY
o Time: HH:MM:SS
3. If it’s the first time using the RTC, the time will be set to the compile time. You can also set the
time manually using rtc.adjust(DateTime(2025, 1, 21, 14, 30, 0)); for a specific time.
Observations:
Conclusion:
You successfully interfaced the DS1307 RTC with the Arduino Due and displayed the current date and
time on the 16x2 LCD. The DS1307 module helps in keeping track of real-time, even when the Arduino is
powered off, by using a battery (typically CR2032).
Troubleshooting:
Experiment Title:
Objective:
To control a 28BYJ-48 5V stepper motor using an ULN2003A driver module and Arduino Due in both
half-step and full-step modes.
Apparatus Required:
Theory:
Stepper motors are DC motors that move in discrete steps. They have multiple coils organized in groups
called "phases." By energizing the coils in sequence, the motor rotates one step at a time.
1. Half-Step Mode:
o Combines both full-step and intermediate steps.
o Offers smoother operation and finer control.
o Sequence contains 8 steps.
2. Full-Step Mode:
o Energizes two coils at a time.
o Provides higher torque but less resolution.
o Sequence contains 4 steps.
Circuit Diagram:
1. Connection Table:
o ULN2003A IN1 to Arduino Pin 8
o ULN2003A IN2 to Arduino Pin 9
o ULN2003A IN3 to Arduino Pin 10
o ULN2003A IN4 to Arduino Pin 11
o ULN2003A GND to Arduino GND
o ULN2003A VCC to 5V external or Arduino 5V
2. Motor Connection:
o Connect the stepper motor to the ULN2003A driver.
Program Code:
#include <Arduino.h>
#define IN1 8
#define IN2 9
#define IN3 10
#define IN4 11
void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
Serial.begin(9600);
Serial.println("Stepper Motor Control Initialized!");
}
void loop() {
int steps = 100; // Number of steps
int delayMs = 5; // Delay between steps (ms)
Procedure:
Observations:
The 28BYJ-48 stepper motor was successfully controlled using an Arduino Due in both half-step and full-
step modes. The behavior of the motor was observed, and differences in torque, resolution, and smoothness
were noted.
Precautions:
Questions:
1. What are the main differences between half-step and full-step modes?
2. How does the delay between steps affect the motor's operation?
3. Why is the ULN2003A driver necessary for controlling the stepper motor?
Conclusion:
This experiment demonstrated how to control a stepper motor using Arduino Due and ULN2003A driver in
different operational modes. Half-step mode provided finer resolution, while full-step mode offered more
torque.
Objective
To control the rotation of a DC motor in both clockwise and counter-clockwise directions at different
speeds using an Arduino Due and an L9110S motor driver.
Apparatus
1. Arduino Due
2. L9110S motor driver module
3. BO motor (DC motor)
4. Connecting wires
5. External power supply (if needed)
6. Breadboard
Theory
A DC motor converts electrical energy into mechanical energy. By controlling the voltage across the motor
terminals, we can control its speed and direction. The L9110S driver module allows bidirectional control of
a DC motor using two input pins (A and B). By applying a PWM signal, the motor’s speed can be adjusted.
Circuit Diagram
Connections:
Procedure
1. Connect the L9110S motor driver to the Arduino Due as per the circuit diagram.
2. Connect the BO motor to the motor output terminals of the L9110S driver.
3. Power the Arduino Due using USB or an external power source.
4. Upload the provided Arduino sketch to the Arduino Due using the Arduino IDE.
5. Observe the motor rotating clockwise at 50% speed for 3 seconds, then stopping for 1 second.
6. Observe the motor rotating counter-clockwise at 75% speed for 3 seconds, then stopping for 1
second.
7. Repeat the steps as needed.
Code
#include <Arduino.h>
#define MOTOR_A 8
#define MOTOR_B 9
void setup() {
pinMode(MOTOR_A, OUTPUT);
pinMode(MOTOR_B, OUTPUT);
}
void loop() {
rotateMotor(128, true); // Clockwise at 50% speed
delay(3000);
stopMotor();
delay(1000);
void stopMotor() {
digitalWrite(MOTOR_A, LOW);
digitalWrite(MOTOR_B, LOW);
}
Observations
1. The motor rotates clockwise at 50% speed when the rotateMotor() function is called with true.
2. The motor stops for 1 second when the stopMotor() function is executed.
3. The motor rotates counter-clockwise at 75% speed when the rotateMotor() function is called with
false.
4. The speed of the motor depends on the PWM value passed to rotateMotor() (0 to 255).
Conclusion
The experiment demonstrates how to control the direction and speed of a DC motor using an Arduino Due
and an L9110S driver. PWM signals are effectively used to vary the motor’s speed, and digital signals
control its direction.
Viva Questions
Components Required:
1. Arduino Board (e.g., Arduino Uno, Mega, Due, etc.)
2. DHT11 Temperature and Humidity Sensor
3. 16x2 I2C LCD
4. Jumper Wires
5. Breadboard (optional)
Circuit Diagram:
Connections:
DHT11 Sensor:
o VCC → 5V (or 3.3V if required by your board)
o GND → GND
o DATA → Digital Pin 2
I2C LCD:
o SDA → SDA Pin on Arduino (A4 on Uno, Mega: Pin 20, Due: Pin 20)
o SCL → SCL Pin on Arduino (A5 on Uno, Mega: Pin 21, Due: Pin 21)
o VCC → 5V
o GND → GND
Procedure:
Step 1: Install Required Libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>
// Define LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set LCD I2C address and size
void setup() {
// Initialize LCD
lcd.init();
lcd.backlight();
// Welcome message
lcd.setCursor(0, 0);
lcd.print("DHT11 Sensor");
lcd.setCursor(0, 1);
lcd.print("Initializing...");
delay(2000); // Wait for 2 seconds
lcd.clear();
}
void loop() {
// Read temperature and humidity
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
1. Open the Serial Monitor to ensure there are no errors from the sensor.
2. The LCD will display the temperature and humidity values in real-time.
Expected Output:
The LCD should display:
Temp: XX.X C
Humidity: XX.X %
Sensor error!
Conclusion:
In this experiment, we successfully interfaced a DHT11 sensor with a 16x2 I2C LCD to measure and
display temperature and humidity values in real-time using an Arduino board.
Troubleshooting:
1. Ensure proper wiring of the DHT11 and I2C LCD.
2. Check the I2C address of the LCD (commonly 0x27 or 0x3F) and update it in the code if needed.
3. Verify that the libraries are installed correctly.
4. Ensure the DHT11 sensor is not exposed to extreme temperatures or humidity beyond its rated
range.
To design and implement a flame detection system that activates a buzzer when a flame is detected.
Components Required:
Theory:
The flame sensor detects the presence of a flame and outputs a signal. In the case of most flame sensors, the
output is LOW when a flame is detected. The Arduino will read this signal and activate a buzzer to alert the
user. The buzzer will generate a 2kHz sound for a short duration (500ms) when flame is detected. If no
flame is detected, the system will remain silent.
Pin Configuration:
Schematic Diagram:
1. Connect the VCC pin of the flame sensor to the 5V pin of the Arduino.
2. Connect the GND pin of the flame sensor to the GND pin of the Arduino.
3. Connect the DO (Digital Output) pin of the flame sensor to Pin 7 of the Arduino.
4. Connect the positive terminal of the buzzer to Pin 8 of the Arduino.
5. Connect the negative terminal of the buzzer to GND.
Procedure:
cpp
CopyEdit
// Define buzzer and flame sensor pins
#define BUZZER_PIN 8
#define FLAME_SENSOR_PIN 7
void setup() {
pinMode(BUZZER_PIN, OUTPUT);
pinMode(FLAME_SENSOR_PIN, INPUT);
Serial.begin(9600); // Initialize Serial Monitor
}
void loop() {
int flameDetected = digitalRead(FLAME_SENSOR_PIN); // Read flame sensor
Precautions:
Do not place the flame sensor too close to the flame to avoid damage to the sensor.
Ensure that the flame is extinguished after testing to avoid fire hazards.
Handle the Arduino and all components with care, especially when powering up.
Conclusion:
In this experiment, you successfully created a simple flame detection system using an Arduino, a flame
sensor, and a buzzer. The system effectively detects flames and activates the buzzer to alert the user. This
type of system can be useful for fire safety applications.
Lab Manual: Interfacing a 4x4 Keypad with I2C 16x4 LCD Using Arduino
Due
Objective: To interface a 4x4 matrix keypad with an Arduino Due and display the pressed keys on a 16x4
I2C LCD.
Required Components:
1. Arduino Due
2. 4x4 Matrix Keypad
3. 16x4 I2C LCD Display
4. Jumper Wires
5. Breadboard (optional)
Theory: A 4x4 matrix keypad consists of 16 keys arranged in a 4-row and 4-column configuration. When a
key is pressed, it connects a specific row and column, which can be detected by scanning the keypad. The
I2C LCD is used to display the pressed key values efficiently using only two wires (SDA & SCL) for
communication.
Circuit Connections:
Keypad:
o Connect the 4 row pins of the keypad to Arduino Due digital pins 9, 8, 7, and 6.
o Connect the 4 column pins of the keypad to Arduino Due digital pins 5, 4, 3, and 2.
I2C LCD:
o Connect SDA to Arduino Due SDA (Pin 20)
o Connect SCL to Arduino Due SCL (Pin 21)
o Connect VCC to 5V
o Connect GND to GND
Code Implementation:
#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Keypad Test");
}
void loop() {
char key = keypad.getKey();
if (key) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Key Pressed: ");
lcd.setCursor(0, 1);
lcd.print(key);
}
}
Procedure:
Expected Output:
When a key is pressed, its corresponding character should appear on the LCD.
Troubleshooting:
If the LCD does not display text, check the I2C address (use an I2C scanner if needed).
Ensure correct wiring of keypad row and column pins.
Verify that the Keypad.h and LiquidCrystal_I2C.h libraries are properly installed.
Conclusion: In this experiment, we successfully interfaced a 4x4 matrix keypad with an Arduino Due and
displayed the pressed key on a 16x4 I2C LCD. This setup can be extended to applications such as password
authentication systems or menu navigation in embedded projects.