Hello Arduino friends. I'm new to the forum, but not new to developing applications. So far I have always used Java to develop small applications for the Arduino (UNO).
Now I would like to use a touch pulse to determine the time between the individual pulses (and then the speed from that).
I query the position of the button in the loop, when it is high I note the time until the next time. I can then calculate the time from this (I thought).
But the results are not at all correct. The calculation of v is also incorrect, although Mils and speeTime are correct. here ist my Code in Loop:
Buttons usually do "bounce" (create a number of spikes when pressed or released that are read by the controller as very quick on/off events). So a method of debouncing is required to avoid reading the spikes.
We have to distinguish "event" from "state":
A usual button can be in the state "open" or "closed".
The moment when the button is pressed or released can be seen as almost taking no time, it is an event.
Therefore the function buttonPressed() in this sketch does not return the state of the button, but only "true in the event when the button state changes from HIGH to LOW.
The sketch prints the time between the previous time the button was and pressed and the actual time when it was pressed again.
You wrote that you want to calculate a "speed". What speed do you want to calculate? Speed is (something)/time, what is your (something) ?
Hello,
I'm sorry I haven't been in touch for so long, but I've had a lot of work. I'll test it now and report back. Thanks in advance for the code and the link.
Pfeiffy