I need help with my light gate project. Unfortunately, because it is for school I can't upload much code otherwise it'll be caught in the plagiarism check.
The problem is:
What I want to do is have the object break the gate, and then Arduino will start a timer, and also start to count how many times the light gate has been broken. After it has broken X times, I want it to stop the timer and show me in the Monitor how many times it was broken.
Currently, it keeps running "0" until randomly without the light gate being broken - it starts counting to 20.
After that it gives me a random number which doesn't even appear to be the correct time.
Any ideas?
p.s. i have checked all my wires and my light gate - they do work.
You didn't show us your code. (Enclose your code in code tags... Click </> on the forum menu.)
You also didn't show us a schematic or tell us what components you're using.
Take it one step at a time... Before you do anything else, make sure you an read the light/no-light condition. You may have to adjust the physical layout (to keep-out ambient light, etc.) and your electronics have to be correct, etc.
Then you can add a counter. You'll probably need some "debouncing" because the program (hopefully) is running very fast and you may get unstable readings when the light is half-blocked for a few milliseconds, etc.
Then add the timer.
Currently, it keeps running "0" until randomly without the light gate being broken
Is that bad??? Is it supposed to read 1 or 0 when the light is unbroken? Ad, what do you mean "randomly"? Is it also randomly reading 1? Does it work better in a dark room?
ReyJ:
I need help with my light gate project. Unfortunately, because it is for school I can't upload much code otherwise it'll be caught in the plagiarism check.
...
Well, then I guess you should figure it out yourself.