I'm looking to build a device (controlled by an arduino UNO or similar) to rotate a pistol target on a pole 90 degrees (or a quarter turn) towards the shooter and then back away 90 degrees again at (semi) random times.
The project will use a servo controlled by the arduino to perform the turning of the target.
The idea is that the unit will turn a quarter turn towards the shooter at semi random intervals between say 5-15 seconds, holds for 10 seconds (to be fired at) then turns back waits between 5-15 seconds (randomly) and repeats on a loop ad infinitum.
As a beginner I'm struggling to find an example of similar code that will achieve this random time function. I've done a fair bit of searching for a similar project online, but whether it's a lack of understanding or not I've so far drawn a blank (pun intended).
Any help or ushering in the right direction as far as a similar project to learn from or coding would be much appreciated!
You might want to start by modifying the [u]Blink Example[/u], something like this:
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay( random(5000,15000) ); //Hold LED on for between 5 & 15 seconds
(There's actually a 1 millisecond "error" in that code. )
Now normally... We like to avoid the use of delay(), especially delays longer than a couple of milliseconds. But in your case, you don't need to do anything during the delay time (I think) so you'll be OK.