Countimer
This is simple timer and counter Arduino library.
Install / Use
/learn @inflop/CountimerREADME
Countimer
This is simple timer and counter Arduino library.
Offers three work modes:
- Count-up timer with call specified method when count is complete.
- Count-down timer with call specified method when count is complete.
- Calling any method at a specified time interval.
It allows you to start/pause, stop or restart timer.
The following are public methods for actions:
- void start()
- void stop()
- void pause()
- void restart()
Other methods:
- byte getCurrentHours()
- byte getCurrentMinutes()
- byte getCurrentSeconds()
- void setInterval()
- String getCurrentTime()
- bool isCounterCompleted()
- bool isCounterRunning()
- bool isStopped()
And here's some sample code!
#include "Countimer.h"
Countimer timer;
void setup() {
Serial.begin(9600);
// Set up count down timer with 10s and call method onComplete() when timer is complete.
// 00h:00m:10s
timer.setCounter(0, 0, 10, timer.COUNT_DOWN, onComplete);
// Print current time every 1s on serial port by calling method refreshClock().
timer.setInterval(refreshClock, 1000);
}
void refreshClock() {
Serial.print("Current count time is: ");
Serial.println(timer.getCurrentTime());
}
void onComplete() {
Serial.println("Complete!!!");
}
void loop() {
// Run timer
timer.run();
// Now timer is running and listening for actions.
// If you want to start the timer, you have to call start() method.
if(!timer.isCounterCompleted()) {
timer.start();
}
}
Related Skills
node-connect
354.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
112.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
354.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
354.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
