// We assigned a name LED pin to pin number 22
const byte LEDPIN = 22;
// this will assign the name PushButton to pin numer 15
const byte PushButton = 15;
// This Setup function is used to initialize everything
void setup()
{
Serial.begin(115200);
// This statement will declare pin 22 as digital output
Serial.println("Hello World");
pinMode(LEDPIN, OUTPUT);
// This statement will declare pin 15 as digital input
pinMode(PushButton, INPUT_PULLUP);
}
int16_t count60=0;
int16_t countON=0;
bool boolON=false;
void loop()
{
count60++;
// Serial.printf(" count =: %d",count60);
delay(100);
if (count60 > 60) {
digitalWrite(LEDPIN, HIGH);
if (boolON == false) {
Serial.println("LED goin ON");
boolON = true;
}
}
if (count60 > 120) {
digitalWrite(LEDPIN, LOW);
Serial.println("Led OFF");
count60 = 0;
boolON = false; // allow the inital "LED ON" msg to print once
}
// digitalRead function stores the Push button state
// in variable push_button_state
int Push_button_state = digitalRead(PushButton);
// if condition checks if push button is pressed
// if pressed LED will turn on otherwise remain off
if ( Push_button_state == LOW )
{
Serial.println("Push Button Pressed !");
digitalWrite(LEDPIN, HIGH);
}
else
{
digitalWrite(LEDPIN, LOW);
}
}