Simple LED Test using Python and Raspberry Pi

  

 Circuit:-


 Code:-

import RPi.GPIO as GPIO  
from time import sleep 
GPIO.setwarnings(False) 
GPIO.setmode(GPIO.BOARD) 
GPIO.setup(8, GPIO.OUT, initial=GPIO.LOW) 
GPIO.setup(10, GPIO.OUT, initial=GPIO.LOW) 
GPIO.setup(12, GPIO.OUT, initial=GPIO.LOW) 
GPIO.setup(3, GPIO.OUT, initial=GPIO.LOW) 
GPIO.setup(5, GPIO.OUT, initial=GPIO.LOW) 
while True: 
    GPIO.output(8, GPIO.HIGH) 
    sleep(1) 
    GPIO.output(8, GPIO.LOW) 
    GPIO.output(10, GPIO.HIGH)
    sleep(1)
    GPIO.output(10, GPIO.LOW)
    GPIO.output(12, GPIO.HIGH)
    sleep(1)
    GPIO.output(12, GPIO.LOW)
    GPIO.output(3, GPIO.HIGH)
    sleep(1)
    GPIO.output(3, GPIO.LOW)
    GPIO.output(5, GPIO.HIGH)
    sleep(1)
    GPIO.output(5, GPIO.LOW)


Note:- 

To excecute this file in python you to need to install the GPIO Libraries for Python to identify the RPi's GPIO Pins .Or else it may display Errors. This library can be installed by typing the following in the terminal.

 $ sudo apt-get install python-rpi.gpio python3-rpi.gpio


Demo:-


Comments

Post a Comment

Popular Posts