sexta-feira, 1 de março de 2013

TUTORIAL - Turning on LED's using a button

Turning on LED's using a button

Since the last tutorial was very easy, we're going to use a button to turn the LED on.

So, what are we going to need for this:

1 - LED
1- Arduino (with USB cable)
1 - button
1 - 1 kohm resistor
1 - jumper wires
1 - breadboard

Now we are going to put the button on the centre of the breadboard with one side connected to the red row using a jumper wire and the other connected to the blue row using the 1K resistor (actually you could use some other resistor but try using a large one) and to the pin 8 of the Arduino using a jumper wire.
After that you will connect the ground pin of the Arduino to the negative row of the breadboard and the 5V pin to the positive row.



To simplify the schematics I will be using the LED in the pin 13 because, like I said in the first post, this pin has already a resistor in it (because of the Arduino's LED). Don't forget to put the short lead to ground and the long lead to 13.

The Sketch is very simple:



(While uploading the Sketch it may happen to blink the LED, if it does don't be worry!)

This one is quite boring right?
Actually you don't even need an Arduino to do this...

So, what we'll do next is:
Turning this button into a push button, that means:

push -> LED turns on
push again -> LED turns off

Using the same circuit, let's just change the Sketch.
If you don't know much about switches I suggest you look up "switch bounce" on google.


Well I hope you enjoyed it
Watch the videos of the results to see how it should look like!









Sem comentários:

Enviar um comentário