What We're DoingUp to this point we have focused entirely on outputs, time to get our Arduino to listen, watch and feel. We'll start with a simple pushbutton. Wiring up the pushbutton is simple. There is one component, the pull up resistor, that might seem out of place. This is included because an Arduino doesn't sense the same way we do (ie button pressed, button unpressed). Instead it looks at the voltage on the pin and decides whether it is HIGH or LOW. The button is set up to pull the Arduino's pin LOW when it is pressed, however, when the button is unpressed the voltage of the pin will float (causing occasional errors). To get the Arduino to reliably read the pin as HIGH when the button is unpressed, we add the pull up resistor. (note: the first example program uses only one of the two buttons)

Light Not Turning On The pushbutton is square and because of this it is easy to put it in the wrong way. Give it a 90 degree twist and see if it starts working.

Light Not Fading A bit of a silly mistake we constantly made, when you switch from simple on off to fading remember to move the LED wire from pin 13 to pin 9.

Underwhelmed? No worries these circuits are all super stripped down to make playing with the components easy, but once you throw them together the sky is the limit.

Making it Better?

On button off button:The initial example may be a little underwhelming (ie. I don't really need an Arduino to do this), lets make it a little more complicated. One button will turn the LED on the other will turn the LED off. Change the code to. int ledPin = 13; // choose the pin for the LED int inputPin1 = 3; // button 1 int inputPin2 = 2; // button 2

Upload the program to your board, and start toggling the LED on and off.

Fading up and down:Lets use the buttons to control an analog signal. To do this you will need to change the wire connecting the LED from pin 13 to pin 9, also change this in code. int ledPin = 13; ----> int ledPin = 9;Next change the loop() code to read.

Changing Fade Speed:If you would like the LED to fade faster or slower, there is only one line of code that needs changing; delay(10); ----> delay(new #);To fade faster make the number smaller, slower requires a larger number.