Disable Simple Timer -timer.disable(timerId)

I'm having some trouble disabling a timer after some code has ran.

I'm currently on a cell phone, so I can't out ask of my code in here...

Void name1(){

timer.setimer(1000,light,10)
// other code
}

Void light(){

// if code....
// else code - time stops
}

I've tried timer.disable(1000,light,10); but it didn't work...

Get thee to http://snippets-r-us.com with your snippets.

I'm not really sure that link helps me :slight_smile:

As I stated in my post, I'm unfortunately on a cell phone and can't post my code. For reason, on my computer, when I sign into this forum it blocks me and and tells that "You are already signed in".

Once I can get on the forum on my laptop I'll post my code....

muldoon:
I'm not really sure that link helps me :slight_smile:

Nor did your original post help us. So we are about even, so far. :slight_smile:

Attached is my code:

The sections I'm concerned with are: CanisterSelect, BrightLight, and DisableCanisterTimer

void BrightLight()
{
  if (lightLevel > 150)
  {

    high = lightLevel;  //the light is off
 //////     Serial.print("This is now ");
 //////     Serial.print(high);
 //////     Serial.print(" and the intLightTimeOut value is ");
 //////     Serial.println(intLightTimeOut);
    intLightTimeOut++;
    if (intLightTimeOut >= 15)
    {
      DisableCanisterTimer();
      digitalWrite(LEDEError, HIGH);
      MotorsOff();
      ResetValues();
      Serial.println("STOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOP");
    //  Serial.println(intLightTimeOut);
    //The timer should end here
    }
sketch_oct26b.ino: In function ‘void BrightLight()’:
sketch_oct26b:4: error: ‘lightLevel’ was not declared in this scope
sketch_oct26b:7: error: ‘high’ was not declared in this scope
sketch_oct26b:12: error: ‘intLightTimeOut’ was not declared in this scope
sketch_oct26b:15: error: ‘DisableCanisterTimer’ was not declared in this scope
sketch_oct26b:16: error: ‘LEDEError’ was not declared in this scope
sketch_oct26b:17: error: ‘MotorsOff’ was not declared in this scope
sketch_oct26b:18: error: ‘ResetValues’ was not declared in this scope
sketch_oct26b:22: error: expected `}' at end of input
sketch_oct26b:22: error: expected `}' at end of input

Re-read reply #1.

For some reason my attached code zip document didn't get attached.

Here is the timer I'm using:
http://playground.arduino.cc/Code/SimpleTimer#F_disable

From other posts I (think) I found out that the ID is should be: timer.setTimer(1000, BrightLight, 25).

So I tried using timer.disable(1000, BrightLight, 25), but I get an compile error of: no matching function for call to "SimpleTimer::disable(in,void(&)(),int)'

sketch_oct25a.zip (5.5 KB)

Is this one of those "interesting" cases where the user spends more time trying to figure out how to use a Library than he would have spent if he simply used millis() to manage the timing as in the Blink Without Delay example sketch and the demo several things at a time ?

...R

If you set up the timer like this

timerId = timer.setTimeout(1000, callMeLater);

You will know the ID of the timer and can disable it like this

timer.disable(timerId);

This is all detailed on Arduino Playground - SimpleTimer Library

1 Like

Is this one of those "interesting" cases where the user spends more time trying to figure out how to use a Library than he would have spent if he simply used millis() to manage the timing as in the Blink Without Delay example sketch and the demo several things at a time ?

I see nothing interesting about it. It IS one of those cases, though.

PaulS:
I see nothing interesting about it. It IS one of those cases, though.

I was searching for a word that would not be considered rude.

...R

Thanks.

I'll take the "interesting" comment as learning experience and not rude.

I knew I didn't want to use a delay() and googling *arduino *timer brought up the "Simple Timer Library". Oh well, at least I learned somethings that I probably would not have ran across.