USA
Asked — Edited
Resolved Resolved by JustinRatliff!

Pir Script

I'm trying to read the status of a PIR detector using:

getDigital(D0)

but it is always showing the the port is high, whether something is in front of it or not. Do I first have to designate that the port is in input port, and if so, how do I do this? If that is not the issue, any suggestions?

Thanks for anyone willing to assist.

R1D1


ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

United Kingdom
#1  

Here's a simple example to test your PIR sensor...

If (GetDigital(D0) = 1)
  Print(detected)
EndIf

And here's a quick example I used to test my PIR sensor a while ago...

If(getDigital(D0)=1)
Print ("On")
Elseif(getDigital(D0)=0)
Print("Off")
Sleep (2000)
Goto(start)
Endif

Hope that helps.

#2  

If your port is always high then either your PIR is not working, wired incorrectly or won't work off of 3.3V .... The ezb is not an Arduino so you don't need to designate the port as an input or output....

United Kingdom
#3  

One other thing to add, does your PIR have a potentiometer on the back? If so, that might need adjusting. The one I use has two, one for adjusting distance, and one for light sensitivity which had to be adjusted.

#4  

The PIR unit's I own require 5 volts. If you can send us a link to the PIR unit you are using we can check the specs.

United Kingdom
#5  

As Justin stated, some PIR sensors require 5v like the one I use as well, so it may need a regulator depending on you EZ-B power set up if you don't use one already, v4 ground and Vcc pins via regulator, and signal to digital out on PIR. I wanted to add one thing further, some PIR's have DO (digital out) and AO (analog out) pins, so of yours has these pins, make sure your using DO on a digital port.

#6  

I have Parallax PIRs and they work fine off of 3.3v.... I have one in my inMoov as we speak... not all PIRs need 5v...

#7  

I bought the unit from TotalRobots about 5 years ago, but never used it, so while it is not new, it hasn't been used before. TotalRobots advertises it simply as "Passive Infrared Motion Sensor". The document I got with it says it should be powered from 5 volts.

My EZB runs off a 6 volt nimh, and I have an inline 5 volt voltage regulator between the sensor and the EZB.

I used code just like the first example above, except my output was for speech, instead of print, sleep 10 seconds and check the status of the pin again, but I can point it at the wall and it just keeps indicating the pin is high every time.

#8  

I should add that the documentation says when it does not detect anything it puts out < 0.8VDC. If it does detect something it puts out >2.5VDC.