Objective: In this project you will be able to control the LED light by infrared proximity sensor. If there is an object in proximity of the sensor, then the LED will be ON otherwise it will be OFF.
Material Required:
Material Required:
- Raspberry Pi
- LED light
- 1k ohm resistance
- Jumper wires
- Bread board
- Infrared Proximity Sensor
Circuit Diagram:
Program:
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO_IN=6
GPIO.setmode(GPIO.BOARD)
GPIO.setup(GPIO_IN,GPIO.IN)
while True:
status=GPIO.input(GPIO_IN)
if status == 1:
GPIO.output(5,1)
time.sleep(2)
else:
GPIO.output(5,0)
time.sleep(2)