Hi, I recently started working with the Teensy 4.1 microcontroller. Unfortunately, I have troubles with serial communication. It seems like the board is not able to send anything to the computer over the USB cable (or it doesn't recognize that a serial monitor is connected). I will provide detail of my code and things I tried below.
First of all, I am working with the Arduino IDE version 2.0.3 and installed the teensy boards though the boards manager of the IDE. The teensy loader is version 1.58.
When I upload the example blink sketch, everything seems to work fine. I select the teensy 4.1 serial port (see the screenshot below), verify the blink.ino (see code below) file and press the programming button on the Teensy. Afterwards the LED on the Teensy starts blinking as expected.
The problem occurs when I try to add any serial communication to the script. I do not see anything appearing in the serial monitor.
If I perform the exact same process but with a 'serial begin'- and 'serial print' -statement added, the program does not work. The code I upload is the following (commented "NEW" for the lines I added compared to the precious sketch):
After verifying this code and pressing the programming button, I open the serial monitor in the IDE. I do not see anything printed to the monitor and do not see the LED blinking on the Teensy. This probably has something to do with the [while(!Serial);] line I added, and the code hangs in this loop. I also tried to remove this line, and keep everything the same as the previous code above. After verifying and pressing the programming button, the LED on the Teensy does blink, but nothing shows on the serial monitor.
Additionally I also tried to open the monitor while selecting the arduino COM port (COM11 in the screenshot above), without luck. I also tried to select a different USB type like 'Serial+keyboard+mouse+joystick'. But this didn't solve the problem either.
The USB cable seems to be fine, because I'm able to upload the blink sketch without any problem (also when changing the delays, the LED blinks at that different rate).
Hopefully someone has an idea what causes this behavior, because I'm not sure what to try next...
Some additional info:
First of all, I am working with the Arduino IDE version 2.0.3 and installed the teensy boards though the boards manager of the IDE. The teensy loader is version 1.58.
When I upload the example blink sketch, everything seems to work fine. I select the teensy 4.1 serial port (see the screenshot below), verify the blink.ino (see code below) file and press the programming button on the Teensy. Afterwards the LED on the Teensy starts blinking as expected.
Code:
const int ledPin = 13;
// the setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output.
pinMode(ledPin, OUTPUT);
}
// the loop() methor runs over and over again,
// as long as the board has power
void loop() {
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}
The problem occurs when I try to add any serial communication to the script. I do not see anything appearing in the serial monitor.
If I perform the exact same process but with a 'serial begin'- and 'serial print' -statement added, the program does not work. The code I upload is the following (commented "NEW" for the lines I added compared to the precious sketch):
Code:
const int ledPin = 13;
// the setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output.
pinMode(ledPin, OUTPUT);
Serial.begin(9600); //NEW
while(!Serial); //NEW
Serial.println("Hello World"); //NEW
}
// the loop() methor runs over and over again,
// as long as the board has power
void loop() {
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
Serial.println("Loop"); // NEW
}
After verifying this code and pressing the programming button, I open the serial monitor in the IDE. I do not see anything printed to the monitor and do not see the LED blinking on the Teensy. This probably has something to do with the [while(!Serial);] line I added, and the code hangs in this loop. I also tried to remove this line, and keep everything the same as the previous code above. After verifying and pressing the programming button, the LED on the Teensy does blink, but nothing shows on the serial monitor.
Additionally I also tried to open the monitor while selecting the arduino COM port (COM11 in the screenshot above), without luck. I also tried to select a different USB type like 'Serial+keyboard+mouse+joystick'. But this didn't solve the problem either.
The USB cable seems to be fine, because I'm able to upload the blink sketch without any problem (also when changing the delays, the LED blinks at that different rate).
Hopefully someone has an idea what causes this behavior, because I'm not sure what to try next...
Some additional info:
- My laptop is running Windows 10
- Board: Teensy 4.1 purchased from Mouser