Sparky wrote:As for your test setup, can you measure the latency of your setup responding to the LED it illuminates?
Yes, I was thinking about that, to determine the deviation. But I don't know what's the deviation of LEDs themselves, like, in what time range LEDs light up? Is it, let's say, 10.5-10.75 ms or is it 10-15 ms? Of course, different LEDs have different 'light up deviation'. So which one I would want to use to test deviation? There are like over9000 models of them.
In
LM393 datasheet it says response time ~1.3 us. I've also read that if you go deep enough you can get Arduino to measure with a precision of 125 ns or something. I wanted to use TCS230 color sensor, it said in
datasheet that it has 100 ns response time. But I couldn't find it in the local stores.
I think any deviation/latency below 1ms isn't that important, IMHO.
Sparky wrote:Is there any change if you delete those "delay(0);"s?
Yes, it glitches out for some reason and 50% of the time I get the same results as with delays but then I get 0 or 150-200% bigger number than average. So results would be something like: 0-55-0-56-0-57 or 56-101-58-102-57-101. Sometimes it would glitch out 1 time after another(glitched-normal-glitched-normal-glitched-normal) and sometimes it would glitch out only once in few measurements or multiple times in a row.
I thought it was a problem with Arduino code but as soon as I added delays bug disappeared.
I was trying to find my mistakes in the code for an hour or two and then I remembered all of that debouncing stuff and how they all recommend to wait a little after you take a measurement(or press a button). So I added little delays and it started working properly. I don't know why, I wanted to ask that on Arduino forums myself.
Sparky wrote:The map is earlier in this thread: viewtopic.php?p=15665#p15665
Thanks.