Lesson 5 - 5 second button register bug?

For makers who have purchased an Adafruit Starter Pack, get help with the tutorials here!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
Autronius
 
Posts: 15
Joined: Fri May 14, 2010 6:59 pm

Lesson 5 - 5 second button register bug?

Post by Autronius »

Firstly, thank you so much for the starter kit - it is awesome!

I had absolutely no trouble with the first 5 lessons (0-4), but I'm getting some weird problem counting button pushes.

at first it seemed to work ok, but wasn't perfect as it would continue counting as long as the button was held (my own programming error). Not a problem, all I had to do was time my button pushing to the delay I added (.25 seconds).

When it came time to test out counting up only when the state changes there was consistently a 5 second delay between registering the 'button released' and the 'button pressed'. I thought it was a problem with my code again, but have the same problem when I copied the tutorial code too. (there is no delay() in the code).

Typically it seems like its hanging up on something ('freezing' if you will), because after 5 seconds the tx button on the arduino will flash a bunch of times and it will print out on the screen a whole bunch of times all at once "button just released" "button just pressed" etc etc, even if I only pressed the button once and then waited for 5 seconds. I know later on in the tutorial it talks about mechanical bugs with a 10 microsecond delay, but I'm talking about a full 5 seconds.

The only thing that makes me thing the arduino isn't frozen is that if I touch the resister with my finger (accident the first time...)from pin 2, it streams pressed and released in real time.

I've tried with both switches and the result is the same.

I attached an LED on the board instead of input to pin 2 and when the button is held the led stays on, when I release it goes off just like its supposed to - evidence to me that the button works as good as it is supposed to.

Any Ideas? Thanks in advance!

- Andy

Autronius
 
Posts: 15
Joined: Fri May 14, 2010 6:59 pm

Re: Lesson 5 - 5 second button register bug?

Post by Autronius »

Incidentally, I also noticed that if I just moved my hand close to the unit ( I didn't touch anything!) it consistently triggers it aswell. I can wave my hand all day and it will send data to the serial monitor.

I guess I really do put the 'cute' in electrocute.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Lesson 5 - 5 second button register bug?

Post by adafruit_support_bill »

Strange stuff. Haven't seen anything like your 5-second delay, but I have seen a case where an arduino was susceptible to false inputs similar to what you describe. If I put my finger near any of the wiring, it would register a button press.

The system at the time was powered by a battery pack, and I had the USB connected for programming/debugging. The problem only existed when both the battery pack and USB were connected. If I powered it with either one alone, it worked fine.

Autronius
 
Posts: 15
Joined: Fri May 14, 2010 6:59 pm

Re: Lesson 5 - 5 second button register bug?

Post by Autronius »

I have yet to use the battery pack - It just didn't seem necessary as long as it was hooked up to the USB. I havn't done anything substantial enough to make me want to use it in an independant fashion.

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Lesson 5 - 5 second button register bug?

Post by adafruit_support_bill »

Maybe if you post your code and a photo of your setup, we might be able to spot a problem.

Autronius
 
Posts: 15
Joined: Fri May 14, 2010 6:59 pm

Re: Lesson 5 - 5 second button register bug?

Post by Autronius »

So, I finally got around to re-doing lesson 5 and taking a picture of it, when it refused to cooperate, and instead worked perfectly fine. I went through every example and everything operated as described.

I still have no idea what was giving me so much trouble, but today it all worked out great! It must have just been a segment of code I overlooked, or orienting the button wrong.

Thanks for all the suggestions!

User avatar
kch
 
Posts: 16
Joined: Tue Nov 23, 2010 3:29 pm

Re: Lesson 5 - 5 second button register bug?

Post by kch »

I have not got my starter pack yet, but I can perhaps answer this question in general electronic terms.

Most simple input circuits are wired directly to the input. This leaves the input 'floating' when it is open circuit. You can then get 50/60 hz hum induced on the line when you put your hand near the wire. The device can get confused with this input and register a keypress.

To prevent this, you can pull the input up/down with a suitable resistor. This forces the I/P one way or the other until the switch shorts it out in the other direction.

--
kch

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Starter Pack”