#define BTN_PIN 3 // кнопка подключена сюда (BTN_PIN --- КНОПКА --- GND)
#include "GyverButton.h"
GButton butt1(BTN_PIN);
#include <TimerMs.h>
TimerMs tmr(2000, 1, 1);
int led = 13;
int time = 4;
uint32_t timer_time;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
butt1.setDebounce(50); // настройка антидребезга (по умолчанию 80 мс)
butt1.setTimeout(300); // настройка таймаута на удержание (по умолчанию 500 мс)
butt1.setClickTimeout(600); // настройка таймаута между кликами (по умолчанию 300 мс)
//butt1.setType(HIGH_PULL);
//butt1.setDirection(NORM_OPEN);
tmr.setPeriodMode();
}
void Show_Time()
{
for (int i = 1; i <= time; i++)
{
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
}
void Doo()
{
for (int i = 1; i <= 1; i++)
{
digitalWrite(led, HIGH);
delay(500);
digitalWrite(led, LOW);
delay(500);
}
}
// the loop routine runs over and over again forever:
void loop() {
if (tmr.tick()) Serial.println("tick");
butt1.tick();
if(butt1.isSingle())
{
Doo();
Serial.println(tmr.timeLeft8());
}
if (butt1.isHold()) {
if(butt1.getHoldClicks()>0)
{
time = butt1.getHoldClicks();
timer_time = time*100*10;
tmr.setTime(timer_time);
Serial.println(timer_time);
}
Show_Time();
}
//digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
//delay(1000); // wait for a second
//digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
//delay(1000); // wait for a second
}