Programming Raspberry Pi to Control LEDs Only attached to the GPIO pins
Programming Raspberry Pi to Control LEDs Only attached to the GPIO pins
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 (GPIO) :
Circuit Diagram:
1
Figure 1: Basic LED Common Anode Figure 2: Basic LED Common Cathode
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.
2
Program:
LED1=14
LED2=15