TIMER OR LED BLINKING

Photo of author

By Jackson Taylor


BLINKING ONCE
import RPi.GPIO as gpio #adds main header file
import time             #adds timer header file
gpio.setmode(gpio.BOARD)          #sets as the pin number in board
gpio.setwarnings(False)          #disable warnings
gpio.setup(40,gpio.OUT) #set 40 pin as output
gpio.output(40,1)              #writes a digital value to it
time.sleep(1)           #sleeps one seconds
gpio.output(40,0)            #writes a digital value to it
BLINKING INFINITELY 

import RPi.GPIO as gpio #adds main header file
import time #adds timer header file
gpio.setmode(gpio.BOARD) #sets as the pin number in board
gpio.setwarnings(False) #disable warnings
gpio.setup(40,gpio.OUT) #set 40 pin as output
while True: #starts infinite loop
    gpio.output(40,1) #writes a digital value to it
    time.sleep(1) #sleeps one seconds
    gpio.output(40,0) #writes a digital value to it
    time.sleep(1) #sleeps one seconds
BLINKING FASTER

import RPi.GPIO as gpio #adds main header file
import time              #adds timer header file
gpio.setmode(gpio.BOARD) #sets as the pin number in board
gpio.setwarnings(False) #disable warnings
gpio.setup(40,gpio.OUT) #set 40 pin as output
while True: #starts infinite loop
    gpio.output(40,1) #writes a digital value to it
    time.sleep(.1) #sleeps one seconds
    gpio.output(40,0) #writes a digital value to it
    time.sleep(.1) #sleeps one seconds
LED CHASER USING RASPBERRY PI


import RPi.GPIO as gpio #adds main header file
import time #adds timer header file
gpio.setmode(gpio.BOARD) #sets as the pin number in board
gpio.setwarnings(False) #disable warnings
gpio.setup(40,gpio.OUT) #set 40 pin as output
gpio.setup(38,gpio.OUT)
gpio.setup(36,gpio.OUT)         #set 40 pin as output
while True: #starts infinite loop
    gpio.output(40,1) #writes a digital value to it
    gpio.output(38,0)
    gpio.output(36,0)           #writes a digital value to it
    time.sleep(1) #sleeps one seconds
    gpio.output(40,0) #writes a digital value to it
    gpio.output(38,1)
    gpio.output(36,0)           #writes a digital value to it
    time.sleep(1) #sleeps one seconds
    gpio.output(40,0)           #writes a digital value to it
    gpio.output(38,0)
    gpio.output(36,1)           #writes a digital value to it
    time.sleep(1)               #sleeps one seconds