Merge pull request #120 from bennuttall/patch-2

This commit is contained in:
RM 2016-10-17 15:49:30 +01:00 committed by GitHub
commit 4bc1a5121a
1 changed files with 14 additions and 24 deletions

View File

@ -43,30 +43,20 @@ pin:
###A quick and easy way to start driving motors on your Raspberry Pi
```python
##Simple motor script for the RTK-000-001
import RPi.GPIO as GPIO
import time
#Set to broadcom pin numbers
GPIO.setmode(GPIO.BCM)
from gpiozero import RyanteckRobot
from time import sleep
#Motor 1 = Pins 17 and 18
#Motor 2 = Pins 22 and 23
GPIO.setup(17, GPIO.OUT)
GPIO.setup(18, GPIO.OUT)
robot = RyanteckRobot()
#Now loop forever turning one direction for 5 seconds, then the other
while (True):
#Sleep 1 second then turn 17 on
GPIO.output(18, 0)
time.sleep(1)
GPIO.output(17, 1);
time.sleep(5);
#And now the other way round
GPIO.output(17, 0)
time.sleep(1);
GPIO.output(18, 1);
time.sleep(5);
#And loop back around
#And final cleanup
GPIO.cleanup()
while True:
robot.forward()
sleep(5)
robot.left()
sleep(1)
robot.backward()
sleep(5)
robot.right()
sleep(1)
robot.stop()
sleep(1)
```