0% found this document useful (0 votes)
0 views38 pages

Arduino Practical File (1)

The document is an assignment submitted by Priyanshu Kanaujiya for the Arduino course, detailing various practical projects involving embedded systems. It includes a certification of completion, a list of practical tasks, and specific code examples for projects such as blinking LEDs, gas detection, temperature monitoring, and motion detection using sensors. The assignment is guided by Asst. Prof. Dr. Janhavi Raut and is part of the academic year 2024-2025.

Uploaded by

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

Arduino Practical File (1)

The document is an assignment submitted by Priyanshu Kanaujiya for the Arduino course, detailing various practical projects involving embedded systems. It includes a certification of completion, a list of practical tasks, and specific code examples for projects such as blinking LEDs, gas detection, temperature monitoring, and motion detection using sensors. The assignment is guided by Asst. Prof. Dr. Janhavi Raut and is part of the academic year 2024-2025.

Uploaded by

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

ASSIGNMENT

ON
JOURNAL
IN THE COURSE
Arduino
SUBMITTED BY
Name: Priyanshu Kanaujiya

ROLL NO: SDIT053A

SEMESTER III
UNDER THE GUIDANCE OF
Asst. Prof. Dr. Janhavi Raut
ACADEMIC YEAR
2024 - 2025
CERTIFICATE

This is to certify that Mr. Priyanshu Kanaujiya of Second


year BSC.IT. Div.: A Roll No. SDIT053A Semester III (2024-
2025) has successfully completed the Assignment for the
course A r d u i n o as per the guidelines of KES’ Shroff
College of Arts and Commerce, Kandivali(W), Mumbai-
400067.

Teacher In-charge Principle


Asst. Prof. Dr. Janhavi Raut Dr. L. Bhushan
Sr. Practical
No.
1. Introduction of Embedded system Component.

2. To Blink a single LED and multiple LEDs.

3. To Create an Arduino project using a gas sensor with a


buzzer and check if gas is present in the environment.
If detected, the buzzer activates and gives an alert.

4. To create an Arduino project using a temperature sensor


and display the temperature on an LCD. The buzzer will
give an alert if the temperature exceeds.

5. To create an Arduino project using an ultrasonic sensor


to measure the distance to an object.

6. To create an Arduino project to detect motion using a


PIR sensor. If motion is detected, the buzzer will be
activated.

7. To create an Arduino program to detect motion using a


PIR sensor and then perform specific actions when
motion is detected using a servo motor.

8. To create an Arduino program using a moisture sensor


to measure the amount of moisture (water content)
present in the soil and supply the required water using a
DC motor.

9. To Create on Arduino project to use of Soil moisture


sensors.

10. To Create on Arduino project to use of Force Sensor.


Practical.1

Introduction of Embedded system Component.

1. Arduino Uno R3 Digital Pins

● Description: The Arduino Uno R3 is a microcontroller board based on the


ATmega328P. It features 14 digital input/output pins, of which 6 can be used as PWM
outputs. These pins are used to interact with various sensors and actuators in
embedded projects.
● Use: The digital pins are used to read digital signals (like on/off states) from sensors and
to control devices like LEDs, motors, and more.
2. Breadboard

● Description: A breadboard is a construction base used for prototyping electronics. It


allows you to connect components easily without soldering.
● Use: Ideal for creating temporary circuits, testing, and iterating designs before finalizing
them on a more permanent platform.

3. LED (Light Emitting Diode)

● Description: LEDs are semiconductor devices that emit light when an electric current
passes through them.
● Use: Commonly used as indicators in circuits to show the status of a system, such as
power on, error states, etc.

4. LCD (Liquid Crystal Display)

● Description: An LCD is a flat-panel display technology that uses liquid crystals to


produce images.
● Use: Used to display information, such as sensor readings, time, or any other data, in a
user-friendly format.

5. Resistor

● Description: A resistor is a passive electrical component that limits the flow of electric
current in a circuit.
● Use: Essential for controlling current, protecting components like LEDs from damage
due to excessive current.

6. Jumper Wires
● Description: Jumper wires are short, insulated wires used to connect components on a
breadboard or to establish connections between the breadboard and the Arduino.
● Use: Used for making temporary connections during prototyping.

7. Temperature Sensor

● Description: A device that measures temperature and converts it into a signal that can
be read by the microcontroller.
● Example: The LM35 is a common temperature sensor that provides an analog output
proportional to the temperature.
● Use: Used in projects where temperature monitoring or control is necessary.
8. Gas Sensor

● Description: A gas sensor detects the presence of gases in an area and provides an
output that can be used to trigger an alarm or log data.
● Example: The MQ series (like MQ-2, MQ-7) sensors are commonly used to detect
gases like methane, carbon monoxide, etc.
● Use: Essential in safety and environmental monitoring projects.

9. Ultrasonic Sensor

● Description: An ultrasonic sensor measures distance by emitting sound waves and


calculating the time it takes for the waves to bounce back after hitting an object.
● Example: HC-SR04 is a widely used ultrasonic sensor in robotics and obstacle
detection.
● Use: Used for measuring distance or detecting objects in automation, robotics, and
security systems.

10. IR Sensor (Infrared Sensor)

● Description: An IR sensor detects infrared light reflected from objects and can be used
to measure distance or detect objects.
● Use: Common in remote control systems, proximity detection, and line-following robots.

11. Moisture Sensor

● Description: A moisture sensor measures the water content in the soil or another
substance.
● Use: Often used in automated irrigation systems to maintain optimal soil moisture levels.
12. Buzzer

● Description: A buzzer is an audio signaling device that converts electrical signals into
sound.
● Use: Used to provide audio feedback, alerts, or alarms in various embedded projects.

13. Servo Motor

● Description: A servo motor is a rotary actuator that allows precise control of angular
position, typically using feedback control.
● Use: Commonly used in robotics, automation systems, and any project requiring precise
movement control.

Practical 2

Blinking single LED, Blinking multiple LEDs.

1.Single LED:

Code :
Output :

Multiple LED :
Code :
int LED=8;
int led=2;
int Led=13;
int LEd=12;
int LeD=7;
void setup()
{
pinMode( LED, OUTPUT);
pinMode( led, OUTPUT);
pinMode( 13, OUTPUT);
pinMode( 12, OUTPUT);
pinMode( 7, OUTPUT);

void loop()
{
digitalWrite( LED, HIGH);
delay(1000); // Wait for 1000 millisecond(s)

digitalWrite( LED, LOW);


delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( led, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( led, LOW);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( 13, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( 13, LOW);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( 12, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( 12, LOW);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( 7, HIGH);
delay(1000); // Wait for 1000 millisecond(s)
digitalWrite( 7, LOW);
delay(1000); // Wait for 1000 millisecond(s)
}

Output :
Practical 3

Create an Arduino project to use of gas sensor with a buzzer and


check if gas present in the environment. The buzzer should start
and give an alert.

Code :
int LED = 13;
int BUZZ = 3;
const int gas = 0;
int MQ2pin = A0;
void setup() {
pinMode(LED,OUTPUT);
pinMode(BUZZ,OUTPUT);
}
void loop() {
float sensorValue,MQ2pin;
sensorValue = analogRead(MQ2pin);
if(sensorValue >= 270){
digitalWrite(LED,HIGH);
digitalWrite(BUZZ,HIGH);
}
else{
digitalWrite(LED,LOW);
digitalWrite(BUZZ,LOW);
}
delay(500);
}
float getsensorValue(int pin){
return (analogRead(pin));
}

Output :
Practical 4
Create an Arduino project for reading a temperature sensor and
displaying the temperature on an LCD. The buzzer gives an alert
if the temperature exceeds 80°C.

Code :
#include <Adafruit_LiquidCrystal.h> // Include the Adafruit library for
LCD
int sensorPin = 0; // Analog pin for temperature sensor
const int buzzer = 9; // Buzzer connected to digital pin 9
Adafruit_LiquidCrystal lcd_1(0); // Create an LCD object with I2C
address 0
void setup()
{
lcd_1.begin(16, 2); // Initialize the LCD with 16 columns and 2 rows
pinMode(buzzer, OUTPUT); // Set pin 9 as an output for the buzzer
}
void loop()
{
lcd_1.clear(); // Clear the LCD display
int reading = analogRead(sensorPin); // Read the analog value from
the sensor
float voltage = reading * 5.0 / 1024.0; // Convert the reading to a
voltage
float temperatureC = (voltage - 0.5) * 100; // Convert the voltage to
Celsius
lcd_1.setCursor(0, 1); // Set the cursor to the second row
lcd_1.print(temperatureC); // Display the temperature on the LCD
lcd_1.println(" degrees C "); // Add "degrees C" to the display
delay(1000); // Wait for 1 second
if(temperatureC > 30) // If the temperature exceeds 30 degrees
Celsius
{
tone(buzzer, 1000); // Sound the buzzer at 1KHz
delay(1000); // Keep the buzzer on for 1 second
noTone(buzzer); // Turn off the buzzer
delay(1000); // Wait for 1 second
}
}

Output :
Practical 5
Create an Arduino project for an ultrasonic Sensor to measure
the distance to an object.

Code :
int trigPin = 10; // Define pin 10 for the trigger pin of the ultrasonic
sensor
int echoPin = 9; // Define pin 9 for the echo pin of the ultrasonic
sensor

long time; // Variable to store the time it takes for the echo to
return
float distance; // Variable to store the calculated distance

void setup() {
pinMode(trigPin, OUTPUT); // Set the trigger pin as an output
pinMode(echoPin, INPUT); // Set the echo pin as an input
Serial.begin(9600); // Initialize serial communication at 9600 baud
rate
}

void loop() {
// Ensure the trigger pin is low before sending a pulse
digitalWrite(trigPin, LOW);
delayMicroseconds(2);

// Transmit a sound pulse for 10 microseconds


digitalWrite(trigPin, HIGH); // Set the trigger pin high
delayMicroseconds(10); // Wait for 10 microseconds
digitalWrite(trigPin, LOW); // Set the trigger pin low

// Measure the duration of the echo pulse


time = pulseIn(echoPin, HIGH); // Measure the time for the echo pin
to go high

// Print the time to the serial monitor


Serial.print("Time: ");
Serial.println(time);

// Calculate the distance based on the time of the echo


distance = time * 0.0343 / 2; // Convert time to distance (speed of
sound is 0.0343 cm/microsecond)

// Print the calculated distance to the serial monitor


Serial.print("Distance: ");
Serial.println(distance);

delay(500); // Add a short delay before the next measurement


}
Output :
Practical 6

Create an Arduino project (program) for motion detection


using a PIR sensor. If motion is detected, the buzzer is
activated.

Code :
int pir_pin = 12; // Define pin 12 for the PIR sensor
int buzzer_pin = 2; // Define pin 2 for the buzzer
void setup()
{
pinMode(pir_pin, INPUT); // Set the PIR sensor pin as an input
pinMode(buzzer_pin, OUTPUT); // Set the buzzer pin as an output
}
void loop()

{
int motion = 0; // Initialize a variable to store the motion status
motion = digitalRead(pir_pin); // Read the PIR sensor status
if (motion == HIGH) { // If motion is detected
digitalWrite(buzzer_pin, HIGH); // Turn on the buzzer
}
else
{ // If no motion is detected
digitalWrite(buzzer_pin, LOW); // Turn off the buzzer
}
delay(15);
}

Output :
Practical 7
Create an Arduino program to detect motion using PIR
sensor and then perform specific action when motion is
detected using a servo motor.

Code :
#include <Servo.h> // Include the Servo library

Servo myservo; // Create a Servo object to control a servo


int ledPin = 13; // Define pin 13 for the LED

int pirPin = 2; // Define pin 2 for the PIR sensor output


int pirStat = 0; // Variable to store the PIR sensor status
int pos = 0; // Variable to store the servo position
void setup()
{
pinMode(ledPin, OUTPUT); // Set the LED pin as an output
pinMode(pirPin, INPUT); // Set the PIR sensor pin as an input
myservo.attach(9); // Attach the servo to pin 9
Serial.begin(9600); // Start serial communication at 9600 baud rate
}
void loop()
{
pirStat = digitalRead(pirPin); // Read the status of the PIR sensor
if (pirStat == HIGH) { // If motion is detected
digitalWrite(ledPin, HIGH); // Turn the LED on
Serial.println("Hey I got you!!!"); // Print a message to the serial
monitor
for (pos = 0; pos <= 180; pos += 1)
{ // Move the servo from 0 to 180 degrees
myservo.write(pos); // Set the servo position
delay(15); // Wait for 15 milliseconds
}
digitalWrite(ledPin, LOW); // Turn the LED off if no motion
for (pos = 180; pos >= 0; pos -= 1)
{ // Move the servo from 180 to 0 degrees
myservo.write(pos); // Set the servo position
delay(15); // Wait for 15 milliseconds
}
}
else {
// If no motion is detected, do nothing
}

Output :
Practical 8
Create an Arduino program with a moisture sensor to
measure the amount of moisture (water content) present
in the soil and supply the water required using a DC
motor.

Code :
const int motor = 13; // Motor connected to digital pin 13
const int Led = 12; // LED connected to digital pin 12
int percentValue = 0; // Variable to store percentage value (not used in
the current code)

void setup() {
pinMode(motor, OUTPUT); // Set pin 13 as an output for the motor
pinMode(Led, OUTPUT); // Set pin 12 as an output for the LED
delay(2000); // Wait for 2 seconds
}

void loop() {
int value = analogRead(A0); // Read the analog value from pin A0
float Moisture = value * 500.0 / 1023.0; // Convert the reading to a
moisture level

if (Moisture < 220){


// If moisture level is less than 220
digitalWrite(motor, HIGH); // Turn on the motor
digitalWrite(Led, HIGH); // Turn on the LED
}
else
{ // If moisture level is 220 or higher
digitalWrite(motor, LOW); // Turn off the motor
digitalWrite(Led, LOW); // Turn off the LED
}
}

Output :
Practical 9
Create an Arduino project to use of IR Sensor (Infrared Sensor).

Code :
const int irSensor=2; //define pin where sensor's out pin is connected
int LED = 13;
int led = 8;
int BUZZ = 7;

void setup() {
Serial.begin(9600); // set the baud rate for serial communication
pinMode(irSensor,INPUT); //set sensor pin as input to receive data
from the pin
pinMode(13, OUTPUT);
pinMode(8, OUTPUT);
pinMode(BUZZ,OUTPUT);

void loop() {

int irData=digitalRead(irSensor); //create a variable to store sensor


data
Serial.print("IR SENSOR DATA:"); //print the data on the serial monitor
Serial.println(irData);
digitalWrite(13, HIGH);
delay(1000); // Wait for 1 second
digitalWrite(13, LOW);
delay(1000); // Wait for 1 second
digitalWrite(8, HIGH);
delay(1000); // Wait for 1 second
digitalWrite(8, LOW);
delay(1000); // Wait for 1 second
digitalWrite(BUZZ,HIGH);
}

Output :
Practical 10
Create an Arduino project to use of Force Sensor.

Code :
#define fsrpin A0
#define led1 2
#define led2 3
#define led3 4
#define led4 5
#define led5 6
#define led6 7
int fsrreading;
void setup() {

Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
}
void loop() {
fsrreading = analogRead(fsrpin);
Serial.println(fsrreading);
if (fsrreading > 200) {
digitalWrite(led1, HIGH);
}
else digitalWrite(led1, LOW);
if (fsrreading > 450) {
digitalWrite(led2, HIGH);
}
else digitalWrite(led2, LOW);
if (fsrreading > 550) {
digitalWrite(led3, HIGH);
}
else digitalWrite(led3, LOW);
if (fsrreading > 650) {
digitalWrite(led4, HIGH);
}
else digitalWrite(led4, LOW);
if (fsrreading > 800) {
digitalWrite(led5, HIGH);
}
else digitalWrite(led5, LOW);

if (fsrreading > 900) {


digitalWrite(led6, HIGH);
}
else digitalWrite(led6, LOW);
}
Output:

You might also like