Skip to content

Instantly share code, notes, and snippets.

@EmperorPenguin18
Created May 10, 2021 23:12
Show Gist options
  • Save EmperorPenguin18/d4876e424e0b1030f40e1f4a5247229b to your computer and use it in GitHub Desktop.
Save EmperorPenguin18/d4876e424e0b1030f40e1f4a5247229b to your computer and use it in GitHub Desktop.
GPIO code for the RPI
import RPi.GPIO as GPIO
from time import sleep
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
BUTTON = 14
GPIO.setup(BUTTON, GPIO.IN)
LED = 18
GPIO.setup(LED, GPIO.OUT)
GPIO.setup(15, GPIO.OUT)
GPIO.output(15, True)
while True:
if GPIO.input(BUTTON):
print("on")
GPIO.output(LED, True)
else:
GPIO.output(LED, False)
sleep(0.1)
GPIO.cleanup()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment