Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- ledPin = 38 # define ledPin
- buttonPin = 40 # define buttonPin
- def setup():
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(ledPin, GPIO.OUT)
- GPIO.setup(buttonPin, GPIO.IN, pull_up_down = GPIO.PUD_UP)
- def loop():
- while True:
- if GPIO.input(buttonPin)==GPIO.LOW:
- for x in range(5):
- GPIO.output(ledPin,GPIO.HIGH)
- time.sleep(0.3)
- GPIO.output(ledPin,GPIO.LOW)
- time.sleep(0.3)
- def destroy():
- GPIO.cleanup()
- if __name__ == '__main__':
- setup()
- try:
- loop()
- except KeyboardInterrupt:
- destroy()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement