Serial Terminal icon Serial Terminal — PC and EZB serial terminals for ARC: connect, monitor and send text/ASCII to serial devices. Supports COM, flow control, baud, DTR/RTS, hex Try it →

ARC Pro

Upgrade to ARC Pro

Become a Synthiam ARC Pro subscriber to unleash the power of easy and powerful robot programming

#25  

Further to @Rich's timer solution (which is really pretty good)... You could remove $x=0 from the timer script and run just the timer script continually... Since all variables are global you can have $x reset to 0 in all your other active scripts (except for the PIR monitoring script of course)... That way while you bot is awake and doing stuff it keeps the timer constantly set to 0. That is until activity stops and then within 60 seconds (or whatever length of time you choose) the bot will go into sleep mode...

Just an idea...

Author Avatar
United Kingdom
LinkedIn Twitter Google+ YouTube
#26  

$x = 0 is there because if it is run before anything else it will fail as $x wouldn't exist. Unless $x is in the init script.

Also, it isn't a forever looping script so once $x did hit 60 (for any reason) the repeat loop would end and the script would stop. Hence why it needs to be part of a bigger script.

#28  

I feel like a blind man wandering around in the bush at night hoping to find my way home!

So here's where I'm at with this project, I've put some comments in so you can see what I'm trying to accomplish. Any and all help will be appreciated.


:loop
#timer to power down
$x = 0
RepeatUntil($x = 30)
$x++
Sleep(1000)

EndRepeatUntil
repeatUntil(1=2)

#what to do when timer gets to 30

set(D2,OFF)
#$x = GetDigital(D2)
ControlCommand("Script Manager", ScriptStart, "power down")#do this once

sleep(5000) 
WaitForChange(GetDigital(D2))
sleep(5000)

#do this when the PIR is triggered after "power down"

$motion=getDigital(D2)
IF($motion=1) #pin went high
ControlCommand("Script Manager", ScriptStart, "Power up")#do this once
endif

#do this if PIR is triggered anytime after it has powered up

$motion=getdigital(D2)
if($motion=1)
#stay powered up -  need something here - what?
sleep(10000)
EndIf

# if Pir is not triggered in 30 sec start the timer again

If($x = 30)
GoTo(loop)
endif
EndRepeatUntil

Thanks

PS. I would pay money to go to a course somewhere to learn EZ-Robot scripting!