int const redLed = 23;
int const button = 22;
bool statusLed = LOW;
unsigned long timeValueNew = 0;
unsigned long timeValueOld = 0;
void setup() {
// put your setup code here, to run once:
pinMode(redLed, OUTPUT);
pinMode(button, INPUT);
}
void loop()
{
// put your main code here, to run repeatedly:
timeValueNew = millis();
if(digitalRead(button) == HIGH)
{
if ((timeValueNew - timeValueOld)>1000)
{
digitalWrite(redLed, HIGH);
}
if ((timeValueNew - timeValueOld)>2000)
{
digitalWrite(redLed, LOW);
timeValueOld = timeValueNew;
}
}
if(digitalRead(button) == LOW)
{
digitalWrite(redLed, HIGH);
}
}