Go Down

Topic: Button Press Debounce Problem, when used Serial (Read 4934 times) previous topic - next topic

wayoda

Hi,
did you verify that the Led connected to pin 12 works. ?

Put this into your setup() function
Code: [Select]

digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
delay(1000);


You have the onboard led on pin 13. Use it to verify that your loop() function is called by blinking it, the same way i did it with the led on pin 12.
put this into your loop() function
Code: [Select]

pinMode(13,OUTPUT);

Put this at the top of your loop() function
Code: [Select]

digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
delay(1000);



Tell us what you see..

Eberhard


vxir

Yeah, Eberhard is smart to take a divide and conquer approach.

We cannot guarantee that the code is getting past the while loop that is waiting to recv data.  His comments will prove or disprove that and therefore point us to a problem in the OLED code or a problem with the button.

I'm going to jump ahead tho and ask you to describe how the button is connected... did you connect pin 2 to one side of the button and the other side to ground?  (That will not work erratically...)


matinzk

This works in Setup()

Both set on pin12 and pin13 for the LED. If I put before the "OLED_Init();"

digitalWrite(ledPin,HIGH);
delay(1000);
digitalWrite(ledPin,LOW);
delay(1000);
--------------------------------

When I do the above in loop(); it works if I get rid of the "OLED_Init();" but doesn't if "OLED_Init();" stays there.

The button is conneted the correct way. Reason why I am 100% sure is that when I so a very simple button push program it works perfectly. When I mix it with OLED code it doesn't work! This is what the problem has been from the begining.

M.

wayoda

And this is what I sugessted from  the beginning:
OLED_init() does never returns therefore setup() never returns and in the end  loop() is never called, so the button is never checked.

My last suggestion to this topic is to remove the call to
OLED_GetResponse(); in setup() and see what happens.

Eberhard

vxir

@matinzk

"The button is conneted the correct way. Reason why I am 100% sure is that when I so a very simple button push program it works perfectly"

I'd recommend that you learn how to present data not your opinion.  That you are 100% sure is not relevant.  You are asking for help.  If you can't be bothered to take the time to state what you think the correct way is, why should we be spending all this time thinking abt your proglem.  In this case, if the pin is "floating" proximity to a driven  pin could affect the float level.  Inclusion of the serial drives pins and could influence proximal pins.  This is why I asked the question.

Regardless, there's no point chasing this unlikely case when in fact this bug is pretty obviously what Eberhard 1st suggested.  I just got fooled by your obstinacy.  Loop() is never being run.

Good luck...

matinzk

Quote
And this is what I sugessted from  the beginning:
OLED_init() does never returns therefore setup() never returns and in the end  loop() is never called, so the button is never checked.

My last suggestion to this topic is to remove the call to
OLED_GetResponse(); in setup() and see what happens.

Eberhard


I will try this and will let you know.

Thanks.

matinzk

Quote
"The button is conneted the correct way. Reason why I am 100% sure is that when I so a very simple button push program it works perfectly"

I'd recommend that you learn how to present data not your opinion.  That you are 100% sure is not relevant.  You are asking for help.  If you can't be bothered to take the time to state what you think the correct way is, why should we be spending all this time thinking abt your proglem.  In this case, if the pin is "floating" proximity to a driven  pin could affect the float level.  Inclusion of the serial drives pins and could influence proximal pins.  This is why I asked the question.

Regardless, there's no point chasing this unlikely case when in fact this bug is pretty obviously what Eberhard 1st suggested.  I just got fooled by your obstinacy.  Loop() is never being run.

Good luck...


I never said I'm not bothered!

Go Up