I'm trying to make a delay on timer with a random delay time.
I've been trying the random() function with & without the randomSeed() function. My problem is the board is in an electrically quiet location and reading an unconnected analog port gives back the same value each time; this makes the random() function start at the same place each time at turn on ie return the same value.
Any ideas please?
Don
I would use a cheap temp sensor to provide an anolog signal to read.
Attach a few inches of bare wire (sticking up into the air) to the analog port, and you should get random values. Make sure that INPUT_PULLUP is not set for that port pin!
Alternatively, you can ask the user to push a button at startup, incrementing a variable until the push is detected.
something like:
int loopcount=0;
void setup() {
while(1) {
loopcount++;
if (button_is_pressed()) break;
}
}
Maybe use a formula to manipulate epoch time? Still new to the arduino. So, maybe it's not feasible. But epoch would never be the same. Just a thought.
Here you go:
thanks for the ideas, tried a 6" wire on the pin, does give a variation after multiple operations. typically half dozen the same then changes - can live with that, it's only a child's toy. (the Hot Potato game)