const int buttonPin = 2; void setup() { pinMode(buttonPin, INPUT_PULLUP); pinMode(LED_BUILTIN, OUTPUT); } void loop() { int buttonLevel = digitalRead(buttonPin); if (buttonLevel == ) { digitalWrite(LED_BUILTIN, HIGH); } else { digitalWrite(LED_BUILTIN, LOW); } }
Stopped
Pin 2: — · LED L: off
Click Start, then press and hold the red button.
To reverse the light, stop the model, double-click LOW in the comparison, type HIGH, and start again.