Created
May 10, 2021 23:12
-
-
Save EmperorPenguin18/d4876e424e0b1030f40e1f4a5247229b to your computer and use it in GitHub Desktop.
GPIO code for the RPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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