0% found this document useful (0 votes)
16 views11 pages

Esiot 2

K. Sai Prardhana conducted an experiment to interface a push button and digital sensors like an IR sensor and LDR with a Raspberry Pi. The experiment involved connecting the sensors to GPIO pins on the Raspberry Pi and writing a Python program to turn on an LED when the push button is pressed or the sensors detect something. When the push button or IR sensor detects an object, the LED is turned on, while the LDR causes the LED to turn on when uncovered and off when covered. The results and diagrams show that the sensors were successfully interfaced with the Raspberry Pi to control an LED.

Uploaded by

21eg104a45
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)
16 views11 pages

Esiot 2

K. Sai Prardhana conducted an experiment to interface a push button and digital sensors like an IR sensor and LDR with a Raspberry Pi. The experiment involved connecting the sensors to GPIO pins on the Raspberry Pi and writing a Python program to turn on an LED when the push button is pressed or the sensors detect something. When the push button or IR sensor detects an object, the LED is turned on, while the LDR causes the LED to turn on when uncovered and off when covered. The results and diagrams show that the sensors were successfully interfaced with the Raspberry Pi to control an LED.

Uploaded by

21eg104a45
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/ 11

NAME:K.

SAI PRARDHANA DATE : 07-12-23


ROLL NO : 21EG104A45 PAGE NO :
EXPERIMENT – 2
To Interface Push button/Dgital sensor(IR/LDR) with Arduino Raspberry
pi and write a program to turn ON LED when push button is pressed or
at sensor detection.

Aim : To Interface Push button/Dgital sensor(IR/LDR) with Arduino Raspberry pi and write a program to
t turn ON LED when push button is pressed or at sensor detection.

Requirements : Raspberry pi 4,LED,switch,IR sensor,personal computer.


Procedure :

1 Connect the Raspberry pi 4 to the Monitor display along with the keyboard, mouse and the ethernet
cable.

2. For the function of the switch connect the 3v3 power supply (pin 1) of the Raspberry pi to the positive
terminal of the LED display board and the negative terminal of the display board to the ground (pin 9)
and connect one of the switch pins to GPIO 17 (pin 11) and from GPIO 18 (pin 12) connect a jumper
cable to one of the LED pin and run the program.

3. Whenever we press the switch we observe that the LED glows.

4. For LDR and IR sensor connect the VCC(pin 1) to 3v3 power supply (pin1) of the Raspberry pi then
connect the ground terminal of the sensor to ground terminal (pin 6) of the Raspberry Pi and the output
terminal to GPIO 17 (pin 11) and from GPIO 18 (pin 12) connect a jumper cable to one of the LED pin
and run the program.

5. Run the program and observe the output.

Program :

import RPi.GPIO as GPIO // Importing RPi GPIO as GPIO //


import time // Importing or setting time //
GPIO.setwarnings(False) // To get only errors but not warnings //
GPIO.setmode(GPIO.BCM) // Setting the GPIO pin in BCM //
GPIO.setup(17,GPIO.IN) // Taking input from GPIO17 pin
// GPIO.setup(18,GPIO.OUT) // Showing output in GPIO18 pin //
while(True): // while loop //
if ( GPIO.input(17)==0): // If GPIO 17 is 0
// GPIO.output(18,GPIO.HIGH) // Output is high //
time.sleep(1) // Output high only for 1 second //
ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT
NAME: K.SAI PRARDHANA DATE : 07-12-23
ROLL NO: 21EG104A45 PAGE NO :

FLOW CHART
ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT
NAME: K.SAI PRARDHANA DATE : 07-12-23
ROLL NO : 21EG104A45 PAGE NO :
else:
GPIO.output(18,GPIO.LOW) // Output is low //
time.sleep(2) // Output is low for 2 seconds //

Result

LED glows when switch is


connected

LED glows when LDR is


covered

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT


NAME: K.SAI PRARDHANA DATE : 07-12-23
ROLL NO : 21EG104A45 PAGE NO :

INTERFACING DIAGRAM

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT ECE DEPARTMENT


LAB
NAME: K.SAI PRARDHANA DATE : 07-12-23
ROLL NO : 21EG104A45 PAGE NO :

LED if off when LDR is


uncoverd

LED glows when sender and receiver emitters of IR are uncovered

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT ECE DEPARTMENT


LAB
NAME: K.SAI PRARDHANA DATE : 07-12-23
ROLL NO : 21EG104A45 PAGE NO :

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT ECE DEPARTMENT


LAB
NAME: K.SAI PRARDHANA DATE : 07-12-23
ROLL NO: 21EG104A45 PAGE NO :

LED is off when sender and receiver emitters of IR are covered

Conclusion:
We have performed the experiment to interface Push button/Digital sensor (IR/LDR) with Arduino/Raspberry
Pi and write a program to turn ON LED when push button is pressed or at sensordetection.

ANURAG UNIVERSITY EMBEDDED SYSTEMS & IOT LAB ECE DEPARTMENT

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy