int buttonPin = 2;
int LED = 18;
byte buttonState = LOW;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(LED, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly
buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
digitalWrite(LED, HIGH);
}
else{
digitalWrite(LED, LOW);
}
}