User manual

27
2.4 Switching the LED on or off
Connect a LED via a 220-ohm series resistor (red-red-brown) to the GPIO port 25 (Pin 22), and not anymore
directly to the + 3.3 V connector, and connect the negative terminal of the LED via the ground rail on the
breadboard to the ground wire of the Raspberry Pi (Pin 6), as shown in the next image.
Components required:
1x breadboard
1x LED red
1x 220-ohm series resistor
2x connecting wire
The next program led.py turns the LED on for 5 seconds and then off:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(25, GPIO.OUT)
GPIO.output(25, 1)
time.sleep(5)
GPIO.output(25, 0)
GPIO.cleanup()