- LED
- Resistor (330 Ω (ohms))
- 2 - Female to male connectors
- 2 - Male to male connectors
Note that Board numbering is used, NOT Broadcom numbering
Refer to this diagram to understand the pins we are using
Note that Board numbering is used NOT Broadcom numbering
Making use of the python RPi library and the GPIO methods, we can make a program that blinks an LED for a indefinate number of times or for a set number of times
# Makes an LED connected to GPIO Pin 11 to blink ON and OFF indefinately
# until the user suplies a keyboard interrupt (<CTRL> + <C>)
import RPi.GPIO as GPIO
from time import sleep
outPin = 11
GPIO.setmode(GPIO.BOARD)
GPIO.setup(outPin, GPIO.OUT)
# Makes the LED blink ON and OFF in 2s
def blinker():
sleep(1)
GPIO.output(outPin, 1)
sleep(1)
GPIO.output(outPin, 0)
try:
while (True):
blinker()
except KeyboardInterrupt:
GPIO.cleanup()
The link to the code is here