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

View File

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