I have a photoresistor thats detecting an LED and I want to count the amount of times the LED triggers the photoresistor. The problem is, when I just use a normal (int) counter, the value shoots up as soon as the resistor detects light.
Now I thought I could just use a boolean that switches from false to true when it detects light over a certain threshold, which works, but now I need to count the amount of times it switches. How can I do that?
Here's some piece of code for better understanding
Look for transitions instead of levels. The state change detection tutorial explains how to do that. Count the times that ticker changes from false to true (positive edge). See also.
oh yeah sure. Thats the intensity of the light which hits the photoresistor. If that value is above 800 (when a laser hits it) it should trigger the counter.