Go Down

Topic: randomly activating a solenoid within 15 second time frame (Read 743 times) previous topic - next topic

tylernt

'Random' on a computer isn't really random. Each time you reset the Arduino, it will play back the same "random" sequence again. You will want to use the randomSeed() function and some source of entropy -- entropy can come from an analogRead on an unconnected pin, or from micros(), or some other way.

stivheys

ok, i thought i may need to random seed is it just a case of changing randomnumber to randomSeed in the loop?

tylernt


ok, i thought i may need to random seed is it just a case of changing randomnumber to randomSeed in the loop?
No, random() stays the same. randomSeed goes in setup().

Here are the links to the documentation:

http://arduino.cc/en/Reference/Random
http://arduino.cc/en/Reference/RandomSeed


Go Up