Adafruit_PWMServoDriver does not let me monitor serial Teensy 3.2

Status
Not open for further replies.

Kevin Coleman

New member
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: https://www.adafruit.com/product/815
Adafruit_PWMServoDriver library: https://github.com/adafruit/Adafruit-PWM-Servo-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);
}

}
}
 
Status
Not open for further replies.
Back
Top