Trouble using RBD::Timer can't compile or cannot see onRestart or isExpired

I want to run a motor for 15 seconds, every hour (for testing, I am running it for 10 seconds every 1 minute). I chose the RBD::timer library for the timing.

I originally called RBD::Timer dayTimer(##); with a number for ##, at the top outside of setup() and loop() etc., and was able to get the timer to count down from the value ##.
It would also enter the ".getInverseValue" if-then statement at 10 seconds and execute the serial.print statement. However, it would never enter the "isExpired" if-then statement, and therefore would never turn off the motor.
Also, the turnTimer would expire and reset, but it would reset to a number around 4 294 967 242 (32 bits I assume).

I then removed the ## from the timer definition and used ".setTimeout(##) in the setup() function.
When I did this, I got an error

 In function 'void setup()': DHTtester:48: error: request for member 'setTimeout' in 'dayTimer', which is of non-class type 'RBD::Timer()'  dayTimer.setTimeout(600000);

I got one of these each time I used the RBD members in setup() or loop().

I searched for this error and got some hits, but did not follow. Can you let me know some thoughts. I copied the RBD folder to my arduino library folder, and 1.3.0 shows installed in the manage libraries.

#include "RBD_Timer.h"

#include "DHT.h"
#define DHTPIN 2     // what digital pin we're connected to


int motorPin = 4;   // the pin that controls the motor


RBD::Timer dayTimer();
RBD::Timer turnTimer();



#define DHTTYPE DHT22   // DHT 22  (AM2302), AM2321
DHT dht(DHTPIN, DHTTYPE);


void setup() {
  Serial.begin(9600);
  Serial.println("DHTxx test!");

  dht.begin();  

  dayTimer.setTimeout(600000);
  dayTimer.restart();
  turnTimer.setTimeout(60000);
  turnTimer.restart();

   pinMode(motorPin,OUTPUT);  // motor transistor on/off

  }




void loop() {

if (turnTimer.isExpired()) 
  {
    // timer just expired, then restarted
    // code only runs once per restart
    Serial.println("1 hour passed");
    digitalWrite(motorPin, LOW);   // the motor should have been running via the getInverseValue call
    turnTimer.restart();    //turnTimerTimeout
  }




  Serial.print("turnTimer elapsed: ");
  Serial.print(turnTimer.getValue());  
  Serial.print("    remaining: ");
  Serial.print(turnTimer.getInverseValue());
  Serial.print("      //      ");
  Serial.print("dayTimer elapsed: ");
  Serial.print(dayTimer.getValue());  
  Serial.print("    remaining: ");
  Serial.println(dayTimer.getInverseValue());



if (turnTimer.getInverseValue() < 10000)         // if 15 seconds remaining, then turn on the motor.  onRestart, turn off the motor   motorCycle*1000
  {
  digitalWrite(motorPin, HIGH);                 // turn on the motor
  Serial.println("Passed 15 second mark");
  }

if (dayTimer.onExpired()) {
    // code only runs once per event
    turnTimer.stop();            // stop the turnTimer since 19 days has elapsed
    digitalWrite(motorPin, LOW);   // make sure the motor is not running
    Serial.println("End of 19 days");
  }


}

Hi,

Welcome to the forum.

Can you post a link to the RBD library please?
What model Arduino and version of the IDE do you have?

Thanks.. Tom.. :slight_smile:

Thanks for the reply.

Board info provides this:
BN: Arduino/Genuino Uno
VID: 2A03
PID: 0043

about arduino shows 1.6.9 at the top in small text, though a quick search of the internet did not show a 'how to find your ide version'.

Quick poll also:

Does anyone out there use RBD::Timer?

And

What timer libraries do you use?

Thanks!
Ted

Hi yelkenli, here is the answer to your question on how to use this timer library: