| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 4471608 commit 564ce4c
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,8 +7,14 @@ void setup() { | |||
| 7 | 7 | size(400, 300); | |
| 8 | 8 | //printArray(I2C.list()); | |
| 9 | 9 | servos = new PCA9685("i2c-1", 0x40); | |
| 10 | - servos.attach(0); | ||
| 11 | - servos.attach(1); | ||
| 10 | + | ||
| 11 | + // different servo motors will vary in the pulse width they expect | ||
| 12 | + // the lines below set the pulse width for 0 degrees to 544 microseconds (μs) | ||
| 13 | + // and the pulse width for 180 degrees to 2400 microseconds | ||
| 14 | + // these values match the defaults of the Servo library on Arduino | ||
| 15 | + // but you might need to modify this for your particular servo still | ||
| 16 | + servos.attach(0, 544, 2400); | ||
| 17 | + servos.attach(1, 544, 2400); | ||
| 12 | 18 | } | |
| 13 | 19 | ||
| 14 | 20 | void draw() { | |
@@ -28,3 +34,8 @@ void draw() { | |||
| 28 | 34 | y = map(angle, 0, 180, 0, height); | |
| 29 | 35 | line(width/2, y, width, y); | |
| 30 | 36 | } | |
| 37 | + | ||
| 38 | + void dispose() { | ||
| 39 | + servos.detach(0); | ||
| 40 | + servos.detach(1); | ||
| 41 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments