mikronauts wrote:I've uploaded PDALib.py v0.90 to the Pi Droid Alpha product page
http://www.mikronauts.com/raspberry-pi/pi-droid-alpha/
After downloading, rename file as PDALib.py
Moderator: Steve
mikronauts wrote:I've uploaded PDALib.py v0.90 to the Pi Droid Alpha product page
http://www.mikronauts.com/raspberry-pi/pi-droid-alpha/
After downloading, rename file as PDALib.py
import PDALib
import time
PDALib.pinMode(6,PDALib.PWM) # init motor1 speed control pin
PDALib.pinMode(7,PDALib.PWM) # init motor2 speed control pin
PDALib.pinMode(12,PDALib.OUTPUT) #init motor1 dirA/Fwd enable
PDALib.pinMode(13,PDALib.OUTPUT) #init motor1 dirB/Bkwd enable
PDALib.pinMode(14,PDALib.OUTPUT) #init motor2 dirA/Fwd enable
PDALib.pinMode(15,PDALib.OUTPUT) #init motor2 dirB/Bkwd enable
# init all direction pins to off
PDALib.digitalWrite(12,0) #set to off/coast
PDALib.digitalWrite(13,0) #set to off/coast
PDALib.digitalWrite(14,0) #set to off/coast
PDALib.digitalWrite(15,0) #set to off/coast
# get ready to go forward
PDALib.digitalWrite(12,1) #set to forward
PDALib.digitalWrite(14,1) #set to forward
# setting speed will start us going (zero to fast in one command for this test)
PDALib.analogWrite(6,127) #set motor1 to half speed
PDALib.analogWrite(7,127) #set motor2 to half speed
time.sleep(10.0) # drive while asleep at the wheel for 10 seconds
# (bad idea but this is a test)
# two ways to stop - set speed to 0 or set direction to off/coast
PDALib.digitalWrite(12,0) #set to off/coast to stop
PDALib.digitalWrite(14,0) #set to off/coast to stop
# turn off the speed pin - not needed when dir pins are off, but good idea
PDALib.analogWrite(6,0) #set motor1 to zero speed
PDALib.analogWrite(7,0) #set motor2 to zero speed
Users browsing this forum: No registered users and 1 guest