Program to control DC motors using the BeagleBone Black
Now that you've connected your motor, here is a simple Python program to control one of the motors:
Let's look at the details. Here are the individual command statements:
#!/usr/bin/python
: As noted earlier, this command sets up the program to be executed without invoking Pythonimport Adafruit_BBIO.PWM as PWM
: This library is used to communicate with the GPIO pinsmotor1 = "P8_13"
: This sets the motor to PWM control P8_13—the 13th pin on the 8th connectorduty_stop = 9
: This sets the duty cycle of the PWM that is needed to stop the motorduty_forward = 12 # 12 max
: This sets the duty cycle of the PWM signal on the control pin that is needed to make the motor go in the forward direction at the maximum speedduty_back = 6 # 6 min
: This sets the duty cycle of the PWM signal on the control pin that is needed to make the motor go in the backward direction at the maximum speedPWM.start(motor1, duty_stop, 60.0)
: This sets the PWM signal...