kevinmcaleer / pca9685_for_pico

MIT License
19 stars 6 forks source link

OSError: [Errno 5] EIO #3

Open gokul6350 opened 1 year ago

gokul6350 commented 1 year ago

code

from machine import I2C, Pin
from pca9685 import PCA9685
from servo import Servos
import time

# Initialize I2C bus
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)

# Initialize PCA9685 board
pca = PCA9685(i2c)

# Initialize servos with a maximum angle of 270 degrees
servo = Servos(i2c, degrees=270)

# Set position of servo on channel 0 to 90 degrees
servo.position(index=0, degrees=90)

# Wait for 2 seconds
time.sleep(2)

# Set position of servo on channel 0 to 0 degrees
servo.position(index=0, degrees=0)

# Wait for 2 seconds
time.sleep(2)

# Set position of servo on channel 0 to 180 degrees
servo.position(index=0, degrees=180)

# Wait for 2 seconds
time.sleep(2)

# Set position of servo on channel 0 to 270 degrees
servo.position(index=0, degrees=270)

image

IncompleteIntegers commented 6 months ago

Not sure if this is the issue you had/are having, but the issue i ran into that gave me this error was the library using a preset slave device address, the preset address is 0x40 I believe, if you edit the pca9685 library file, you can change the address used to the address of the device you are controlling