Last active
March 2, 2017 09:16
-
-
Save MrDMurray/6bb7b01810f748af8b86c9f16381ce55 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 #lets you use GPIO | |
from time import sleep #lets you pause the program | |
GPIO.setmode(GPIO.BOARD) #chooses BOARD instead of BCM | |
GPIO.setup(11, GPIO.OUT) #sets up the motors | |
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
Other Code to use: https://gist.github.com/dobrienSTJ/0e93a7983e00ff0d2bb28f21851a0394