Society of Robots - Robot Forum

Software => Software => Topic started by: Dscrimager on December 07, 2008, 05:32:55 PM

Title: Another Noob question on analog pins - AXON
Post 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
Title: Re: Another Noob question on analog pins - AXON
Post by: pomprocker on December 07, 2008, 07:19:59 PM
Look at my example of using a Parallax Ping sensor which is also digital. The link is in my signature.
Title: Re: Another Noob question on analog pins - AXON
Post by: Dscrimager on December 07, 2008, 08:16:35 PM
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,.....
Title: Re: Another Noob question on analog pins - AXON
Post by: pomprocker on December 08, 2008, 12:01:05 AM
digital just means 0's and 1's. Just don't run it through the ADC and you've got it.
Title: Re: Another Noob question on analog pins - AXON
Post by: Admin on December 08, 2008, 08:20:28 PM
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:
Code: [Select]
if(ADC>127)
   do X;
if(ADC<128)
   do Y;


Instructions to change pin configuration are in SoR_Utils.h