Skip to content

Commit cd11522

Browse files
author
Marcus Lindblom Sonestedt
authored
Fix typo and wire/9685 setup code
1 parent 5bb46c1 commit cd11522

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ServoPID/servopid.ino

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#define USE_PCA9684 1 // set 0 to use Arduino to directly control servos
1+
#define USE_PCA9685 1 // set 0 to use Arduino to directly control servos
22

33
#ifndef ARDUINO
44
#include "ArduinoMock.h"
5-
#if USE_PCA9684 == 1
5+
#if USE_PCA9685 == 1
66
#include "PCA9685Mock.h"
77
#endif
88
#else
9-
#if USE_PCA9684 == 1
9+
#if USE_PCA9685 == 1
1010
#include <Wire.h>
1111
#include <PCA9684.h>
1212
#else
@@ -189,13 +189,14 @@ bool enabled = true;
189189

190190
void setup()
191191
{
192-
#if USE_PCA9684
193-
gPwmController.init();
194-
192+
#if USE_PCA9685
195193
Wire.begin(); // Wire must be started first
196194
Wire.setClock(400000); // Supported baud rates are 100kHz, 400kHz, and 1000kHz
197195

198-
gPwmController.resetDevices();
196+
pwmController.resetDevices(); // Software resets all PCA9685 devices on Wire line
197+
198+
pwmController.init(B010101); // Address pins A5-A0 set to B010101
199+
pwmController.setPWMFrequency(500); // Default is 200Hz, supports 24Hz to 1526Hz
199200
#endif
200201

201202
// assume servos on pin 3,5,6,9 and potentiometers on analog in 0,1,2,3

0 commit comments

Comments
 (0)