Arduino Timer Calculator
Arduino timers are tricky to set up, because they involve configuring registers on the AVR chip.
There is a great Arduino Timer calculator that writes the code for you here !
Here is what is looks like. We specify the time interval in Hz (f=1/T), for example, 2 seconds = (1/2) = 0.5Hz
However, the more common use case is that we want to run something every N seconds. In this scenario, we would set time period to 1s or 1Hz.
The code that is produced follows:
You put the code you want to run every second inside Line 33 in the code above.
Now if you want to run some code every 30 seconds, this is how you would modify the code above
Try it out on TinkerCad circuits. I did
Leave a Comment