LED CONTROL USING KEYBOARD USING FUNCTION CALL




PROGRAM


def initpi():
    gpio.setmode(gpio.BOARD)        #sets as the pin number in board
    gpio.setwarnings(False)         #disable warnings

def setuppins():
    gpio.setup(40,gpio.OUT) #set 40 pin as output
    gpio.setup(38,gpio.IN)

    gpio.output(40,0)
import RPi.GPIO as gpio #adds main header file
import time #adds timer header file
initpi()
setuppins()
while True: #starts infinite loop
    x=raw_input('led control word/n  ')
    if(x=='on'):
gpio.output(40,1) #writes a digital value to it
print 'led is on '
    elif(x=='off'):
print('led is off ')
gpio.output(40,0) #writes a digital value to it