0% found this document useful (0 votes)
229 views8 pages

IoT Lab Assignment No. 2

iot lab assignment 2 sppu

Uploaded by

samarpita.kule
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)
229 views8 pages

IoT Lab Assignment No. 2

iot lab assignment 2 sppu

Uploaded by

samarpita.kule
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/ 8

T.E.

(Computer Engineering) IoT and Embedded System

Class: - TE Div.:- _Name:-_ _Roll No._

Assignment 2: Connectivity of Arduino / Raspberry Pi with IR Sensor.


Problem Statement:-
Understanding the Connectivity of Arduino / Raspberry Pi with IR Sensor. Write
an application to detect obstacle and notify user using LEDs.
Components: IR Sensor, LED, Arduino board/Raspberry Pi board, connecting
wires etc.
Theory:

Fig.1 IR Sensor
An infrared sensor is an electronic device that emits in order to sense some aspects of the
surroundings. An IR sensor can measure the heat of an object as well as detects motion. These
types of sensors measures only infrared radiation, rather than emitting it that is called as a
passive IR sensor.

Fig.2 Working of IR Sensor

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune


T.E. (Computer Engineering) IoT and Embedded System

Fig.3 Connection Diagram IR Sensor with Arduino Board

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune


T.E. (Computer Engineering) IoT and Embedded System

Arduino Code:

Arduino Code for Obstacle detection using IR Sensor


int IRSensor = 2; // connect ir sensor to arduino pin 2

int LED = 13; // conect Led to arduino pin 13

void setup()
{
pinMode (IRSensor, INPUT); // sensor pin INPUT

pinMode (LED, OUTPUT); // Led pin OUTPUT


}

void loop()
{
int statusSensor = digitalRead (IRSensor); if

(statusSensor == 1)

digitalWrite(LED, LOW); // LED LOW

else

{
digitalWrite(LED, HIGH); // LED High

IR Sensor Connections with Arduino Board:-


Arduino Board Pin Number /
Sr. No. IR Sensor
Pin Name
1 Vcc

2 Gnd

3 Out

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune


T.E. (Computer Engineering) IoT and Embedded System

Write Arduino Code to obstacle detection

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune


T.E. (Computer Engineering) IoT and Embedded System

Fig 4. Connection of IR Sensor With Raspberry Pi Board

Raspberry Pi Code:

import RPi.GPIO as GPIO

import time

GPIO.setmode(GPIO.BOARD)

GPIO.setwarnings(False)

GPIO.setup(3,GPIO.IN)

GPIO.setup(5,GPIO.OUT)

while True:

val=GPIO.input(3)

print(val)

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune


T.E. (Computer Engineering) IoT and Embedded System

if val = = 0:

print("Object Detected")

GPIO.output(5,GPIO.HIGH)

time.sleep(1)

else:

print("Object Not Detected")

GPIO.output(5,GPIO.LOW)

time.sleep(1)

IR Sensor Connections with Raspberry Pi Board:-


Raspberry Pi Pin Number /
Sr. No. IR Sensor
Pin Name
1 Vcc

2 Gnd

3 Out

Write Raspberry Pi Code to obstacle detection

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune


T.E. (Computer Engineering) IoT and Embedded System

Result:-

Sr. No. Output

Conclusion:-

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune


T.E. (Computer Engineering) IoT and Embedded System

Fig.5 Raspberry Pi Board

Prof. Rakhi S. Punwatkar Zeal College of Engineering and Research, Pune

You might also like