Introduction: Arduino - Button With LED

Turns ON and OFF a light LED, when pressing a pushbutton.

Step 1: Hardware Required

Picture of Hardware Required

  • Arduino Uno
  • LED
  • Button
  • 220 and 10k ohm resistors
  • Wires
  • Breadboard

Step 2: LED Connections

Picture of LED Connections

  1. LED attach to board
  2. Resistor (220 ohm) connect to LED's long leg (+)
  3. The wire connect to resistor empty leg
  4. After that, same wire connect to digital pin from resistor
  5. The wire connect to LED's short leg (-), after that same wire connect to ground

Step 3: Pushbutton Connections

Picture of Pushbutton Connections

  • The button attach to board
  • 10k resistor connect to button leg
  • The wire connect to resistor empty leg, after that same wire connect to ground
  • The wire connect to button's other leg, after that same wire connect to +5V
  • The yellow wire connect to button's top leg, after that connect to digital pin

Step 4: Code

Picture of Code

const int ledPin = 2;

const int buttonPin = 4;

int buttonState = 0;

void setup() {


pinMode(ledPin, OUTPUT);

pinMode(buttonPin, INPUT);


void loop() {

buttonState = digitalRead(buttonPin);

if (buttonState == HIGH) {

digitalWrite(ledPin, HIGH);

Serial.println("LED ON +++++++");

else {

digitalWrite(ledPin, LOW);

Serial.println("LED OFF -------");



Step 5: If It Helps, Please Subscribe

Picture of If It Helps, Please Subscribe

First of all, I would like to thank you for reading this guide ! I hope it helps you.

If you want to support me, you can subscribe my channel and watch my videos.

Mert Arduino Tutorial & Projects


Nic-SMD (author)2017-09-27

Hello friend,

I need to make a project but my zero knowledge in programming does not allow me to build it. For someone with knowledge and experience may be a project for children :).

I am wondering if you can help me on that.. please!

Micky Flanagan (author)2016-11-18

Maybe it's not yours or something but the arduino uno on the first page looks like a knockoff.

im with you

Sorry. I don't understand you :/ What are you talking about?

Alejandro2099 (author)2017-08-28

im with Micky Flanagan

Alejandro2099 (author)2017-08-28

i dont know what i did wrong and it didnt work

About This Instructable




Bio: For more project and tutorial visit my YouTube channel Mert Arduino and Raspberry Pi
More by MertArduino:XY Plotter Drawing Robot | Arduino | PolargraphArduino - Balance - Balancing Robot | How to Make?Arduino - MPU6050 GY521 - 6 Axis Accelerometer + Gyro (3D Simulation With Processing)
Add instructable to: