A code for light pulse to control servo

Hello I am new here and browsing this forum for ages now, I need a good basic code where I could build from, because I have been trying some coding now and I have no idea where to start. I need a pulse counter in combination with an analog sensor.

The idea is that light pulses will be send with beamer and according to the frequency (which is about 1hz) a servo reacts accordingly. For sensor I have an LDR.

So the situation is the LDR has an value.

Every second is measured if the value changes a lot so natural light + beamer light (value + threshold) if it changes a counter will count +1

Every 5 seconds is measured what the count is if it is 3 > servo will go to 90 degrees if it is 4 > servo will go to 180 degrees and the counter will be reseted

I saw so many different ways to count I really don't know where to start.

Great thanks in advance!

So the situation is the LDR has an value.

You can read the value using analogRead.

Every second is measured if the value changes a lot so natural light + beamer light (value + threshold)
if it changes a counter will count +1

Use millis() to see what time it is. Record when you take a reading. See if enough time has elapsed to need to take another reading.

If it is time to take a reading, do so, and record the time. If the reading has changed significantly, increment (or decrement?) count.

Every 5 seconds is measured what the count is
if it is 3 > servo will go to 90 degrees
if it is 4 > servo will go to 180 degrees
and the counter will be reseted

Use millis() to see what time it is. Record when you last sent data. See if it it time to send again. If so, send the value, set the time, and reset count.

The idea is that light pulses will be send with beamer and according to the frequency (which is about 1hz) a servo reacts accordingly.

Can’t help you with this. I have no idea what a beamer is, or how to make it send pulses, or what pulses you need to send to make a servo move.