New to electonics and Arduino and need advice

Hi all I am new here so I will introduce myself. My name Anthony and I got myself a Arduino Uno R3 just before Christmas as I have just completed a basic electronics course covering soldering and want to get into projects like this. I am following examples in a book No Stratch Arduino Workshop with 65 projects, and I have come across a project and I am stuck and need advice.

I am trying to do project 4 which is using a push-button to light an LED. Here is the reference sample and circuit diagram and pics: http://www.nostarch.com/download/samples/Arduinows_ch4.pdf.

The only difference is he is using a 4-leg push-button and I am using a 2 leg one. Below is a link to my circuit diagram I created, taken with my phone so it is OK-ish:

http://i8.photobucket.com/albums/a41/acharris05/pictureofmycircuitproject4_zps55157c22.jpg

I know it is something to do with my switch that I am not positioning the components correctly, as I have even had the circuit if I touch the wire going from Pin 7, or move my finger near it, I earth the circuit and make the LED light so obviously I got a open short in the circuit somewhere. I have been on this for 2 evenings now and took it apart many times, so any help is appreicated as I am not confident in reading schematics yets, hence why I am following that chapter in the book. Thanks.

Anthony

Hi Anthony and welcome.

You have put your setup on a breadboard, but you aren't using that breadboard the best way. Mover the switch 3 positions lower so it crosses the gap in the breadboard. While you do that, check that you have the switch in the right orientation (rotate it 90 degrees if necessary). Also you have the yellow wire in grid f43 together with a pin of the switch. Don't do that, you do not need to. You are switching to vcc ("+"), are you sure that is what you want to do ? Also for this test you do not need the capacitor to debounce. You can do debouncing in software so there will be no need for that at all (you'll learn that later on).

I'd say rebuild your setup, move the switch and use other wires from your starterkit. Some of these wires might not be good, that's known to happen.

Thanks for the help and advice. So do away with the capacitor then, and move the switch so that it crosses the board gap, which means rotating it 90 degrees so that the 2 pins go either side of the gap. That sounds like a plan, and I will try that and will update with how I got on with the rebuilding. Thanks again.

I can't be sure about rotating the switch. These switches have 4 legs, or rather 2 x 2. If things do not work, first thing to try is to rotate that switch.

That is where my push-button switch varies, mine only has 2 legs, 1 each end of the switch in the middle, I aint got 4 legs or 2 x 2 legs, only 2 pins to push into the breadbuttons. This is where I must be having the issue, not enough legs. Mine are these mini switches:

http://www.ebay.co.uk/itm/TS-044-Tactile-Switch-Push-Button-Momentary-Tact-Miniature-Mini-Micro-SMT-6mm-/221249798092?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item338383ffcc

Thanks.

You've got enough legs to go. Just haven't come across these switches yet.

You should indeed rotate that switch if you're going to put it over that gap. Once the switch is placed, you'll have 4 more contacts to put your wires in so that should do.

Well I have tried this circuit, and I really cant get it to work with this 2 leg push-button of mine. All I am getting when I position it across the gap, is a open short somewhere, as if I hold the wire going from Pin 7 Adruino to the switch I can make the LED light with me completing the circuit. I think this switch only gives 2 pins, and not 4 and being a single throw switch, I cant run 3 things to the switch.

Sure there must be a way to use this 2 leg switch, to make an LED light like in the circuit above. Thanks.

All I am getting when I position it across the gap, is a open short somewhere, as if I hold the wire going from Pin 7 Adruino to the switch I can make the LED light with me completing the circuit.

Yes that is what a switch does. The 4 leg switches as you call it electrically are identical to the switch you have. If it is not doing what you want you have probably miss-wired it.

It would help if you posted a picture of what you have wired up in a way we could actually make out the wiring from your photograph.

Also put your sketch in your next reply please, next to your new picture. Put it in code tags and show all of it. The link to your project leads to a complete book, and i don't plan on reading it all to find the section you're addressing at the moment. You might have a mistake in there in combination with the hardware setup. So do not copy the text / instructions, but what you've actually got now.

Thanks for your help. I know I have done something wrong, but I cant see for the life of me where. I have included the schematic:

http://i8.photobucket.com/albums/a41/acharris05/schematic_zps85fdb36d.jpg

My circuit and sketch is below. I kept the capacitor in just to show my full circuit design. it is a 10k resistor by the switch, a 560 ohm resistor in line with the LED. The blue wire is from pin 7, and the green is from pin 12. and the yellow link wire is going from next hole to the resistor and linking to the GND. And built like this, if I touch the blue wire, whether it is connected to the breadboard or not, I can cause the LED to light by holding the blue wire. Thanks again for the help.

http://i8.photobucket.com/albums/a41/acharris05/mycircuitlayout_zps8477743d.jpg

#define LED 12
#define BUTTON 7

void setup()
{
 pinMode(LED, OUTPUT); // output for the LED
 pinMode(BUTTON, INPUT); // input for the button
}
 void loop()
{
 if ( digitalRead(BUTTON) == HIGH )
{
 digitalWrite(LED, HIGH); // turn on the LED
 delay(500); // wait for 0.5 seconds
 digitalWrite(LED, LOW); // turn off the LED
}
}

It is hard to see but it looks like the 10K and switch are not wired right. As you only have two legs you have to make sure they are in the right holes in the breadboard.

Thanks for that, that is what I am wondering. Below is a more square on shot, and the pins for the switch are in F17 and E17 holes.

http://i8.photobucket.com/albums/a41/acharris05/betterlayout_zpsf00e8567.jpg

Thanks.

Grumpy_Mike is right. I went to your Photobucket site and selected the picture, after which i was able to see it full size. The blue wire is in grid d30, but the switch is in grid e29, so there is an open line. It is invisible in the picture where the other pin of the switch is, but it's likely it is in f29. It's also invisible to see where the resistor goes, but that seems to be in f30. One side of the capacitor and the yellow wire are in g29 and i29, but if the switch is in f29, it is directly connected to GND The other leg of the capacitor goes to g31, which seems to be connected to nothing (should go to D7 according to the schematics).

So, try this: Put the yellow wire in i31. Put the resistor in j29. Put the blue wire in h29. Put a new red wire in the 5 volt rail and in c29.

This way you will have it connected according to the schematics. And also according the sketch. Try if this works.

Later on, after you got this working, we'll be glad to help you set this same thing up in another way so you can get rid of some components and have the same functionality. But that's for the next exercise.

Edit: This was about the first picture today, the second one is built up completely new and is not the same as the one before. It is important that you keep working the same way. Do not change wirecolors between 2 versions of the same circuit unless you're very sure what you're doing (you also shifted the blue and green wires in the 2nd picture)

Yep it is the wiring. Not only is there nothing connected to one side of the switch, the input should be connected to one end of the resistor with the other end to 5V. Then the switch should be connected to the resistor with the other end to ground.

Don't go so much on the photo in that chapter in fact do not follow it at all, try and follow the schematic and recreate the same topology.

A big thank you for all your help, I followed the above advice and the circuit now works as it should. And by having the circuit now correct, and then looking at the schematic that was in the book I understand a lot more how the diagram works, and how the picture in the book shows the circuit setup wrong on the board, leaving the one side of the switch not connected, like was said above.

Thanks again for help, it has been most appreciated and I be happy to know as well how to set this up another way, but I am happy it is working as I Could not see where the mistake was.