This is a quick blog post which includes attaching two servos to the Beaglebone Wireless and using a 2-axis analog thumb joystick to test out the movement and help calibrate the angle I need to move as part of the final servo mechanism. Basically each axis on the thumb joystick maps to movement of one of the servos, which will be placed below top plate of the maze. And, as part of the final setup the in addition or instead of the joystick, the BBC Microbit will be used to control the servo mechanism.
Here are the connections made to Beaglebone Wireless
- Servo1 - P8_13
 - Servo2 - P8_19 - both these are PWM pins on the Beaglebone
 
And the pins of the Thumb Joystick
- VERT - P9_38
 - HORZ - P9_36 - both these are analog pins on the Beaglebone
 
To power the servo's I am using 5V mini breadboard power supplies.
And, here is the python program that I used on the Beaglebone to run the test -
#07142018 testing Beaglebone Wireless with servo, and thumb joystick
import Adafruit_BBIO.PWM as PWM
import Adafruit_BBIO.ADC as ADC
import time
servo_pinL = "P8_13"
servo_pinS = "P8_19"
sensor_pinHOR = 'P9_36'
sensor_pinVER = 'P9_38'
ADC.setup()
duty_min = 3
duty_max = 11
duty_span = duty_max - duty_min
PWM.start(servo_pinL, (100-duty_min), 50.0)
PWM.start(servo_pinS, (100-duty_min), 50.0)
while True:
        readingHOR = ADC.read(sensor_pinHOR)
        readingVER = ADC.read(sensor_pinVER)
        print("ADC HOR: "+ str(readingHOR) + " ADC VER: "+ str(readingVER))
        angleHOR = readingHOR * 180
        angleVER = readingVER * 180
        if angleHOR > 180:
                PWM.stop(servo_pinL)
                PWM.cleanup()
                break
        if angleVER > 180:
                PWM.stop(servo_pinS)
                PWM.cleanup()
                break
        angleflHOR = float(angleHOR)
        angleflVER = float(angleVER)
        dutyHOR = (angleflHOR / 180) * duty_span + duty_min
        dutyVER = (angleflVER / 180) * duty_span + duty_min
        print("duty servo HOR: "+ str(dutyHOR) + " duty servo VER: " + str(dutyVER))
        PWM.set_duty_cycle(servo_pinL, dutyHOR)
        PWM.set_duty_cycle(servo_pinS, dutyVER)
        time.sleep(1)
Here is a screenshot of the output of the program above running on the Beaglebone Wirless.
Here is a quick video demo
			    
