Does anyone have an example of I2C patch driving a servo and reading a button
What hardware do you use? Casual buttons and servos don’t use I2C, so the particular model is important.
Thanks for the quick reply. The hardware I am using is the PCA9685.
By the way the XOD software is fantastic.
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.
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
Thanks, that is great. Now how do I upload the wrapper.
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.
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.
Do you know the i2c Address or the control board you are using? Default is “0x40”
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.
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
No problem check out the count block it may be useful for driving the servos.
Is it possible to change the I2C address of the PCA9585 device node to run two or more of these boards? I need to run two remote clusters of servos.
You can use a “CLK” selector with a CD4066 and you can share the same address
but in the case of the PCA9685 (0x40-0x7F) if you can change it see the data sheet
# TECHNICAL DETAILS- ](https://www.adafruit.com/#technical-details)*Specifications:** * Dimensions (no headers or terminal block) 2.5" x 1" x 0.1" (62.5mm x 25.4mm x 3mm) * Weight (no headers or terminal block): 5.5grams * Weight (with 3x4 headers & terminal block): 9grams * This board/chip uses I2C 7-bit address between 0x40-0x7F, selectable with jumpers
Sorry I put the question wrong…
My question is how the address of the node object i2-servo-pwm-device can be set, so that i can use two boards in the same sketch. The address of the board itself is set by jumpers.
Well it is not implemented in the library, you should modify it, add a pin
ADDR and modify this line
Type pwm = new (state->mem) Adafruit_PWMServoDriver(); //to Type pwm = new (state->mem) Adafruit_PWMServoDriver((int8_t)getValue<input_ADDR>(ctx));
Don’t get it to run. Tried to add ADDR as number or byte,
changed the constructor to
Type pwm = new (state->mem) Adafruit_PWMServoDriver(0x41);
Anything but an empty pair brackets will not work and make the arduino’s LED flash.
According to adafruit’s tutorial the constructor should be
Adafruit_PWMServoDriver pwm2 = Adafruit_PWMServoDriver(0x41);