Go Down

Topic: "Debounce" on Ethernet client (Read 641 times) previous topic - next topic

indergod

Dec 24, 2015, 12:00 pm Last Edit: Dec 24, 2015, 12:09 pm by indergod
Hi,

I'm having issues with the following code, and wondered if anyone could help. The intention is that the code should operate as follows:

- A link to 192.168.0.141/?A is clicked
- The Arduino takes the instruction, and reads the value on the current sensor to see if the bulb is on or not.
- If off (ie reading below "10", then the relay is triggered using the "triggerPin" void. The triggerPin void also includes some code to return the browser to the previous page, so that it is ready for the next input.
- Or, if already off, a message to that effect is returned on the serial monitor.

The problem I'm having is that upon clicking the link, the relay is more often than not (not always) triggered twice. Messages to show that it has been triggered twice also show on the serial monitor.

I wonder whether this might be because the Arduino is seeing "noise" on the ethernet line, or whether there is a signal bounce issue here, although I've only ever seen physical inputs (eg buttons) needing debouncing.

I tried to post the code up here using the code tags, but I got an error message saying the post limit was 9000 characters and that was exceeded. Apologies therefore, but I've had to attach the sketch to this post instead...


NOTE: Upon clicking the button, the following is what appears on the serial monitor....I would have expected the line only to appear once, not twice:

Code: [Select]

?AKITCHEN LIGHT ON instruction received
Sensor reading is: -0.17
KITCHEN Light was OFF, now ON
-------------------------------------------
?AKITCHEN LIGHT ON instruction received
Sensor reading is: 1.72
KITCHEN Light was OFF, now ON
-------------------------------------------


Any help appreciated!!

indergod


SurferTim

Are you certain it is not being triggered by the web browser's request for favicon.ico?

zoomkat

Quote
The triggerPin void also includes some code to return the browser to the previous page, so that it is ready for the next input.
This could also be the issue causing a second request to the server.

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

Go Up