Asked
— Edited

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!
@bhouston... Digital will return a value of 1 or 0 (true or false)... whereas 8 bit analog will be something like 0 - 255... So when reading analog you should assume the PIR has been activated if the adc7 value is greater than say something like 100... The number may vary so you will need to test this...
@Richard R, I have tried several different settings - none make a difference. Any other thoughts?
Can you try changing part of your code your code to this?
@Richard R, Tried that at different values - no change
Can the PIR work on the analogue ports? Check it's datasheet (post it's datasheet if unsure). Bearing in mind that the Analogue ports are 3.3v regulated which may not be enough voltage to power the PIR or may cause problems if there isn't enough current available.
If not, you may need to build a small circuit to make it work for ADC.
Try this in a separate script and see what values $pir are giving you... wave your hand in front of the pir detector and see what happens to the value of $PIR
Or add the ADC graph, value or meter control
@Rich... bite me LOL.... Forgot about the analog value control. That's much easier... I have some PIRs from Parallax Inc and I have them working on both analog and digital ports... Saying that however, @bhouston does not have the same PIRs so you may be right, the ones he has may not work via analog...