Project : LED Blink using Raspberry Pi | Python Programming
YouTube URLs
Project : LED Blink using Raspberry Pi
VIDEO
Program: Project : LED Blink using Raspberry Pi | Python Programming
#!/usr/bin/env python
import RPi.GPIO as GPIO
import time
RedledPin = 11
BlueledPin = 12
GreenledPin = 13
YellowledPin = 16
def setup():
GPIO.setmode(GPIO.BOARD)
GPIO.setup(RedledPin, GPIO.OUT)
GPIO.output(RedledPin, GPIO.LOW)
GPIO.setup(BlueledPin, GPIO.OUT)
GPIO.output(BlueledPin, GPIO.LOW)
GPIO.setup(GreenledPin, GPIO.OUT)
GPIO.output(GreenledPin, GPIO.LOW)
GPIO.setup(YellowledPin, GPIO.OUT)
GPIO.output(YellowledPin, GPIO.LOW)
def lightsOn():
GPIO.output(RedledPin, GPIO.HIGH)
GPIO.output(BlueledPin, GPIO.HIGH)
GPIO.output(GreenledPin, GPIO.HIGH)
GPIO.output(YellowledPin, GPIO.HIGH)
def stop():
GPIO.output(RedledPin, GPIO.LOW)
GPIO.output(BlueledPin, GPIO.LOW)
GPIO.output(GreenledPin, GPIO.LOW)
GPIO.output(YellowledPin, GPIO.LOW)
GPIO.cleanup()
if (__name__ == '__main__'): # Main Program Start From Here
setup()
try:
lightsOn()
except KeyboardInterrupt: # When 'Ctrl+C' is pressed or stopped program
stop()