// set pin numbers
const int sensorPin = 32; // the number of the pushbutton pin
const int ledRed = 27; // the number of the LED pin
const int ledGreen = 33;
// variable for storing the pushbutton status
int buttonState = 0;
void setup() {
Serial.begin(115200);
pinMode(sensorPin, INPUT);
pinMode(ledRed, OUTPUT);
pinMode(ledGreen, OUTPUT);
// initialize the LED pin as an output
// pinMode(ledpin, OUTPUT);
}
void loop() {
// read the state of the pushbutton value
buttonState = digitalRead(sensorPin);
delay(1000);
// check if the pushbutton is pressed.
// if it is, the buttonState is HIGH
if (buttonState == HIGH) {
digitalWrite(ledRed, HIGH);
digitalWrite(ledGreen, LOW);
Serial.println("Dim");
} else {
digitalWrite(ledGreen, HIGH);
digitalWrite(ledRed, LOW);
Serial.println("Bright");
}
}