Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4485

C/C++ • Timers in C++

$
0
0
I would like to have several timers in my program. Say I want to turn a fan on for 1 minute and then off for another 2 minutes. At the same time I would like to turn an LED on for 2 seconds and then off for 3 seconds. The thing repeats like that for the rest of eternity (or until someone closes the program).

I searched both this forum and others on the internet, but all I found was people recommending to do it with a thread that waits for the needed time or with some delay or sleep. However delays and sleep are not nice because the program should keep doing its other things while those two happen. I could possibly program my own timers, but before I reinvent the wheel, I would like to know if there is any function in any library that would do that fairly easily. Is anyone aware of anything like that?

Statistics: Posted by elrkoxo — Thu Dec 05, 2024 8:52 pm — Replies 0 — Views 15



Viewing all articles
Browse latest Browse all 4485

Trending Articles