delay command

Chris Danckert

New Member
Hi, I'm fairly new to picaxe and don't have a lot of experience. I have a project that requires a motor to turn several revolutions once a day. My problem is getting a delay time for that long period of time. Any ideas please.
Chris
 

AllyCat

Senior Member
Hi Chris,

Welcome to the forum. A typical method is to use nested loops, for example:

Code:
symbol seconds = b0
symbol minutes = b1
symbol hours = b2
for hours = 0 to 23
	for minutes = 0 to 59
		for seconds = 0 to 59
			pause 1000       ; One second
		next
	next
next
Or with M2 PICaxes, the "time" variable is very useful:

Code:
time = 0
do : loop until time = 43199	; 12 hours in seconds
time = 0
do : loop until time = 43199	; Another 12 hours
You can try those in the simulator by making the numbers a lot smaller. ;)

Cheers, Alan.
 

rq3

Senior Member
Hi, I'm fairly new to picaxe and don't have a lot of experience. I have a project that requires a motor to turn several revolutions once a day. My problem is getting a delay time for that long period of time. Any ideas please.
Chris
Here's a short macro that will let you just plug in the delay you want in minutes:

Code:
#macro timer(minutes)            ;define timer macro
    for w0=0 to minutes
        wait 60                                  ;delay 60 seconds
    next w0
#endmacro
So, if you want a 24 hour delay, somewhere in your code would be:

timer(1440) ;delay 1440 minutes (24 hours)

Of course, the drawback to this is that the picaxe won't be doing anything else while it is stuck in this 24 hour loop!
 
Top