Skip to content

Instantly share code, notes, and snippets.

@samister2k
Last active March 2, 2017 15:19
Show Gist options
  • Save samister2k/7de7585f042ab0e2c411f49d177d1ae7 to your computer and use it in GitHub Desktop.
Save samister2k/7de7585f042ab0e2c411f49d177d1ae7 to your computer and use it in GitHub Desktop.
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(17, GPIO.OUT)
GPIO.setup(27, GPIO.OUT)
GPIO.setup(11, GPIO.IN)
if i==1:
GPIO.output(27, GPIO.LOW)
GPIO.output(18, GPIO.LOW)
GPIO.output(16, GPIO.LOW)
GPIO.output(13, GPIO.LOW)
GPIO.output(11, GPIO.LOW)
control=input("Press W to move Forward or D to turn Right or A to turn Left and S to move Backwards!")
if control=="W":
GPIO.output(17, GPIO.HIGH)
GPIO.output(24, GPIO.HIGH)
sleep(10)
GPIO.output(17, GPIO.LOW)
GPIO.output(24, GPIO.LOW)
elif control=="A":
GPIO.output(17, GPIO.HIGH)
sleep(5)
GPIO.output(17, GPIO.LOW)
elif control=="D":
GPIO.output(24, GPIO.HIGH)
sleep(5)
GPIO.output(24, GPIO.LOW)
-
elif control=="S":
GPIO.output(27, GPIO.HIGH)
GPIO.output(23, GPIO.HIGH)
sleep(10)
GPIO.output(27, GPIO.LOW)
GPIO.output(23, GPIO.LOW)
else:
print("THIS IS NOT A CONTROL")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment