I present a very simple Arduino based project where you can control an LED with a push button. This project is good for beginners starting out with Arduino programming.
You will require the following apparatus:
- 1 x Arduino Uno
- 1 x 330 ohm resistor (orange, orange, brown)
- 1 x 10k ohm resistor (brown, black, orange)
- 1 x LED
- 1 x Push button/tactile button
- 1 x Breadboard
- Some jumper wires
Connect the circuit as shown in the image above.
We are using one side of the push button.
- Connect a wire from one side of the tactile button to GND of Arduino
- Connect the 10k resistor from the other side of the button to the 5V of Arduino
- From the same pin of the button, run a wire to pin 10 of Arduino
- Connect the anode of the LED to pin 6 of Arduino
- Connect a 330 ohm resistor from the cathode of the LED to GND of Arduino
Upload the following code to the Arduino board;
//Declare pins you are going to use
int ledPin = 6;
int pushButton = 10;
int val = 0; //variable to hold state of button
void setup() {
pinMode(ledPin, OUTPUT); //set mode of pin as outputÂ
pinMode(pushButton, INPUT); //set pin as input to read button state
//Begin with LED off
digitalWrite(ledPin, LOW);
}
void loop() {
val = digitalRead(pushButton); //Read button state
if(val == HIGH){
digitalWrite(ledPin, HIGH); //if button is pressed turn on LED
}
else{
digitalWrite(ledPin, LOW); //Turn off LED when button is released
}
}
When you press the button, pin 10 goes HIGH, or is at 5V, hence the LED is put on. Releasing the button returns pin 10 back to GND or 0V, and consequently, the LED goes off.
I have used the comment symbol // in the above sketch to explain what each part or line of code does.
Also read:

