Hi all, I'm new to Arduinos but I did get a kit and have completed some of the very basic projects that came with it. I now have a project that I'd like to build and I'm hoping that an Arduino might work for it. I'm looking for someone to tell me if it will, and possibly help me out.
I want to turn on a motor randomly.
I'm hoping to turn on the device, then it will start the motor for a set amount of time, (a few seconds or so) then turn off for a random amount of time. (Ideally, that time would be from 1 minute to 30 minutes) then repeat.
Is this something that an Arduino should be able to accomplish?
And if so, what other components might I need? I can handle triggering the motor part of the electronics, but I need help getting a random signal to occur.
I want to learn how to write the code but would love some help in it if possible.
There is a keyword random(). It produces a (pseudo) random number. So that's not going to be a problem. See Random()
Other than the Arduino a motor driver (or a MOSFET if the motor only turns one way) should be all you need
Steve
It depends on exactly what kind of random do you want:
-
Cryptographically secure random.
-
Repeatable sequence of numbers so tests always come out the same.
-
Looks random to an observer.
These options are listed in decreasing order of randomness.
Option 1 is understandably difficult. But you can get pretty close to it with regular Arduinos and the randomSeed() function. Some of the more advanced ones have dedicated hardware modules inside the chip to do this.
Option 2 is very simple with the Arduino random() function.
Option 3 is actually very difficult because tossing a coin 4 tails in a row seems like it should be very rare but it happens quite often with truly random tosses.
MorganS:
Option 3 is actually very difficult because tossing a coin 4 tails in a row seems like it should be very rare but it happens quite often with truly random tosses.
I suspect that random() plus randomSeed() achieves Option 3 for the vast majority of (not all that observant) observers.
Steve
Thanks all. Looks like it should be a simple project and a good one to help me learn. Any of the 3 above choices are fine for what I need. I'll start on it.