0% found this document useful (0 votes)
2 views

DUE EXPS

The document outlines a series of experiments designed to familiarize users with the ARM Cortex M3 evaluation board and Arduino Due, focusing on programming and interfacing various components such as LEDs, switches, motors, and sensors using Embedded 'C' and Arduino IDE. It includes detailed procedures for setting up hardware and software, writing code, and testing the functionality of each experiment. Each section concludes with observations, results, and viva questions to reinforce learning outcomes.

Uploaded by

20r11a04d7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

DUE EXPS

The document outlines a series of experiments designed to familiarize users with the ARM Cortex M3 evaluation board and Arduino Due, focusing on programming and interfacing various components such as LEDs, switches, motors, and sensors using Embedded 'C' and Arduino IDE. It includes detailed procedures for setting up hardware and software, writing code, and testing the functionality of each experiment. Each section concludes with observations, results, and viva questions to reinforce learning outcomes.

Uploaded by

20r11a04d7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 20

LEARNING OUTCOMES:

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)

3. Femiliarise with KeiluVision-5 tool/ ARDUINO IDE (or equivalent software)

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. Place the LED and the resistor on the breadboard.


2. Make the connections as per the circuit diagram:
o Pin 13 → LED anode (long leg).
o LED cathode → Resistor → GND.
3. Verify all connections to ensure accuracy.
2. Software Setup

1. Open the Arduino IDE.


2. Select the correct board:
o Go to Tools > Board > Arduino Due (Programming Port).
3. Select the correct COM port:
o Go to Tools > Port and select the port associated with Arduino Due.

3. Write the Code

1. Copy and paste the following code into the Arduino IDE:

// Blink LED on Arduino Due

// Define the pin for the LED


#define LED_PIN 13

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);
}

4. Upload the Code

1. Click the Upload button in the Arduino IDE.


2. Wait for the IDE to compile and upload the code.
3. Observe the LED connected to pin 13. It should blink with a 1-second interval.

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.

Lab Manual: Switch Interface with Arduino Due


Objective
To interface a switch with Arduino Due, read its status, and control an output device (LED/Relay/Buzzer)
based on the switch state.

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

1. Place the switch and output device (LED/Relay/Buzzer) on the breadboard.


2. Connect the switch terminals as described:
o Pin 7 → Switch terminal 1.
o Switch terminal 2 → GND.
3. Connect the LED anode to pin 13 through a 330Ω resistor (or connect the relay/buzzer driver circuit
to pin 13).

2. Software Setup

1. Open the Arduino IDE on your computer.


2. Select the board:
o Go to Tools > Board > Arduino Due (Programming Port).
3. Select the COM port:
o Go to Tools > Port and choose the appropriate port.

3. Write the Code

1. Copy and paste the following code into the Arduino IDE:

// Define the pins


#define SWITCH_PIN 7 // Input pin for the switch
#define OUTPUT_PIN 13 // Output pin for LED/Relay/Buzzer

void setup() {
// Set the switch pin as INPUT with an internal pull-up resistor
pinMode(SWITCH_PIN, INPUT_PULLUP);

// Set the output pin as OUTPUT


pinMode(OUTPUT_PIN, OUTPUT);

// Initialize the output pin to LOW (OFF state)


digitalWrite(OUTPUT_PIN, LOW);
}

void loop() {
// Read the state of the switch
int switchState = digitalRead(SWITCH_PIN);

// Check if the switch is pressed (LOW state, due to pull-up resistor)


if (switchState == LOW) {
// Turn ON the LED/Relay/Buzzer
digitalWrite(OUTPUT_PIN, HIGH);
} else {
// Turn OFF the LED/Relay/Buzzer
digitalWrite(OUTPUT_PIN, LOW);
}
}

4. Upload the Code

1. Click the Upload button in the Arduino IDE.


2. Wait for the code to compile and upload to the Arduino Due.

5. Test the Circuit

1. Observe the output device (LED/Relay/Buzzer).


2. Press the switch and verify that the output device turns ON.
3. Release the switch and verify that the output device turns OFF.

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:

 Arduino Due (1 unit)


 DS1307 RTC Module (1 unit)
 16x2 LCD with I2C Module (1 unit)
 Jumper wires (for connections)
 Breadboard (optional)

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:

1. Wiring the DS1307 RTC to Arduino Due:

 SDA (RTC) → SDA (Arduino Due) (Pin 20)


 SCL (RTC) → SCL (Arduino Due) (Pin 21)
 VCC (RTC) → 5V (Arduino Due)
 GND (RTC) → GND (Arduino Due)

2. Wiring the LCD 16x2 I2C to Arduino Due:

 SDA (LCD) → SDA (Arduino Due) (Pin 20)


 SCL (LCD) → SCL (Arduino Due) (Pin 21)
 VCC (LCD) → 5V (Arduino Due)
 GND (LCD) → GND (Arduino Due)

Procedure:

Step 1: Install Required Libraries

1. Open the Arduino IDE.


2. Go to Sketch → Include Library → Manage Libraries.
3. In the Library Manager, search and install the following libraries:
o RTClib by Adafruit (for RTC module).
o LiquidCrystal_I2C by Frank de Brabander (for the LCD).

Step 2: Connect Components

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

Upload the following code to the Arduino Due:

cpp
CopyEdit
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <RTClib.h>

// Initialize the LCD and RTC


LiquidCrystal_I2C lcd(0x27, 16, 2); // Update LCD address if different
RTC_DS1307 rtc; // RTC object without address

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());

delay(1000); // Update every 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:

 The LCD should show the current date and time.


 The time will update every second.

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:

 If the LCD is not displaying anything:


o Check the wiring.
o Ensure the I2C address of the LCD is correct (use I2C Scanner).
 If the RTC time is incorrect:
o Make sure the RTC module has a CR2032 coin battery installed.
o Manually set the time in the code if needed.

Lab Manual for Stepper Motor Control using Arduino Due

Experiment Title:

Control and Operation of Stepper Motor in Half-Step and Full-Step Modes

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:

1. Arduino Due microcontroller


2. 28BYJ-48 5V stepper motor
3. ULN2003A stepper motor driver module
4. Connecting wires
5. USB cable for Arduino
6. External power source (if required)
7. Personal computer with Arduino IDE installed

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:

(Refer to the diagram provided or follow the below connections.)

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

const int FULL_STEP_SEQUENCE[4][4] = {


{1, 0, 0, 0},
{0, 1, 0, 0},
{0, 0, 1, 0},
{0, 0, 0, 1}
};

const int HALF_STEP_SEQUENCE[8][4] = {


{1, 0, 0, 0},
{1, 1, 0, 0},
{0, 1, 0, 0},
{0, 1, 1, 0},
{0, 0, 1, 0},
{0, 0, 1, 1},
{0, 0, 0, 1},
{1, 0, 0, 1}
};

void runStepper(int steps, int delayMs, bool isHalfStep, bool isClockwise);


void setPins(const int step[], int length);

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)

Serial.println("Running in half-step mode...");


runStepper(steps, delayMs, true, true); // Half-step, clockwise
delay(1000);

Serial.println("Running in full-step mode...");


runStepper(steps, delayMs, false, false); // Full-step, counter-clockwise
delay(1000);
}

void runStepper(int steps, int delayMs, bool isHalfStep, bool isClockwise) {


const int (*sequence)[4] = isHalfStep ? HALF_STEP_SEQUENCE : FULL_STEP_SEQUENCE;
int sequenceLength = isHalfStep ? 8 : 4;

for (int i = 0; i < steps; i++) {


for (int stepIndex = 0; stepIndex < sequenceLength; stepIndex++) {
int index = isClockwise ? stepIndex : (sequenceLength - 1 - stepIndex);
setPins(sequence[index], 4);
delay(delayMs);
}
}
}

void setPins(const int step[], int length) {


for (int i = 0; i < length; i++) {
digitalWrite(IN1 + i, step[i]);
}
}

Procedure:

1. Connect the 28BYJ-48 stepper motor to the ULN2003A driver module.


2. Connect the ULN2003A driver module to the Arduino Due as per the connection table.
3. Open Arduino IDE on the computer and upload the provided program to the Arduino Due.
4. Open the Serial Monitor to monitor the execution.
5. Observe the motor rotation:
o The motor should rotate in half-step mode first.
o Then, it should rotate in full-step mode.
6. Change the parameters in the code (e.g., steps, delayMs) to observe different behaviors.

Observations:

Parameter Half-Step Mode Full-Step Mode


Torque Lower Higher
Resolution Higher Lower
Smoothness Better Moderate
Speed Slower Faster
Result:

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:

1. Ensure proper connections to avoid damage to components.


2. Do not exceed the voltage and current ratings of the motor and driver.
3. Use a stable power source to prevent fluctuations.

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.

Lab Manual: DC Motor Control Using Arduino Due and L9110S


Driver

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:

Arduino Pin L9110S Driver Pin Description


8 Input A Controls speed and direction
9 Input B Controls speed and direction
GND GND Common ground
5V VCC Powers the driver circuit

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);

rotateMotor(192, false); // Counter-clockwise at 75% speed


delay(3000);
stopMotor();
delay(1000);
}

void rotateMotor(int speed, bool clockwise) {


if (clockwise) {
analogWrite(MOTOR_A, speed);
digitalWrite(MOTOR_B, LOW);
} else {
analogWrite(MOTOR_B, speed);
digitalWrite(MOTOR_A, LOW);
}
}

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

1. What is the function of the L9110S motor driver?


2. How does PWM control the speed of a DC motor?
3. What happens if both Input A and Input B are set to LOW?
4. What are the advantages of using a motor driver with a microcontroller?
5. Can this setup control multiple motors simultaneously? Why or why not?

Lab Manual: Interfacing DHT11 Sensor with 16x2


I2C LCD using Arduino
Objective:
To interface a DHT11 sensor with a 16x2 I2C LCD using Arduino to measure and display temperature and
humidity in real-time.

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

1. Open the Arduino IDE.


2. Go to Sketch > Include Library > Manage Libraries.
3. Search for DHT sensor library by Adafruit and click Install.
4. Search for LiquidCrystal I2C library by Frank de Brabander and click Install.

Step 2: Assemble the Circuit

Connect the components as per the circuit diagram.

Step 3: Upload the Code

1. Open a new sketch in Arduino IDE.


2. Copy and paste the following code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <DHT.h>

// Define DHT sensor


#define DHTPIN 2 // Pin connected to the DHT11 sensor
#define DHTTYPE DHT11 // Define the sensor type (DHT11)
DHT dht(DHTPIN, DHTTYPE); // Initialize DHT sensor

// Define LCD
LiquidCrystal_I2C lcd(0x27, 16, 2); // Set LCD I2C address and size

void setup() {
// Initialize LCD
lcd.init();
lcd.backlight();

// Initialize DHT sensor


dht.begin();

// 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();

// Check if the reading failed


if (isnan(temperature) || isnan(humidity)) {
lcd.setCursor(0, 0);
lcd.print("Sensor error!");
delay(2000);
return;
}

// Display temperature on the first row


lcd.setCursor(0, 0);
lcd.print("Temp: ");
lcd.print(temperature);
lcd.print(" C ");

// Display humidity on the second row


lcd.setCursor(0, 1);
lcd.print("Humidity: ");
lcd.print(humidity);
lcd.print(" %");

// Wait 2 seconds before refreshing the display


delay(2000);
}

3. Verify the code by clicking the Verify button.


4. Upload the code to the Arduino by clicking the Upload button.

Step 4: Observe the Output

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 %

If there is an issue with the sensor, it will display:

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.

Lab Manual: Flame Detection and Alarm System Using Arduino


Objective:

To design and implement a flame detection system that activates a buzzer when a flame is detected.

Components Required:

 Arduino (Any model, e.g., Arduino Uno, Due, etc.)


 Flame sensor module
 Buzzer (Active or Passive)
 Connecting wires
 Breadboard
 Computer with Arduino IDE

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:

 Flame Sensor Pin (FLAME_SENSOR_PIN): Connected to digital pin 7 of Arduino


 Buzzer Pin (BUZZER_PIN): Connected to digital pin 8 of Arduino

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:

1. Wiring the Circuit:


o Set up the circuit on a breadboard as per the schematic diagram.
o Ensure that the flame sensor and buzzer are connected to the correct pins on the Arduino.
o Use jumper wires to connect the components properly.
2. Programming the Arduino:
o Open the Arduino IDE on your computer.
o Write the following code to detect flame and activate the buzzer.

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

if (flameDetected == LOW) { // Flame detected (LOW means fire detected for


most sensors)
Serial.println("Flame detected! Activating buzzer.");
// Turn buzzer on
for (int i = 0; i < 2000; i++) { // 2kHz sound for 500ms
digitalWrite(BUZZER_PIN, HIGH);
delayMicroseconds(250);
digitalWrite(BUZZER_PIN, LOW);
delayMicroseconds(250);
}
} else {
Serial.println("No flame detected.");
}
delay(1000); // 1-second pause
}

3. Upload the Code:


o Connect the Arduino to the computer using a USB cable.
o Select the correct board and port in the Arduino IDE.
o Click on the Upload button to upload the program to the Arduino.
4. Testing:
o Open the Serial Monitor from the Arduino IDE to monitor the output messages.
o When the flame sensor detects a flame, the system will print "Flame detected! Activating
buzzer." on the Serial Monitor, and the buzzer will emit a sound.
o If there is no flame, the system will print "No flame detected."
5. Observe the Results:
o Test the system with a candle or another flame source.
o Observe the response of the buzzer when the flame is detected.
o Observe the messages displayed on the Serial Monitor.

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:

1. Include the required libraries (Keypad.h and LiquidCrystal_I2C.h).


2. Define the keypad layout and initialize the keypad object.
3. Initialize the I2C LCD display.
4. Continuously scan the keypad and display the pressed key on the LCD.

#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>

// Initialize LCD with I2C address 0x27


LiquidCrystal_I2C lcd(0x27, 16, 4);

const byte ROWS = 4;


const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};

Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

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:

1. Connect the components as per the circuit diagram.


2. Upload the given code to the Arduino Due using the Arduino IDE.
3. Open the Serial Monitor (optional) to verify keypress detection.
4. Press keys on the keypad and observe the corresponding characters displayed on the LCD.

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.

You might also like