const int BUTTON = 19; //Connect button to D1
const int LED=2; //Connect LED to D2
int ledState = LOW; //Default state of LED is low
int previousButtonState;
int presentButtonState;
void setup()
{
pinMode(BUTTON,INPUT); //Configure Button as input
pinMode(LED, OUTPUT); //Configure LED as output
}
void loop()
{ //Read the button state
presentButtonState = digitalRead(BUTTON);
if(presentButtonState==HIGH) //If Button state is high
{
digitalWrite(LED, HIGH); //Turn ON LED
}
else //If button state is low
{
digitalWrite(LED, LOW); //Turn LOW LED
}
}