[go: up one dir, main page]

0% found this document useful (0 votes)
162 views10 pages

EMbedded

This document describes an experiment to interface an IR sensor to an Arduino board to realize an obstacle detector. It lists the required apparatus including an IR sensor, Arduino Uno board, LED, resistor and connecting wires. It provides a connection diagram and an Arduino program to detect obstacles using the IR sensor and indicate detection by turning on an LED. It reads the IR sensor value and turns on the LED if an obstacle is detected by a high sensor value and turns off the LED if no obstacle is detected with a low sensor value.

Uploaded by

A
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)
162 views10 pages

EMbedded

This document describes an experiment to interface an IR sensor to an Arduino board to realize an obstacle detector. It lists the required apparatus including an IR sensor, Arduino Uno board, LED, resistor and connecting wires. It provides a connection diagram and an Arduino program to detect obstacles using the IR sensor and indicate detection by turning on an LED. It reads the IR sensor value and turns on the LED if an obstacle is detected by a high sensor value and turns off the LED if no obstacle is detected with a low sensor value.

Uploaded by

A
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/ 10

Swami Keshvanand Institute of Technology, Management and Gramothan,

Department of Electrical Engineering

Experiment No-5
Object
Write a program to interfacing IR sensor to realize obstacle detector
Apparatus Required
S. No. Name of Apparatus Specifications Type Quantity
1. IR Obstacle Sensor - - 1
2. Arduino Board Microcontroller: ATmega328P Uno 1
Operating Voltage: 5V
3. LED 3mm - 1

4. Resistance 300ohm - 1

5. Connecting Wires - - As per required

Brief Theory

Fig 5.1: Connection diagram of IR sensor with Arduino

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 1


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

Program:
int IR = 3;
int led = 12;

void setup()
{
// put your setup code here, to run once:
pinMode(IR, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int z= digitalRead(IR);
if (z == HIGH)
{
digitalWrite(led, HIGH);
}
if (z == LOW)
{
digitalWrite(led, LOW);
}
}

Result

Viva-Voce Questions

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 2


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

Experiment No-6
Object
Write a program to implement temperature measurement and displaying the same on an LCD display.
Apparatus Required
S. No. Name of Apparatus Specifications Type Quantity
1. Temperature Sensor LM 35 - 1
2. Arduino Board Microcontroller: ATmega328P Uno 1
Operating Voltage: 5V
3. LCD 16X2 - 1

4. Potentiometer 1K - 1

5. Connecting Wires - - As per required

Brief Theory

Fig 6.1: Connection diagram of Temperature sensor with Arduino

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 3


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

Program:
#include <LiquidCrystal.h>
LiquidCrystal LCD(10, 9, 5, 4, 3, 2);
float tempC;
int reading;
int tempPin = 1;

void setup()
{
LCD.begin(16,2);
LCD.setCursor(0,1);
LCD.print(" ");
LCD.setCursor(0,0);
LCD.print(" ");

analogReference(INTERNAL);
Serial.begin(9600);
}

void loop()
{
reading = analogRead(tempPin);
tempC = reading / 9.31;
Serial.println(tempC);

LCD.setCursor(0,0);
LCD.print(" Temperature ");

LCD.setCursor(0,1);
LCD.print(" ");
LCD.print(tempC);
LCD.print(" C ");
delay(200);
LCD.setCursor(0,1);
LCD.print(" ");
}

Result

Viva-Voce Questions

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 4


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

Experiment No-7
Object
Write a program for interfacing GAS sensor and perform GAS leakage detection.
Apparatus Required
S. No. Name of Apparatus Specifications Type Quantity
1. Gas Sensor MQ-4 - 1
2. Arduino Board Microcontroller: ATmega328P Uno 1
Operating Voltage: 5V
3. LCD 16X2 - 1

4. Potentiometer 1K - 1

5. Connecting Wires - - As per required

Brief Theory

Fig 7.1: Connection diagram of Gas sensor with Arduino

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 5


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

Program:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
int led = 6;
int Gas = 7;
void setup()
{
pinMode(led, OUTPUT);
pinMode(Gas , INPUT);
}
void loop()
{
if(digitalRead(Gas) == HIGH){digitalWrite(led, HIGH);}
if(digitalRead(Gas) == LOW){digitalWrite(led, LOW); }
}

Result

Viva-Voce Questions

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 6


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

Experiment No-8
Object
Write a program to design the Traffic Light System and implement the same using suitable hardware.
Apparatus Required
S. No. Name of Apparatus Specifications Type Quantity
1. Arduino Board Microcontroller: ATmega328P Uno 1

Operating Voltage: 5V
2. LED 3mm Red 4
Green 4
Yellow 4
3. Connecting Wires - - As per required

Brief Theory

Fig 8.1: Connection diagram

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 7


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

Program:
int g1 = 2;
int y1 = 3;
int r1 = 4;
int g2 = 5;
int y2 = 6;
int r2 = 7;
int g3 = 8;
int y3 = 9;
int r3 = 10;
int g4 = 11;
int y4 = 12;
int r4 = 13;

void setup()
{
pinMode (r1, OUTPUT);
pinMode (y1, OUTPUT);
pinMode (g1, OUTPUT);
pinMode (r2, OUTPUT);
pinMode (y2, OUTPUT);
pinMode (g2, OUTPUT);
pinMode (r3, OUTPUT);
pinMode (y3, OUTPUT);
pinMode (g3, OUTPUT);
pinMode (r4, OUTPUT);
pinMode (y4, OUTPUT);
pinMode (g4, OUTPUT);
}

void loop() {
// PATTERN 1 AND 2

digitalWrite(g1,HIGH);
digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);
digitalWrite(r4,HIGH);
delay(10000);

digitalWrite(g1,LOW);

digitalWrite(y1,HIGH);
digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);
digitalWrite(r4,HIGH);
delay(3000);

digitalWrite(y1,LOW);
digitalWrite(r2,LOW);

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 8


Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

digitalWrite(r1,HIGH);
digitalWrite(g2,HIGH); //2nd light
digitalWrite(r3,HIGH);
digitalWrite(r4,HIGH);
delay(10000);

digitalWrite(g2,LOW);

digitalWrite(y2,HIGH);
digitalWrite(r1,HIGH);
digitalWrite(r3,HIGH);
digitalWrite(r4,HIGH);
delay(3000);

digitalWrite(y2,LOW);
digitalWrite(r3,LOW);

digitalWrite(g3,HIGH);//3rd light
digitalWrite(r1,HIGH);
digitalWrite(r2,HIGH);
digitalWrite(r4,HIGH);
delay(10000);

digitalWrite(g3,LOW);

digitalWrite(y3,HIGH);
digitalWrite(r1,HIGH);
digitalWrite(r2,HIGH);
digitalWrite(r4,HIGH);
delay(3000);

digitalWrite(y3,LOW);
digitalWrite(r3,LOW);
digitalWrite(r4,LOW);

digitalWrite(g4,HIGH);//4th light
digitalWrite(r1,HIGH);
digitalWrite(r2,HIGH);
digitalWrite(r3,HIGH);
delay(10000);

digitalWrite(g4,LOW);
digitalWrite(r4,LOW);

digitalWrite(y4,HIGH);
digitalWrite(r1,HIGH);
digitalWrite(r2,HIGH);
DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 9
Swami Keshvanand Institute of Technology, Management and Gramothan,
Department of Electrical Engineering

digitalWrite(r3,HIGH);
delay(3000);

digitalWrite(y4,LOW);
digitalWrite(r4,LOW);
digitalWrite(r1,LOW);

Result

Viva-Voce Questions

DOEE/LAB MANUAL/7EE4-21/ Embedded System Lab Page 10

You might also like