0

I have created an app which is connencted to my arduino via bluetoth. The user of the app can turn on and off a led which is connented to the arduino. But I want to take it a step further... I want the user to be able to give the time and the date when the light should turn on and additionally the time that sould pass until the led turns off again. Is it significantly harder? I have thought of using an already existing alarm app but I am pretty stuck, so could anyone give me some suggestions?

1
  • All you will need is an RTC module, you set an alarm with the module; it will trigger an interrupt when the time and data you set is reached. Then you light up the LED and use a timer to keep track of the length of time its on. – SoreDakeNoKoto Mar 6 '16 at 11:44
1

Make the Bluetooth message send how many seconds it is until the light should be on, and how many seconds it should stay on.

Then the arduino code can just handle everything with millis(). You know the millis() you were asked to start, add the delay, and wait for that time.

Delays less than 50 days (wrap around of millis ()) take no effort to handle it you embrace the overflow.

Handling delays greater than 50 days can be achieved by watching for millis() overflows and counting them. You could also make your own timer based counter.

If you care about recovery after power loss / reset you could use an RTC module. Depending on its complexity, it could interrupt you or you poll it to check for a date you saved to Arduino eeprom. You would have to consider what the system should do it the alarm would have happened during the power loss...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.