bool StatusOfLED = true;
byte StatusOfButton = 0;
long TimeOfStateNumber0, CurrentTime = 100;
void setup()
{
pinMode(4, OUTPUT); pinMode(8, INPUT_PULLUP);
}
void loop()
{
if (StatusOfButton == 0)
{
if (digitalRead(8) == false)
{
StatusOfButton = 1;
TimeOfStateNumber0 = millis();
}
}
else if (StatusOfButton == 1)
{
if (digitalRead(8))
{
StatusOfButton = 0;
}
else if (millis() - TimeOfStateNumber0 > CurrentTime)
{
StatusOfLED = !StatusOfLED;
StatusOfButton = 2;
}
}
else if (StatusOfButton == 2)
{
if (digitalRead(8))
{
StatusOfButton = 0;
}
}
digitalWrite(4, StatusOfLED);
}