RoboPi.RoboPiInit("/dev/ttyAMA0", 115200) while 1: # set both motors to go forward RoboPi.pinMode(MOTORA_IA, PWM) RoboPi.pinMode(MOTORA_IB, OUTPUT) RoboPi.pinMode(MOTORB_IA, PWM) RoboPi.pinMode(MOTORB_IB, OUTPUT) # slowly ramp up the sped for speed in xrange(0, 256, 2): RoboPi.analogWrite(MOTORA_IA, speed) RoboPi.analogWrite(MOTORB_IA, speed) time.sleep(0.1) # now ramp back town for speed in xrange(255, -1, -2): RoboPi.analogWrite(MOTORA_IA, speed) RoboPi.analogWrite(MOTORB_IA, speed) time.sleep(0.1) # set both motors to go reverse RoboPi.pinMode(MOTORA_IA, OUTPUT) RoboPi.pinMode(MOTORA_IB, PWM)
import setup from setup import RPL import RoboPiLib as RoboPi RoboPi.RoboPiInit(“/dev/ttyAMA0”,115200) RoboPi.pinMode(1,RoboPi.OUTPUT) RoboPi.digitalWrite(16,1) RoboPi.pinMode(17,RoboPi.PWM) RoboPi.analogWrite(17,127) print RoboPi.analogRead(0) #RPL.servoWrite(0,1000) #RPL.servoWrite(1,1000) #x = 1 #while x == 1: # RoboPi.analogRead(1) # AnalogRead = RoboPi.analogRead(1) # AnalogRead = int(AnalogRead) # print AnalogRead # Dist = (500 * AnalogRead)/1024 # print Dist #import RoboPiLib as RoboPi