-
-
Save dobrienSTJ/261161007e287245a36e3bd42c3b5ee9 to your computer and use it in GitHub Desktop.
Roverdover STJLOL
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.setmode(GPIO.BOARD) | |
GPIO.setup(11, GPIO.OUT) | |
GPIO.setup(13, GPIO.OUT) | |
GPIO.setup(16, GPIO.OUT) | |
GPIO.setup(18, GPIO.OUT) | |
while True: | |
key=input("Type to control. WASD is what we'll use.") | |
if key == "w": #forward | |
GPIO.output(11, GPIO.HIGH) | |
sleep(1) | |
GPIO.output(11, GPIO.LOW) | |
elif key == "s": #reverse | |
GPIO.output(13, GPIO.HIGH) | |
sleep(1) | |
GPIO.output(13, GPIO.LOW) | |
elif key == "a": #steers left | |
GPIO.output(16, GPIO.HIGH) | |
sleep(1) | |
GPIO.output(16, GPIO.LOW) | |
elif key == "d": #steers right | |
GPIO.output(18, GPIO.HIGH) | |
sleep(1) | |
GPIO.output(18, GPIO.LOW) | |
elif key == "z": #quits the program | |
GPIO.cleanup() | |
print("Motors on safe, exiting.") | |
sleep(1) | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment