Hello all, pretty much of a newb here, but trying to work things out. I have an issue with delay hanging when I try to use some values. Yes, I know there are other ways to blink an LED and to time it, such as millis, but I want to understand why this does not work.
The idea is to make the LED flash twice in a 60 second cycle. Flash 1 and Flash 3 happen 60 seconds apart, Flash 2 happens a variable time between 1 and 3. Flash 2 starts close to 1 and then walks closer to 3 for 60 cycles.
Yes, this is part of a larger effort, but this portion of the code will not run on its own for some reason with certain delays selected. For example, if I use 60 in the FOR loop (to get 60 seconds Flash 1 to Flash 3) it will give me the first 2 flashes and then hang, never flashing again after that. But it I use 30 (for a 30 second cycle) it runs fine.
Is there a maximum delay using the DELAY function, and if so have I exceeded it here? Or have I made some other bone headed mistake?
/*
Flash Cycle Investigation
*/
int led = 13;
int FlashSpeed = 4;
int PulseDelay = 0;
void setup()
{
pinMode(led, OUTPUT);
}
void loop()
{
FlashCycle();
}
void FlashCycle()
{
FlashSpeed = 5;
for (int i=1; i<60; i++)
{
Flash();
delay (1000*i);
Flash();
PulseDelay = 60 - i;
delay (1000*PulseDelay);
}
}
void Flash()
{
digitalWrite(led,HIGH);
delay(25*FlashSpeed);
digitalWrite(led,LOW);
delay(25*FlashSpeed);
}
Any ideas? Thanks
T!
(edit) Sorry, did not specify, I am trying to run this on an UNO.