Society of Robots - Robot Forum
Software => Software => Topic started by: Dscrimager on December 07, 2008, 05:32:55 PM
-
I hate to waste an analog pin on a digital PIR but I need to hook the sensor to regulated (not battery) power since I'm using 6 V in and it will only take 5V max,...
I have my PIR hooked to K7 AKA analog 15 ( which is by default an analog pin) what do need to include in my program so that one port is digital not analog?
I looked in SofR_UTILS.h and found a comment about making an analog port digital but couldn't discern the correct example...
I assume then I can read with :
(bit_is_set(PINK, 7)
for a device that will go high when active.
BTW, LOVE the AXON! Finally, plenty of memory, UARTS, pins, interrupts, etc. Great library to work with as well!
Thanks
Doug
-
Look at my example of using a Parallax Ping sensor which is also digital. The link is in my signature.
-
Thanks for the reply, I looked at the code and I still don't see how to turn an analog in pin into a digital in pin,.....
-
digital just means 0's and 1's. Just don't run it through the ADC and you've got it.
-
A few other options:
plug sensor power into the regulated ADC line, but the sensor output into a regular digital input pin
or use this pseudocode:
if(ADC>127)
do X;
if(ADC<128)
do Y;
Instructions to change pin configuration are in SoR_Utils.h