nakedsensor
Member
My current project needs a startup delay, to allow some external electronics to stabilise before the main code runs. I'm having trouble with "delay()" though.
The code below works fine on a Teensy 3.1, but fails to introduce any delay on a Teensy-LC ( most of the time it fails ... very occasionally it works though ... weird ).
Since this is always run from a reset, the workaround below works fine, but I'd like to be able to use delay() with confidence.
Any ideas ?
The code below works fine on a Teensy 3.1, but fails to introduce any delay on a Teensy-LC ( most of the time it fails ... very occasionally it works though ... weird ).
Code:
int LED_pin = 13;
void setup(void)
{
Serial.begin(9600);
digitalWrite(LED_pin,LOW);
pinMode(LED_pin,OUTPUT);
delay(3000);
Serial.println("Hello");
}
void loop(void)
{
digitalWrite(LED_pin,HIGH);
delay(500);
digitalWrite(LED_pin,LOW);
delay(500);
}
Since this is always run from a reset, the workaround below works fine, but I'd like to be able to use delay() with confidence.
Code:
int LED_pin = 13;
void setup(void)
{
Serial.begin(9600);
digitalWrite(LED_pin,LOW);
pinMode(LED_pin,OUTPUT);
while ( millis() < 3000 )
{
}
Serial.println("Hello");
}
void loop(void)
{
digitalWrite(LED_pin,HIGH);
delay(500);
digitalWrite(LED_pin,LOW);
delay(500);
}
Any ideas ?