Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by JustinRatliff!

Pir Script

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


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.


AI Support Bot
Related Content
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
United Kingdom
Here's a simple example to test your PIR sensor...


If (GetDigital(D0) = 1)

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


Print ("On")
Sleep (2000)

Hope that helps.
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
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.
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
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.
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...
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.
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.
United Kingdom
Have you tried adjusting any settings on the PIR itself? Most (not all) sensors have some kind of adjustment that can be done by turning a knob or using a screwdriver (potentiometer).

User-inserted image
Do you have a link for "TotalRobots", I could not find them from a google search.

Not all PIR have the adjustment potentiometers like SteveG pictured. The kind he pictured is probably the standard type now, but there are older ones still being sold that don't have the pots and in documentation suggest having a pull up or pull down resister. I'd really like to see the exact PIR you purchased @R1D1. If you can't find a site link to the product can you post a pic of your PIR if SteveG's advice does not work?

@RichardR, I'm surprised the Parallax PIR's run on 3.3 volts. That's handy to know! :)
@R1D1 Try it on an analog port (since it is an old PIR version).... see if the voltage changes with motion.... Also I was referring to the ezb's signal pin being only 3.3v... that may have something to do with why it won't work ....

User-inserted image
@RichardR, that makes sense, you have the revB that works in the lower voltage range.
Here is a picture of the sensor. There is no place to make any adjustments. I was however able to dig up some old notes that came with it saying that if it always indicates that the sensor is activated, then to connect a 10k resistor between the signal wire and ground. So now I've got to see if I've got one laying around, as Radio Shack is no longer!

User-inserted image
Unfortunately, too much secular work right now. I will try to wire up the resistor this weekend and post as to whether or not this was successful.

Thanks for all of the input so far.
@R1D1, if you can't find a 10K resister let me know and I'll mail you a few for free. My email address is in my profile.
I appreciate the offer for the resistor Justin. I found two 5.6K 's. So I could put them in series and be pretty close. Think there is any harm in being 1.2K off?
I don't think there will be any harm to try it. My guess is it will work, but it is possible it could be too much resistance to allow the sensor to trip or it might not be optimal, but certainly no harm.
Well, finally got some time to play with this again. I grounded the signal wire with two 5.6k resistors in a series and that did the trick! Finally, seeing a spark of life in my project. Thanks so much for your input. All of you were helpful. Hopefully I'll be able to add to the discussion in time.