Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import time
- buttonPin = 11
- ledPin = 12
- GPIO.setmode(GPIO.BOARD)
- GPIO.setup(buttonPin, GPIO.IN)
- GPIO.setup(ledPin, GPIO.OUT)
- GPIO.output(ledPin, True)
- previous_state = 0
- led_state = False
- while True:
- input = GPIO.input(buttonPin)
- if previous_state == 0 and input == 1:
- led_state = not led_state
- GPIO.output(ledPin, led_state)
- previous_state = input
- time.sleep(0.1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement