Go Down

Topic: Stumped again Blinky (Read 681 times) previous topic - next topic

perkunas

I'm near the end of my program and I'm stumped this is what I need
1) checks if its 12 hours into the program
then sets up a while loop
2) In the while loop it has 2 blinky's, one that blinks every 12 hours on off, and one that blinks for 20 seconds on off every 24 hours.
3) Then in 14 days, it breaks out of the loop and the whole program starts over.

I got the 1st Blinky, to turn on off every 12 hours, and only when its 12 hours into the program too. The second Blinky, shouldn't be too hard set up, using a for loop counter every second blink, some thing like that.
They don't have to be very accurate.

Lost how to to do this any hints would be appreciated.
Thanks
Code: [Select]
}
//Light and Topup
  digitalWrite(7, LOW);  //Nutrient Heater on
  if (StartTime >= hours_in_ms(12)){
    while(y){
  unsigned long currentMillis = millis();
  if(currentMillis - previousMillis > interval) {
    previousMillis = currentMillis;
    if (ledState == LOW)
      ledState = HIGH;
    else
      ledState = LOW;
    digitalWrite(ledPin, ledState);
}




PaulS

Snippets-r-us.com is down the internet a ways. Here, we expect to see ALL of your code.

It appears, though, that you need a state machine. Start with drawing a bunch of circles, for each state that is of interest. Draw arrows between states that show what triggers that state change, and what happens when the state changes.

Just to make it clear, LEDs do not blink. They get turned on and off. Describing what you want to do in terms of turning the LED on and off will make it a lot easier to turn that into code than will using the term blink (or, even worse, blinky).

UKHeliBob

In the snippet that you posted would the LED ever come on ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Grumpy_Mike

Quote
would the LED ever come on ?

It depends on the value of the variable y
Code: [Select]
while(y){

As this variable is never altered inside the scope of the while then if it does start going it will never stop.
That is why a snippet of code is as useful as a chocolate fire guard. 

UKHeliBob


Quote
would the LED ever come on ?

It depends on the value of the variable y
Code: [Select]
while(y){

As this variable is never altered inside the scope of the while then if it does start going it will never stop.
That is why a snippet of code is as useful as a chocolate fire guard. 


At least you can eat a chocolate fire guard !

Agreed that we don't know what the value of y is but I don't see how the LED would ever come on in the snippet that was posted if it was not already on.  So, yes, we do need all of the code or a cut down but complete sketch that demonstrates the problem.
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

perkunas

I thought this was snipits.com lol too funny.
A state machine is probably the only answer here;  hopefully since what I want do is so simple, I can figure out how to build one.
Scarey stuff for a newb.


Go Up