Hey guys I know this should be very simple but I just can't get it figured out. I tried to modify the "blink" code to make the led blink at 1 second intervals for 10 seconds and then start blinking for 10 second intervals. Seems like it should be easy but instead it blinks once at a 1 second interval then once at 10 second interval and on and on. Please take a look, I'm sure its something dumb.
int ledPin = 13; // LED connected to digital pin 13
int dly = 1000;
long t;
// The setup() method runs once, when the sketch starts
void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
t= millis();
if (t<10000);
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(dly); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(dly); // wait for a second
t=millis();
}
if (t>=10000 && t<10000000);
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(dly*10); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(dly*10); // wait for a second
t=millis();
}
}
if (t<10000);
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(dly); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(dly); // wait for a second
t=millis();
}
I think that you want this block executed while, not if, t < 10000. Since there is some time involved in calling digitalWrite, delay, and millis, the block won't execute 10 times (or even 5).
If you want to make the led flash 10 times at one second intervals, then 10 times at 10 second intervals, then have the program do nothing, you need three for loops, with the last one being:
I thought it might be easier to get rid of time so I tried this:
if (i<100);
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(dly); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(dly); // wait for a second
t=millis();
i++;
}
if (i>=100);
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(dly*10); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(dly*10); // wait for a second
t=millis();
i++;
}
It still gives me the same problem it basically just ignores the if statements and keeps looping through the program as if they weren't there. Any suggestions?