DrOpShOtZ
Published

Arduino Button with LED

Turns on and off a LED when pressing a pushbutton

BeginnerProtip11,235
Arduino Button with LED

Things used in this project

Story

Read more

Schematics

ARDUINO PUSHBUTTON with LED

The circuit diagram

Code

ARDUINO BUTTON.ino

Arduino
const int buttonPin = 2;
const int ledPin =  13;

int buttonState = 0;

void setup()
{
  pinMode(ledPin, OUTPUT);
  pinMode(buttonPin, INPUT);
}

void loop()
{
  buttonState = digitalRead(buttonPin);

  if (buttonState == HIGH)
  {
    digitalWrite(ledPin, HIGH);
  } 
  else
  {
    digitalWrite(ledPin, LOW);
  }
}

Credits

DrOpShOtZ

DrOpShOtZ

12 projects • 17 followers
Contact me from Discord. DrOpShOtZ#6290

Comments