From button press to LED

Gate & Kernel

Arduino sketch

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);
  }
}

Uno circuit model

Arduino Uno R3 GND2 L ON Pushbutton

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.