PCA9685-Python-Microbit
PCA9685-Python-Microbit copied to clipboard
microbit pca9685
I use mu editor, when I connect PCA9685 to microbit with slave address "0x41". The microbit gives me that "no module pca9685".
from microbit import sleep, i2c
import PCA9685 import servo
Initialise the PCA9685 using the default address (0x40).
#PCA9685_ADDR = 0x41 #pwm = PCA9685.PCA9685(i2c) pwm = PCA9685.PCA9685(i2c)
Configure min and max servo pulse lengths (will need to adjust for different servos)
servo_min = 150 # Min pulse length out of 4096 servo_max = 600 # Max pulse length out of 4096:
Set frequency to 60hz, good for servos.
pwm.set_pwm_freq(60)
print('Moving servo on channel 0, press Ctrl-C to quit...')
Move servo on channel O between extremes.
pwm.set_pwm(4, 0, servo_min) sleep(1000) pwm.set_pwm(4, 0, servo_max) sleep(1000)
Use servo helper class to move channel 0 by degrees
s0 = servo.Servos(i2c) s0.position(0, 90) sleep(1000) s0.release(0)
Getting error on lines 59 and 104 of the PCA9685.py
@wpsliu123 try with slave address "0x7F"
Thanks, but I can’t remember what the problem was now. Must have solved it! Regards