Code to control onboard LEDs

The Pi comes with two LEDs on its board, for power and activity. It’s possible to control them via Python.

Note: not for Pi3.

To have the onboard LEDs blink, you can use code similar to this one:
print ("Program Start")
import RPi.GPIO as GPIO
import time

channels = [35, 47]
GPIO.setup(channels, GPIO.OUT)
for i in range(5):
print (“Turning off LED’s”)
GPIO.output(channels, GPIO.LOW)
print (“Turning on LED’s”)
GPIO.output(channels, GPIO.HIGH)


print (“Program End”)

Take note that the LEDs are still linked to their regular trigger. So if something else happens on the Pi, and the LED needs to display it (mainly the green one), then the blinking done here won’t be perfect.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s