Skip to content

Instantly share code, notes, and snippets.

@MrDMurray
Last active March 2, 2017 09:16
Show Gist options
  • Save MrDMurray/6bb7b01810f748af8b86c9f16381ce55 to your computer and use it in GitHub Desktop.
Save MrDMurray/6bb7b01810f748af8b86c9f16381ce55 to your computer and use it in GitHub Desktop.
Roverdover STJLOL
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
@dobrienSTJ
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment