random time

nick12ab

Senior Member
need to set up a random time delay of between 3 to 30 minutes
You need to be a bit more descriptive. What is it for and what will trigger its generation.

If it is triggered by a button press, you could rely on how long the button is pressed for to generate the number since even the PICAXE can do it faster than a human can time it to get the time they want. This is a brief idea of how it could work although I can't guarantee that it will as I'm not sure about conditions for exiting a loop.



A better response will come from someone else.
 

Technical

Technical Support
Staff member
You can use the random command to put a byte (0-255) into a variable (e.g. A). You will then need to scale this and use loops.

As a rough example, take the values 0-30 to mean 30, which makes 3 minute.
Take any other value 30-255 to give you 3 to 25.5 minutes.

So a value of 10 means 1 minute, value of 1 means 6 seconds.

So use a flowchart which is the equivalent of

random A
if A < 30 then A = 30
B = 0

do while B < A
wait 6
inc B
loop
 
Last edited:

driedeker

New Member
What I am after is my program to go into a random wait of 3 to 30 minutes after this time runs then goes into the wait again.
 

Briski

New Member
Hi guys. I'm a massive, massive, massive, massive noob to all this, but I need a little help making a random timer for school.

Basically I'm making a reaction game, and I want the LED to light up at any random time between 3 and 6 seconds

I'd be really grateful if you could give this to me in a flowchart format :)

Thanks!!
 

nick12ab

Senior Member
Look at the Random and Compare (If) commands in Logicator help. Basically, what you can do is use Random to generate a number and use Compares to check that the generated variable is within the limits you want, and if not, generate the number again until it is.
 

Briski

New Member
Look at the Random and Compare (If) commands in Logicator help. Basically, what you can do is use Random to generate a number and use Compares to check that the generated variable is within the limits you want, and if not, generate the number again until it is.
Sorry to be a bit of a pain, but I don't really get how to use the compare function
 

hippy

Ex-Staff (retired)
Sorry to be a bit of a pain, but I don't really get how to use the compare function
Within Logicator, clicking on the Help menu option will lead you to detailed information on each command. Particularly useful are -

Help -> Contents

Help -> Manuals -> Logicator Manual
 

Briski

New Member
Within Logicator, clicking on the Help menu option will lead you to detailed information on each command. Particularly useful are -

Help -> Contents

Help -> Manuals -> Logicator Manual
So how would the compare command work with the random command?
 

nick12ab

Senior Member
You use the random command first then two compare commands as shown below.



You just use the three blue shapes as shown and they're inserted into your program.
 
Top