Teensy 3.2 not populating serial monitor when using Adafruit_PWMServoDriver

To all,

I am using a Teensy 3.2 to control an Adafruit product #815 16 Channel 12 Bit PWM servo driver. The code below works fine, but when I try to use the serial monitor, nothing populates. If I rim out the two "Wire.set" lines and upload to an UNO, the serial monitor works fine. I believe this to be an issue with the Adafruit_PWMServoDriver library clashing with the 3.2 in some way. Any help or insight on this would be greatly appreciated as my final project will most definitely need to use a Teensy. Also, this is my first post to a Forum ever, so please help direct me if my post need better explanation. Thanks!

Adafruit 815: Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits
Adafruit_PWMServoDriver library: https://github.com/adafruit/Adafruit...Driver-Library
Teensy 3.2
Windows 10 with Arduino IDE 1.8.13

Code Below:

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

int analogPin = A0;

int val = 0;

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(0x40, Wire);

void setup() {

pwm.begin();
Serial.begin(9600);
Serial.println("16 channel PWM test!");

pwm.setOscillatorFrequency(25000000);
pwm.setPWMFreq(1000); // This is the maximum PWM frequency

Wire.setSDA(18);
Wire.setSCL(19);

Wire.setClock(100000);

}

void loop() {

int sensorValue = analogRead(A0);

Serial.print(sensorValue);
Serial.print(0x0a);

for (uint16_t i=0; i<4096; i += 1) { //replaced 8 with 1
for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {
pwm.setPWM(pwmnum, 0, (i + (4096/16)*pwmnum) % 4096 );

delay(100);
}

}
}

Are you saying that code fails on a Teensy and works on an Uno. I'm not clear whether you had to comment out Wire for both.

The serial monitor works on the UNO and fails on the Teensy. Serial monitor works on the teensy until I use the "Adafruit_PWMServoDriver" library.

I'll guess that whatever timer Adafruit is using to run the wire protocol timing is being used by the Teensy for serial, but you would need to dig into the library code to see.

You always have the Teensy forum as an option for direct support.

https://forum.pjrc.com/forums/3-Technical-Support-amp-Questions

Thanks all for the input. I was putting my "Serial.writeln" before the for loop. This loop was taking forever due to it's size. I have figured it out and have everything up and running. Thanks!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.