Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:adafruit/Adafruit-PWM-Servo-Drive…

…r-Library
  • Loading branch information...
commit 9760448377dcef00e34fc8bb4dd37e08ec7c68fb 2 parents 811e835 + 3606610
@ladyada ladyada authored
Showing with 8 additions and 30 deletions.
  1. +8 −5 Adafruit_PWMServoDriver.cpp
  2. +0 −25 examples/pwmtest/pwmtest.pde
View
13 Adafruit_PWMServoDriver.cpp
@@ -50,13 +50,14 @@ void Adafruit_PWMServoDriver::setPWMFreq(float freq) {
write8(PCA9685_PRESCALE, prescale); // set the prescaler
write8(PCA9685_MODE1, oldmode);
delay(5);
- write8(PCA9685_MODE1, oldmode | 0x80);
+ //write8(PCA9685_MODE1, oldmode | 0x80);
+ write8(PCA9685_MODE1, oldmode | 0xa1); // This sets the MODE1 register to turn on auto increment.
+ // This is why the beginTransmission below was not working.
// Serial.print("Mode now 0x"); Serial.println(read8(PCA9685_MODE1), HEX);
}
void Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on, uint16_t off) {
- /*
- // hmm doesnt work, whyso?
+ // hmm doesnt work, whyso? ( Not in AI mode. See line 54 above. ( Works now!! :D )
Wire.beginTransmission(_i2caddr);
Wire.write(LED0_ON_L+4*num);
Wire.write(on);
@@ -64,11 +65,13 @@ void Adafruit_PWMServoDriver::setPWM(uint8_t num, uint16_t on, uint16_t off) {
Wire.write(off);
Wire.write(off>>8);
Wire.endTransmission();
- */
+
+/*
write8(LED0_ON_L+4*num, on);
write8(LED0_ON_H+4*num, on >> 8);
write8(LED0_OFF_L+4*num, off);
- write8(LED0_OFF_H+4*num, off >> 8);
+ write8(LED0_OFF_H+4*num, off >> 8);
+*/
}
uint8_t Adafruit_PWMServoDriver::read8(uint8_t addr) {
View
25 examples/pwmtest/pwmtest.pde
@@ -50,28 +50,3 @@ void loop() {
}
}
}
-it_PWMServoDriver();
-// you can also call it with a different address you want
-//Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x41);
-
-void setup() {
- Serial.begin(9600);
- Serial.println("16 channel PWM test!");
-
- // if you want to really speed stuff up, you can go into 'fast 400khz I2C' mode
- // some i2c devices dont like this so much so if you're sharing the bus, watch
- // out for this!
-
- // save I2C bitrate
- uint8_t twbrbackup = TWBR;
- TWBR = 12; // upgrade to 400KHz!
-
- pwm.begin();
- pwm.setPWMFreq(1600); // This is the maximum PWM frequency
-}
-
-void loop() {
- // Drive each PWM in a 'wave'
- for (uint16_t i=0; i<4096; i += 8) {
- for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
- pwm.setPWM(pwmnum, 0, (i + (
Please sign in to comment.
Something went wrong with that request. Please try again.