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


#define LED_PIN 5
#define BUTTON_PIN 6
#define BTN_DEB 50

int count = 0;

void setup()
{
  pinMode(LED_PIN, OUTPUT);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop()
{
  static bool pState = false;
  static uint32_t tmr;

  bool state = !digitalRead(BUTTON_PIN);

  if (pState != state && millis() - tmr >= BTN_DEB)
  {
    tmr = millis();
    pState = state;

    if (state)
    {
      count++;

      if (count == 3)
      {
        for (int i = 0; i <= 255; i++)
        {
          analogWrite(LED_PIN, i);
          delay(12);
        }
      }

      if (count == 4)
      {
        count = 0;
        analogWrite(LED_PIN, 0);
      }
    }
  }
}