stellartom
New member
I have a data usb cable and plug in my Teensy 4.0 but can get a serial port. Meanwhile the slow blink program is running. I use the Teensy loader to load the blink fast hex file and it works. Anyone have any ideas?
const int ledPin = LED_BUILTIN; // the number of the LED pin
int ledState = LOW; // ledState used to set the LED
unsigned long previousMillis = 0; // will store last time LED was updated
const long interval = 100; // interval at which to blink (milliseconds)
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
unsigned long currentMillis;
while (1) {
currentMillis = millis();
if (Serial)
break;
if (currentMillis - previousMillis >= interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}
}
void loop() {
if (Serial.available()) { // If anything comes in Serial (USB),
Serial.write(Serial.read()); // read it and send it out Serial (USB)
}
}
The sketch p#2 was edited and tested here ... was it used and tested there? With what results?Thanks for the reply.