Загрузка данных


// Подключаем библиотеку
#include <QuadDisplay.h>

#define DISPLAY_PIN 9
#define BUTTON_PIN 4

int timerSeconds = 300;
unsigned long prevMillis = 0;
bool timerRunning = true;

void setup()
{
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  displayInt(DISPLAY_PIN, 0);
  prevMillis = millis();
}

void loop()
{

  if (digitalRead(BUTTON_PIN) == LOW) {
    timerSeconds = 300;
    timerRunning = true;
    delay(300);
  }

  if (timerRunning && timerSeconds > 0) {
    if (millis() - prevMillis >= 1000) {
      timerSeconds--;
      prevMillis = millis();
      
      int minutes = timerSeconds / 60;
      int seconds = timerSeconds % 60;
      displayNumber(minutes, seconds);
    }
  }
 
  if (timerSeconds == 0 && timerRunning) {
    timerRunning = false;
    displayDigits(DISPLAY_PIN, QD_O, QD_f, QD_f, QD_NONE); 
  }
}

void displayNumber(int minutes, int seconds) {
  int number = minutes * 100 + seconds;
  displayInt(DISPLAY_PIN, number, true); 
}