I2C drive a servo


#1

Does anyone have an example of I2C patch driving a servo and reading a button


#2

Hello!

What hardware do you use? Casual buttons and servos don’t use I2C, so the particular model is important.


#3

Thanks for the quick reply. The hardware I am using is the PCA9685.

By the way the XOD software is fantastic.

Alan


#4

I see. That would be an interesting challenge. Unfortunately, I have no hardware based on PCA9585, so cannot provide any example. However, if someone will be close to success, feel free to ask for help.


#5

Hi alanburdick
Just uploaded a simple wrapper for the Adafruit 16-channel PWM Servo driver
I don’t have that servo board on me at the moment (i will grab one soon) if you could test and let me know if anything needs changing that would be great :smile:

bradzilla84/i2c-pwm-servo-16ch


Does anyone know if you can use a PWM servo shield with XOD?
#6

Thanks, that is great. Now how do I upload the wrapper.


#7

Just go File->Add Library on XOD and paste in “bradzilla84/i2c-pwm-servo-16ch” (Without the quotes) when the entry comes up just hit Enter and it will install it automatically.
The first time you try to upload it if you don’t already have the adafruit library it will ask if you want it to download and install it for you.


#8

I am such a newbie. I cannot figure out how to assemble these nodes into a working program for 6 or more servo outputs.
Again thanQ for your replies.
Alan


#9

Do you know the i2c Address or the control board you are using? Default is “0x40”


#10

Hi Alan
The block at the top of the example setups the link to the control board and the update frequency(Device Block).

The next block is for the servo itself each servo will be attached to a pin number on the control board just add one block for each servo you want and set its pin. Then connect the Device Block to each of the control blocks.

Then Connect the angle you want to the PWM Pin (i dont have one of these to test you may have to multiply the angle by 180 first to get the correct angle). I can fix in code later if necessary.


#11

I was over thinking it. i got the servos working. Now I am working on how to use buttons to control the various servos. I have never experienced such good feedback and help.
Thank you again you are very helpful
Alan


#12

No problem :blush: check out the count block it may be useful for driving the servos.