I was just wondering how to run the motor controller at a constant level for a duration of time.
I'm coding in python using RPi.GPIO, I'm coding in python.
Any help would be great
You're in luck, Ben has added soft PWM to RPi.GPIO. That should make things a LOT easier.dawson345 wrote:I'm not sure how to do this still, I am not familiar with PWM I just want to be able to have a process that runs the motor at a constant level. Would anyone be able to help?
Well yes it does. You've chosen RPi.GPIO and that's the only way to get speed control in RPi.GPIOdawson345 wrote:Doe's this help me with the gertboard motor controller?
If you only want on off control just wire two ports to motor A and motor B.dawson345 wrote:I'm approaching my deadline now, if you could supply the lines of code to have the motor run at a constant level then I would really appreciate it
Code: Select all
#!/usr/bin/env python2.7 import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BCM) ports = [18,17] # define which ports to be pulsed (using a list) for port_num in ports: # set the ports up for output GPIO.setup(port_num, GPIO.OUT) # set up GPIO output channel print ("setting up GPIO port:", port_num) GPIO.output(port_num, False) # set both ports to OFF wait_time = 5 # define your wait time in seconds GPIO.output(17, True) # switch port 17 on time.sleep(wait_time) #wait for a period of time GPIO.output(17, False) # switch port 17 off GPIO.cleanup() # reset all ports used by this program on finishing