Pages: [1]   Go Down
Author Topic: Stumped again Blinky  (Read 517 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
}
//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);
}

 
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 551
Posts: 46240
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 90
Posts: 3516
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In the snippet that you posted would the LED ever come on ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31543
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
would the LED ever come on ?
It depends on the value of the variable y
Code:
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. 
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 90
Posts: 3516
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
would the LED ever come on ?
It depends on the value of the variable y
Code:
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.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Full Member
***
Karma: 0
Posts: 111
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

Logged

Pages: [1]   Go Up
Jump to: