gingemonster / PCA9685-Python-Microbit

Microbit Python Driver for PCA9685 16-Channel 12-bit PWM/Servo Driver - I2C interface
MIT License
23 stars 5 forks source link

microbit pca9685 #1

Open wpsliu123 opened 6 years ago

wpsliu123 commented 6 years ago

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)

redwoodturner commented 3 years ago

Getting error on lines 59 and 104 of the PCA9685.py

Koraze commented 3 years ago

@wpsliu123 try with slave address "0x7F"

redwoodturner commented 3 years ago

Thanks, but I can’t remember what the problem was now. Must have solved it! Regards