Author Topic: Another Noob question on analog pins - AXON  (Read 2233 times)

0 Members and 1 Guest are viewing this topic.

Offline DscrimagerTopic starter

  • Full Member
  • ***
  • Posts: 57
  • Helpful? 0
Another Noob question on analog pins - AXON
« 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

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: Another Noob question on analog pins - AXON
« Reply #1 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.

Offline DscrimagerTopic starter

  • Full Member
  • ***
  • Posts: 57
  • Helpful? 0
Re: Another Noob question on analog pins - AXON
« Reply #2 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,.....

Offline pomprocker

  • Supreme Robot
  • *****
  • Posts: 1,431
  • Helpful? 16
  • Sorry miss, I was giving myself an oil-job.
    • Nerdcore - Programming, Electronics, Mechanics
Re: Another Noob question on analog pins - AXON
« Reply #3 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.

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Another Noob question on analog pins - AXON
« Reply #4 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

 


Get Your Ad Here

data_list