This is a library for our Adafruit 16-channel PWM & Servo driver Pick one up today in the adafruit shop! ------> http://www.adafruit.com/products/815 These displays use I2C to communicate, 2 pins are required to interface. Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! Written by Limor Fried/Ladyada for Adafruit Industries. BSD license, check license.txt for more information All text above must be included in any redistribution
Diff: Adafruit_PWMServoDriver.cpp
- Revision:
- 3:5e1fd11c4f94
- Parent:
- 2:237e7b9d17c8
- Child:
- 4:41a00db32ae7
--- a/Adafruit_PWMServoDriver.cpp Sat Dec 14 06:04:33 2013 +0000 +++ b/Adafruit_PWMServoDriver.cpp Sun Jan 05 22:26:12 2014 +0000 @@ -32,7 +32,10 @@ void Adafruit_PWMServoDriver::reset(void) { - write8(PCA9685_MODE1, 0x0); + + // leave the ALL CALL address enabled (we might use that!) + // if you don't want ALL CALL, write 00 to offset 00 + write8(PCA9685_MODE1, 0x1); } void Adafruit_PWMServoDriver::setPWMFreq(float freq) { @@ -76,8 +79,10 @@ uint8_t Adafruit_PWMServoDriver::read8(uint8_t addr) { char data; - _i2c->write(_i2caddr, &data, 1, true); - _i2c->read(_i2caddr, &data, 1); + if(_i2c->write(_i2caddr, (char *)&addr, 1, true)) + printf("no ack on write before read.\n"); + if(_i2c->read(_i2caddr, &data, 1)) + printf("no ack on read\n"); return (uint8_t)data; } @@ -85,6 +90,6 @@ char data[] = { addr, d }; if(_i2c->write(_i2caddr, data, 2)) { - //("No ACK on i2c write!"); + printf("No ACK on i2c write!"); } } \ No newline at end of file