Switch keeps shorting Arduino/USB?

Hey guys, I've been able to use my breadboard to make a series of LED's light up, and I made a "Roulette" sort of game, where it spins through the LEDs and such.

Now I have been trying to use push-button switch, but no matter what I have tried, I keep shorting it apparently. When I press the button, Windows displays an alert saying "A USB Hub has gone past it's allowed current" or something to that effect. Then the arduino stops responding until I unplug/replug it.

I have no idea why, I have tried following the tutorial, but I just cant seem to get it to work.

I know the switch works fine, because I was able to make a quick circuit with the arduino, connecting pin 9 to one part of the switch, a LED to the other pole, then the LED to ground, and it works fine.

Here are some pictures of my set-up... this is driving me crazy! :stuck_out_tongue:

The wire on pin 2-

The 5V and GND wires-
(They are in the right spots, the angle makes it look weird)

The 5V and GND into the breadboard-
(The white wire jumps it to the adjacent red wire, going to my switch)

The wires going to the switch-

After the switch-

The left-hand red wire is after the switch. The orange jumper leads to a 10KOhm resistor.

The resistor and purple wire-

I think this is where I am messing up, at the last part.
The green wire directly after the resistor leads to digital pin 2, and the purple wire jumps to the "-" part of the breadboard. Directly below the purple wire, after it jumps, is a green wire going to GND.

PS- Yes, I know I should use correctly/diff colored wires, but these were the only colors I had to use at the moment.

How about one photo that shows the whole setup??

Don

I know the switch works fine, because I was able to make a quick circuit with the arduino, connecting pin 9 to one part of the switch, a LED to the other pole, then the LED to ground, and it works fine.

Without a resistor, the LED is not going to be "working fine" too much longer.

If I follow these two correctly...

...you've wired the button across +5 and ground. Pushing the button causes a dead short.

Does this help...

Wire the Arduino pin to the resistor. Then the resistor to ground. This creates a pull-down resistor. If you read the pin, it will read LOW.

Leaving the circuit above in place... Wire the Arduino pin to the button. Then the button to +5 V. If you close the button, you create a complete circuit THROUGH THE RESISTOR.

Okay, I understand about the pull-down resistor, but you said wire the arduino pin to the resistor. I assume you mean digital pin 2, wired to the resistor. Then you also said wire the arduino pin to the button. What do you mean/how do I do that, if the arduino pin is already wired to the resistor?

Also, for the LED, I have been using them for a while without resistors, and they are fine. They don't need any resistors actually, according to their data on the back of the package.

make a T http://francisshanahan.com/index.php/2009/what-are-pull-up-and-pull-down-resistors/

and yes led's need resistors, but thats not to say they dont have one biult in, which is rare unless its in some sort of mounting (like radio shack sells some that are panel mount, and they are in a colored case with 2 soft wire leads popping out, one has a resistor inline for 12v car application)

Wire the Arduino pin to the resistor. Then the resistor to ground. This creates a pull-down resistor. If you read the pin, it will read LOW.

Leaving the circuit above in place... Wire the Arduino pin to the button. Then the button to +5 V. If you close the button, you create a complete circuit THROUGH THE RESISTOR.

So, I just tried this, but I realized I accidently wired the GND pin to Digital Pin 13. When i close the switch, the LED on pin 13 comes on, and the digitalRead(2) returns 1, which is correct. However, when I realized this mistake and moved my ground wire to the GND(right above pin 13) when I close the switch i keep shorting it.

Someone said to "make a T". I believe I did, but maybe I did it wrong?

I'll go ahead and describe my setup, using co-ordinates on the breadboard. (Don't have camera right now)

(A-E is the column, 1-30 is the row)

Digital Pin 2 is connected to A-18.
One leg of the resistor is in B-18.
Other leg connects to B-24.

Then, to the immediate RIGHT of the B-24 leg of the resistor, is a wire in C-24 connecting to the GND right below the +5V.
To the immediate LEFT of B-24 leg of the resistor, is a wire in slot A-24 connected to one part of the switch. The other part of the switch is wired to +5V.

Apparently I am an idiot at this, and rather than go through every possible permutation of wiring ( and fry my arduino ::slight_smile: ), I figure I would seek the advice of the almighty arduino-gods. :stuck_out_tongue:

5v----button--digital input--resistor--gnd

or

5v--resistor--digital input--button-gnd

The first reads low until you press the button, the second reads high until you press the button. There should always be a resistor between 5v & gnd.

Third option is just wire a button between digital input and gnd and enable the internal pull up on the digital pin. The code can be a bit confusing for a noob though.....

The code can be a bit confusing for a noob though.....

Not if they stand on their heads while they write the code.

Lefty

The code can be a bit confusing for a noob though.....

I may be new to the wiring/electronics part, but I have no problems with coding/understanding code, especially the arduino code, as it is relatively simple.

I still don't understand how to do the first option you mentioned-

5v----button--digital input--resistor--gnd

I see how to get from 5V to button, but from the button's legs, how do i make it go to the digital input to the resistor?

Use one of the commoned tracks on the breadboad with one socket connected to the button, one with the resistor and one with a jumper lead to the digital pin.

5v--button----resistor--gnd
|
|
digital pin

if thats clearer

If you're happy with coding, enabling a pullup is a matter of declaring a pin to be an input and then writing it high. 2 lines in setup. Then its a just a button between the pin and ground. Its high until you press the button.

Thanks.

I'm going to try doing it the non-coding way so I can understand it better though.

Woohoo, it worked.

Thanks you guys.

Now that I have already established myself as a complete idiot, I can't go any lower when I undoubtedly return to ask another question! :smiley:

Now that I have already established myself as a complete idiot, I can't go any lower when I undoubtedly return to ask another question!

Not a compete idiot, just been corrupted and isolated in a software only world to long. Welcome the the reality we call electronics. :wink:

Lefty

Thanks for sticking around for the confirmation, nothing worse than providing a solution and the poster is never heard from again. :slight_smile:

Haha, havne't released the magic smoke from anything (arduino related) yet....

Almost let the smoke out on a $2000 cRIO once.... thank god for insulated wires... Only melted the insulation off, but scared the crap out of me, seeing smoke come from it. :stuck_out_tongue:

Is this the time to bring up the issue of switch bounce ? :wink:

Is this the time to bring up the issue of switch bounce ?

Not a good idea, most software only guys can only handle so much reality in a single day.

Lefty

That hurts my feewings. :cry:

Is switch bounce what could be causing my...interesting... results?

I have my code set to, if the digitalInput is HIGH, to turn on the LED on pin 13.

However, even when not pressing the button, the light will flicker on/off.

Sometimes if I even tap the wire going to the input, or even hover my finger over it, the input will turn high. =/