Skip to content

Instantly share code, notes, and snippets.

@daniel-obrien
Last active April 28, 2017 21:31
Show Gist options
  • Save daniel-obrien/7bddd435d284d11e925316cba9408916 to your computer and use it in GitHub Desktop.
Save daniel-obrien/7bddd435d284d11e925316cba9408916 to your computer and use it in GitHub Desktop.
Original Rover
import RPi.GPIO as GPIO #GPIO Libraries
from time import sleep #Sleep Functions
import readchar
GPIO.setmode(GPIO.BCM) #Setting Up
GPIO.setup(23, GPIO.OUT)#Right Motor Forwards
GPIO.setup(24, GPIO.OUT)# Backwards
GPIO.setup(17, GPIO.OUT)#Left Motor Backwards
GPIO.setup(27, GPIO.OUT)# Forwards
print("Welcome to the Awesome Robot!!!")
sleep(2)
while True:
key=readchar.readkey()
if key=="1":
GPIO.output(17, GPIO.HIGH)
GPIO.output(24, GPIO.HIGH)
sleep(1)
GPIO.output(17, GPIO.LOW)
GPIO.output(24, GPIO.LOW)
elif key=="2":
GPIO.output(17, GPIO.HIGH)
sleep(1)
GPIO.output(17, GPIO.LOW)
elif key=="3":
GPIO.output(24, GPIO.HIGH)
sleep(1)
GPIO.output(24, GPIO.LOW)
elif key=="4":
GPIO.output(27, GPIO.HIGH)
GPIO.output(23, GPIO.HIGH)
sleep(1)
GPIO.output(27, GPIO.LOW)
GPIO.output(23, GPIO.LOW)
elif key=="z":
GPIO.cleanup()
sleep(1)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment