IO: Add a dispose method to PCA9685 example, document pulse widths

Developed together with @OlivierLD
This commit is contained in:
gohai
2018-07-12 13:27:30 -07:00
parent cc46c5e680
commit cbdfb06c99
@@ -7,8 +7,14 @@ void setup() {
size(400, 300);
//printArray(I2C.list());
servos = new PCA9685("i2c-1", 0x40);
servos.attach(0);
servos.attach(1);
// different servo motors will vary in the pulse width they expect
// the lines below set the pulse width for 0 degrees to 544 microseconds (μs)
// and the pulse width for 180 degrees to 2400 microseconds
// these values match the defaults of the Servo library on Arduino
// but you might need to modify this for your particular servo still
servos.attach(0, 544, 2400);
servos.attach(1, 544, 2400);
}
void draw() {
@@ -28,3 +34,8 @@ void draw() {
y = map(angle, 0, 180, 0, height);
line(width/2, y, width, y);
}
void dispose() {
servos.detach(0);
servos.detach(1);
}