Run code if previous value was true?


hello again,

a minor setback in code creation, it's quite enjoyable figuring out solution  :d

i have piece of code inside while() loop
code: [select]


if (millis() - tempstate > inttemp)
    {
      tempstate = millis();
      ktemp = tempsensor();
  }

if (ktemp < 100)
    {
      if(togglemarker = true)
        {
          startsequence();
          delay(10000ul);
        }

      mainsequence();
      togglemarker = false;
    }
  else if (ktemp >= 100)
    {
      stopsequence();
      togglemarker = true;
    }
 
 


basically i'm looking this:

i want startsequence() run once (for 10 seconds) if temperature before above 100 or better yet, if stopsequence() has been active before. nice keep ktemp timer still going (so no delays).


my solution along these lines (but i'm not sure if code works way):

when code "is in the" stopsequence() part of the if statment, should leave "marker" in..."i here" speak. instant temperature falls below 100 code switches first part of if statment, whilst marker still true moment being. code starts running startsequence(). after it's done should switch the mainsequence() , turn marker off, preventing startsequence() ever run again until temperature condition meet again.

again...i'm not sure if local variable togglemarker can used way?
and there way not use delay startsequence() part?

i'm looking hints rather solved code, it's way more fun , learning experience way  :d
thank you.

code: [select]
     if(togglemarker = true)
does assigning true togglemarker, in context, make sense?

code: [select]
     ktemp = tempsensor();
function names should have noun , verb. noun , verb?

quote
it nice keep ktemp timer still going (so no delays).

i fail see how ktemp timer.

quote
when code "is in the" stopsequence() part of if statment, should leave "marker" in..."i here" speak.


code: [select]
bool beentheredonethat = false; // global

in stopsequence(), set beentheredonethat true.

quote
and there way not use delay startsequence() part?

without seeing startsequence(), , having idea sequence function starts, there no way know.

by way, start , stop verbs. main not.


Arduino Forum > Using Arduino > Programming Questions > Run code if previous value was true?


arduino

Comments

Popular posts from this blog

Connecting Raspberry Pi 2 to P10(1R)-V706 LED Dot Matrix - Raspberry Pi Forums

TypeError: <unknown> is not a numpy array - Raspberry Pi Forums

datso and removing imagetitle - Joomla! Forum - community, help and support