Congratulations Richard R, for answering the question and has received an EZ-Credit award! Share what you have learned and create a tutorial to help others by clicking here.

Trying To Use An Adc Port For Pir

Assistance Requested

Help bhouston with their question and receive $10 of EZ-Credit to get more robots and parts from our store. The following information was provided about their previous efforts searching tutorials for a resolution.

bhouston claims to have checked these sources:

I am trying to use an ADC port to get the signal from a PIR sensor.

I have in my script:


$PIR = GetADC(A7)

and I get this error message;

Error on line 26: Missing String Quotes or Invalid Expression: A

Is it possible to use this port for this purpose?
If so, what is the proper syntax to use it?


I have found a few conversations, tutorials and activities that may help with your question. Take a look at these links. I've sorted them by what I believe to be most relevant but that is not always the case as I'm still learning.

Also, consider reviewing the Learn section for informative lessons and activities. Check it out!


Your syntax is incorrect, see below




What PIR are you using?... The one I have use digital, but they also will work on an analog port as well...


Thanks Richard, I am using a Radio Shack PIR


It should work on analog as well... but remember analog unlike digital (1 or 0) will report values between 0 and 255... So (you have to test this) a value of above 100 might indicate the PIR has been triggered... Like I said you have to test this with your PIR... I have a Parallax PIR and when I use it on analog it activates with a value of around 40 or so is reached... It is meant for digital, but it does work on analog as well...


If the value RX is a 10 you'll receive that error. If you TX from the EZ B 34,40 or 92 you will again receive an error.
DJ knows about this I don't know if he's had a chance to look into it yet.


@mtiberia ... Ummm we're talking about a PIR detector on a digital and analog port not anything related to serial or the UART port....


I know but the issue shows up when trying to save to a file as well. I'm returning from out of town but if my guess is right it will show up when reading from a ADC port as well. I'll test it when I get home.


My bad, downloaded the latest issue of EZ Builder and can now RX all unsigned integers 0 to 255. The only issues remaining are TX or saving 34,40 or 92 and that is the subject of a different post.