Skip to content

Instantly share code, notes, and snippets.

@dobrienSTJ
Forked from MrDMurray/roverdover.py
Created February 28, 2017 10:35
Show Gist options
  • Save dobrienSTJ/261161007e287245a36e3bd42c3b5ee9 to your computer and use it in GitHub Desktop.
Save dobrienSTJ/261161007e287245a36e3bd42c3b5ee9 to your computer and use it in GitHub Desktop.
Roverdover STJLOL
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