Saturday, 29 December 2018

Project : Control LED Using Raspberry Pi 3 B+ |

Project : Control LED Using Raspberry Pi 3 B+ | Python Program

YouTube URLs:

Project : Control LED Using Raspberry Pi 3 B+




program: Control LED Using Raspberry Pi 3 B+

#!/usr/bin/env python

import RPi.GPIO as GPIO
import time

RedLEDPin = 11 

def setup():
GPIO.setmode(GPIO.BOARD)     
GPIO.setup(RedLEDPin, GPIO.OUT) 
GPIO.output(RedLEDPin, GPIO.LOW)

def lightson():
while True:
GPIO.output(RedLEDPin, GPIO.HIGH)
time.sleep(2)
GPIO.output(RedLEDPin, GPIO.LOW)
time.sleep(2)
def stop():
GPIO.output(RedLEDPin, GPIO.LOW)   
GPIO.cleanup()                   

if (__name__ == '__main__'):   
setup()
try:
#
lightson()
except KeyboardInterrupt:
stop()



No comments:

Post a Comment