I was trying to debug some code running on a Teensy 3.0 and was getting some really odd results. After a lot of going back and forth, I figured it out. When you open the serial monitor in the Arduino IDE, it doesn't restart the Teensy 3.0 as it does for ATmega boards including the Teensy 2.0. For example, see this sketch:
On an ATmega board (including Teensy 2.0), every time you open the serial monitor window in the Arduino IDE, the LED blinks and it starts the counting at 1, then 2, etc. But, run the same sketch on the Teensy 3.0 and you'll get something totally different. The LED doesn't blink and the counter will display how many seconds since you uploaded the program or the last time you hit the reset button. For example, 5 then 6, etc. If you close the serial monitor, wait 10 seconds and open the serial monitor again, the LED won't blink and the display will read something like 17, 18, etc.
Try this, with the above sketch on a Teensy 3.0, try to get the serial monitor to start with 1, near impossible (best I could do was 2). Because of this, all sketches where you want to get a serial output you need to start the sketch with a several second delay, hit the reset button on the Teensy 3.0, then open the serial monitor.
Am I missing something or doesn't the Teensy 3.0 have the ability to trigger a restart via the serial monitor?
Tim
Code:
int cnt = 1;
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
digitalWrite(LED_BUILTIN, LOW);
delay(100);
digitalWrite(LED_BUILTIN, HIGH);
}
void loop() {
Serial.println(cnt++);
delay(1000);
}
On an ATmega board (including Teensy 2.0), every time you open the serial monitor window in the Arduino IDE, the LED blinks and it starts the counting at 1, then 2, etc. But, run the same sketch on the Teensy 3.0 and you'll get something totally different. The LED doesn't blink and the counter will display how many seconds since you uploaded the program or the last time you hit the reset button. For example, 5 then 6, etc. If you close the serial monitor, wait 10 seconds and open the serial monitor again, the LED won't blink and the display will read something like 17, 18, etc.
Try this, with the above sketch on a Teensy 3.0, try to get the serial monitor to start with 1, near impossible (best I could do was 2). Because of this, all sketches where you want to get a serial output you need to start the sketch with a several second delay, hit the reset button on the Teensy 3.0, then open the serial monitor.
Am I missing something or doesn't the Teensy 3.0 have the ability to trigger a restart via the serial monitor?
Tim