LED-Interfacing-Raspberry Pi (2)
LED-Interfacing-Raspberry Pi (2)
GPIO pin
Aim: Programming Raspberry Pi to Control LED attached to the GPIO pin
Objectives:
a. To understand basics of the GPIO Pins of Raspberry Pi.
b. To write a python program to control LEDs attached to the GPIO pins.
Raspberry Pi Pin-out and circuit diagram (GPIO) :
1
Procedure:
Note: The Raspbian operating system comes with a Python already installed in it.
1. Setting up the circuit:
a. Turn OFF the Raspberry Pi while building/connecting on the circuit board/
components according to the diagram.
b. Then turn the Raspberry Pi and check whether the Raspbian OS is loaded
properly or not. If not then check the circuit connection again.
2. Python Programming:
Python via IDLE
a. Start Raspberry Pi in desktop mode, open the applications menu in the top left of
your screen, and navigate to Programming > Python 3 (IDLE). This will open the
Python-shell.
Program:
#LED interfacing with Raspberry Pi
LED=23
GPIO.setup(LED,GPIO.OUT) # setup pin 23 as output
time.sleep(1) #time delay for 1sec
while True:
GPIO.output(LED,True) # set LED1 high
time.sleep(1) # time delay for1 sec
GPIO.output(LED,False) # set LED1 low
time.sleep(1) # time delay for1 sec
2
Steps to execute Program