Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Import the required module.
- import RPi.GPIO as GPIO
- # Set the mode of numbering the pins.
- GPIO.setmode(GPIO.BCM)
- #GPIO pin 10 is the output.
- GPIO.setup(13, GPIO.OUT)
- #GPIO pin 8 is the input.
- GPIO.setup(6, GPIO.IN)
- #Initialise GPIO13 to low (False) so that the LED is on.
- GPIO.output(13, False)
- while 1:
- if GPIO.input(6):
- GPIO.output( 13, True)
- else:
- GPIO.output( 13, False)
- #keep LED on till the button pressed again then it turns off?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement