Adafruit 16-Channel 12-bit PWM/Servo Shield - I2C interface #1009
Replies: 6 comments
-
Posted at 2018-12-10 by @gfwilliams Hey, no problem! Yes, it is possible to use it - I believe just connecting, GND, power, SDA and SCL would be enough. However it's not entirely simple as we don't currently have a library for the PCA9685 chip - so you'd have to send the I2C commands needed to control it using Adafruit's code (https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library/blob/master/Adafruit_PWMServoDriver.cpp) as a base. I can definitely help you to do that if you want (and I'm happy to make a library so that it is really easy to use code with it), but I don't have a PCA9685-based board here so it might require a little bit of trial and error! I should add that if you just want to control servos, you can just connect them straight to the Espruino WiFi - you should be able to control quite a few of them at a time without issues. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-12-10 by Matteo Thank you for your kind reply, Gordon! :-) I am a frontend web developer (that's why I love Espruino), but as I said I am a newbie in electronics, hence I am not sure to be able to do what you are suggesting. I know I can control servos directly from Espruino (already successfully done!), but I am trying to learn something new reusing hardware from previous experiments with different microcontrollers. By the way, I would like to try to "translate" Adafruit c++ code to a module for Espruino, avoiding to bother you with my personal experiments! ;-) I definitely wanna deepen this stuff. Maybe the libs/README.md file (https://github.com/espruino/Espruino/blob/master/libs/README.md) could be a starting point. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-12-10 by @gfwilliams Great! In this case you should be able to do what you want in normal JavaScript, so actually delving into Espruino itself isn't needed - maybe that link should mention it? What you really need is: http://www.espruino.com/Writing+Modules The modules that use I2c (http://www.espruino.com/I2C#using-i2c) are a good start - and the code for them is usually here: https://github.com/espruino/EspruinoDocs/tree/master/devices To get you started, just copy/paste this into the Web IDE:
So you need to implement setPWMFreq, but the general outline of what you need should be there for the other stuff. I did Other thing to note is that servos don't run at 1000Hz (the default) so you have to use Adafruit's example: https://github.com/adafruit/Adafruit-PWM-Servo-Driver-Library/blob/master/examples/servo/servo.ino Part of me thinks it's worth just setting it to 60Hz by default and adding a 'setServo' function as well though. Most people are going to use this board/chip for servos anyway :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-12-11 by Matteo Wow! A lot of stuff here! :-) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-12-11 by Wilberforce
Modules.addCached("pca9685_servo",function() |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-12-11 by @gfwilliams Thanks - just fixed! And I spotted some other issues too - I should have tested that! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-12-07 by Matteo
Hi!
Sorry for the question, I'm a kind of newbie...
I was wondering if it's possible to connect Espruino Wi-Fi to the Adafruit 16-Channel 12-bit PWM/Servo Shield (https://learn.adafruit.com/adafruit-16-channel-pwm-slash-servo-shield/overview).
And, if it is, how to program it?
Should I connect the SDA and SCL pins on the boards and use a code similar to this: https://www.espruino.com/arduino-motorshield?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions