Arduino not behaving properly

Hey guys,

This is my first post here. I have been fumbling my way through this and have made a lot of progress. I have an issue however. I did the debounce switch example the other day to see how it worked and it worked exactly as expected. So today I was going to take a snippet from it for another code I was writing. Instead of the light turning on with one push and off with a second push it would be on [u]while[/u] the button was pushed and off when I let go.

So thinking I had an error in my code, I went back and reloaded the original example and tried that. Same result!

I don't want to write any more code until I get it behaving properly. Is there a way to clear the atmega so that I know I am not getting any residual effects? Is this a problem with the Arduino?

Thanks for any advice. Jeremy

HERE is the tutorial by the way.

Is there a way to clear the atmega so that I know I am not getting any residual effects?

Loading a new sketch completely overwrites the old one.

To confirm that, load the Blink sketch, and see for yourself that pressing the button does nothing.

OK so that's not it. I guess the only other reason would be that the IC is bad? It does everything else that I want it to except for the on/off status of the button. I tried several different pins with the led and the momentary switch, but with the same results.

Why don't you post the exact code you are uploading to the Arduino and let us look it over. It sounds like the polarity of the input reading is beening inverted somewhere in your code.

Lefty

It's in my second post. I am using the tutorial verbatim.

oh, OK. Your first post said "So today I was going to take a snippet from it for another code I was writing.", so I assumed you now had a combination of code you were working with.

Lefty

I did, but like I said in the first post, when I realized it wasn't working I tried just the tutorial sketch and ended up with the same results. I hope I am not coming across as rude because I don't mean to. I just really don't understand why it is reacting the way it is.

It sounds like the switch is wired with a pull-up rather than a pull-down resistor that the example used. Have you double checked that your switch wiring is exactly the same as the example page?

It's wired identically to the tutorial. I have a +5v line to one side of the switch, a line that goes to my input of the arduino to the other side of the switch with a 10K resistor from that side to ground.

Yes, but are you sure the switch orientation is correct? There are two common pins on each side and it is easy to confuse them with the switched pins for that type of switch.