## Step 3: Wiring the Pushbutton Switch

To keep things modular, the pushbutton switch also connects to your Arduino, but it's a very separate circuit.

Note that the little pushbutton switches commonly available have four legs. The pins on each side are permanently connected to one another, so the button actually makes a single connection between the two sides. If you're in doubt as to which posts are which, just check it with your multimeter.

In the circuit diagram you're going to notice that we are using two resistors. Again, the exact values aren't really important, but the relative values are. If you aren't familiar with the concept of pull-up/pull-down resistors, please take a minute to really understand this circuit. If you don't, you will likely get flaky results in future projects or -- worse yet -- burn out your Arduino.

When the switch is OPEN, the circuit is simply a connection from the digital input (pin 2 in our case) to ground through a couple of resistors. Since we are connected to ground the value at pin 2 is LOW (approximately zero volts). If we were connected only to the switch the value would be whatever noise the wires were picking up. Maybe it would be close enough to zero to work, but maybe not. We need that ground connection to make sure our reading is right.

When the switch is CLOSED, the 5V source is connected to ground across our 15k resistor. The 150 ohm resistor is negligible by comparison, so it has a minimal effect on the voltage our input pin is reading (5V) and the digital input is HIGH (~5V). The 150 ohm resistor keeps us from creating a short between the power source and the pin so that we don't damage the Arduino.

Again, the exact values of these resistors are not important. Just make sure R1 is MUCH bigger than R2 and that R2 is big enough to limit the current back to the board. My values were simply plucked from my parts bin.

Clarification: The resistor is a pull-DOWN resistor because it connects the digital input to ground. A pull-UP resistor would pull the normal (no button pressed) state of the input to 5V.
I try to get 2 type output from my one arduino uno. I upload 2 types sketch, but i can't able....so anyone is help me out....from this
<p>So when you send a message to the computer using Serial.print how do you view it on the computer. I think you need to add this bit in please. Otherwise your instructable is excellent indeed.</p>
<p>Hi , thansk for the tutorial , it was clear and it works , even i have a Arduino Mega2560 everything is fine. I just dont get the last bit with the serial.print function. <br><br>Could you specify this ? Where do i add the code ? Into the monitor send ? </p>
this is a great tutorial about Arduino. also, I write a comprehensive <a href="http://www.intorobotics.com/resources-and-tutorials-to-start-working-with-arduino-boards/" rel="nofollow">tutorial about how to start using Arduino boards and resources</a>.&nbsp;
this may be a little late (and possibly make me sound like an idiot) but here goes, i was wondering if thats all code or if your instructions are included in the coding above?
Download the file at the end called &quot;KevinsArduinoTutorial.cpp&quot;. That's JUST the code and you can use it as-is in the Arduino IDE (the program editor). In the text on this Instructables page, the code starts with the line: <br> <br>/* <br> <br>and ends with the final <br> <br>} <br> <br>on the page. <br> <br>Don't worry about sounding like an idiot! If you aren't tackling new subjects where you don't know anything at all, then you aren't reaching your potential. The smartest people I know are the least afraid of looking like an idiot -- so they fearlessly ask &quot;dumb questions&quot; all the time!
Thanks for the help, and the motivation great instructable by the way :)
Just ordered an arduino duemilanove =D Cant wait to get my hands on it :P<br/>
&nbsp;Be careful not to roast your first one! Stick with using USB power until you're pro. Enjoy :)
I have an uno that I ordered from fut-electronics.com and because I live in Egypt it was delivered to me for total of 165 egptian pounds that I'm afraid to loss or fry because i think my dad won't let me buy any thing else from that web-site as it was delivered an empty arduino uno box sealed and sealed cable so the i told them on the phone they sent another one with the board inside!!
There's really not much that can go wrong with external power supply. Just make sure you've got the right polarity, and that it is no higher than 12VDC and you should be good.<br /> But don't play with transistors :P .. I roasted 2 pins on my atmega168 by connecting transistors to it the wrong way, but I already ordered some new atmega328's :D<br />
&nbsp;Hahaha, i roasted my whole 328 :(<br /> <br /> I also ordered a new one!
i'll try to be careful not to roast my 328's when i get them :)<br /> Where do you order your chips from?<br /> <br /> Atleast i only roasted 2 pins (so far) on my 168, so I can still use the other pins :)<br /> <br />
I ordered my first Arduino from Italy which took too long so now I am ordering parts from the only local store we have in South Africa.<br /> http://www.netram.co.za<br />
awesome!!!! i've been struggling with electronics123 cos they don't have much. now i haz a new place to gets my stuffs!!! thanks
Okay I ordered my first arduino from www.coolcomponents.co.uk, but now im ordering my parts from sparkfun.com .. Better prices, and more stuff :)<br />
i have 4 of the new deumilanove atmega328's hope i dont fry them xD
Yeah i am ordering one too!
I ordered today Getting Started with Arduino kit from Makershed! Can't wait it to come all the way to Finland!!
Wow Finland? I'm gonna get mine soon...eventually XD
Mine is gonna take a liiitle more than the 3-5 days.. Someone got one from US to Canada in a week... Well I just hope that I'd get mine in about one and a half week
i got mine now! :D Did you?
About four (five) weeks ago... :)
Ah :D Last month?
Yes
What have you done with it so far?
The Blinking LED, of course :D The EMF detector is awesome invention and I added a piezo buzzer to mine. And I've done some FSR (force sensing resistor) LEDs and knight rider lights and many others.. The sample code "Melody" was nice too, and of course with my own modification ;) What you have done? Do you recommend some project? I recommend warmly the EMF detector by Aaron Alai.
The blinking LED, Getting readings from potentiometers, And even a siren!(based on melody code) Would you like the siren code?
Here
Yeah, Where did you buy yours from?(also, Is finland near italy?(italy is where arduino's are made))
I ordered from USA Makershed. Finland is one of the Northest countries and Italy pretty much at the Southest end of Europe. So it might take some time to get over the ocean and here...
Hi To All <br>I need your help.I have Arduino Duemilnove but nothing happen when I plug it through USB.The first time I plugued it it went through the installation.but when I plug it now the computer does not detect it! <br>another thing I downloaded all the drivers but when I try to unzip them ,they are kind of non-executable!?what to do .your help is greatly appreciated.Thanks again. <br>Ijabi
and i have a arduino uno
do i have to reset my arduino before loding another code or i have to erase the old code or just programme the new program<br>and how many pin switch did u use 4 or 2
I'm completely new with programming. don't even know much about computers. Can somebody please explain to me what means what here. why am i typing int before everything. is there somewhere i can reference all of these terms?
I would recommend you learn a little basic programming first. Look for a tutorial on C as a starting point as the Arduino uses a bit of C and C++ for it's development. <br><br>The &quot;int&quot; before the variable names defines what kind of information the variable will store. In the case of &quot;int&quot; it means the value will be an integer. Other common variable types are &quot;float&quot; for floating point (decimal) numbers and &quot;char&quot; for characters. There are quite a few types. The full language reference for the Arduino is here: http://arduino.cc/en/Reference/HomePage
I just bought The getting started book and a kit, and they keep mentioning using a resistor on some pins but not others, thank you for finally explaining why.
I'm new to this stuff but wouldn't that be a pull down?
Correct. Thanks for the catch on that. I've clarified the text now. Pull-up/Pull-down refers to what happens when the switch is OPEN. A pull-up resistor would hold Digital Pin 2 to 5V. A pull-down resistor holds it to 0 when the switch is open. We're holding to 0V when the switch is open, so this is a pull-down resistor.
I have a slightly different setup: both resistors are 220 ohm.<br/><br/>The button: white - pin 2, orange - 5V, blue - ground.<br/><br/>The diodes: All white cables are connected to ground on this part of the bread board. Connect ground to resistor and then all diodes to the other end of the resistor.<br/><br/>I also modified the code to fix some bugs and look better in general (in my opinion): <a rel="nofollow" href="http://pastebin.com/f4474a984">http://pastebin.com/f4474a984</a><br/><br/>Larger pictures: <a rel="nofollow" href="https://www.instructables.com/file/FCHGNN5FS8RCU12/?size=ORIGINAL">1</a>, <a rel="nofollow" href="https://www.instructables.com/file/FWH8307FS8RCU11/?size=ORIGINAL">2</a>, <a rel="nofollow" href="https://www.instructables.com/file/FPJNVKFFS8RCU0U/?size=ORIGINAL">3</a>.<br/>
The code definitely looks much cleaner!
(Note that the code says i use 5 LEDs but the pictures only show 4. This is because I updated the code after I took the pictures.)
Woo Hoo! I ordered my arduino yesterday, and i geuss its supposed to get here today......
Its not working for me....... Here's the <a rel="nofollow" href="https://www.instructables.com/answers/Why_cant_i_upload_programs_to_my_arduino_duemilan/">question</a> i posted.<br/>
Something i should do! as soon as i get enough money
Definitely! The Arduino is a great platform for experimentation. As an added plus, you can then pull the ATmega168 chip from the board to put in a standalone project. Add a replacement chip (with the bootloader already on it) for your next development project from Adafruit for \$6. I may write up the process of going from Arduino to standalone in the next couple of weeks as a separate instructable for building an LED mood light decoration.
you can buy the ATmega168 for 3 euros...
That's about right. However, you'll have to burn an Arduino bootloader on it unless you buy one with it preloaded. That usually raises the price just a little -- say to 4 Euro (5 or 6 USD). I just ordered several for use in my next project and tutorial. You will also need an external crystal for the ATmega168 if you use it in a standalone project.
ohh but does the arduino come with all that? coz i havent got the programing PC ready yet, i just ordered to see if it works(dont trust portuguese mail), and if it does i wil be thrilled, so does the arduino come with everything i need?(not counting resistors and all...) i know i gotta get the software from the website... thnks
The only thing you have to have besides the Arduino is a USB cable to connect to your computer (plus, as you said, a few parts to build a circuit).