Arduino Tutorial Series : Lesson 04 - Using Push Button

In this tutorial we will learn how to read the state of a push button to control a LED.

What you need...

an Arduino
a Breadboard
a Push Button
10 kohm resistor

Hardware setup


In this setup we have used a 10k resistor to connect the input pin 2 to the ground at normal state. When the push button is pressed, pin 2 connects to 5v. This 10k resistor is called a Pull Down resistor. This ensures the voltage at pin 2 is 0v when puch button is not pressed.

Arduino Sketch

Download arduino sketch PushButton.ino














In this sketch we check the button state in every loop and set the LED state.



No comments:

Powered by Blogger.