View Single Post
  #341   Spotlight this post!  
Unread 06-02-2008, 21:16
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: New C18 3.0+ Compatible FRC Code

Quote:
Originally Posted by RyanN View Post
I also tried the quick_adc, but I was having trouble, so I went back to this...
You just use a number from 1 to 16 to select the ADC channel. As an example:

liftpos = Get_Analog_Value(1); or liftpos = Quick_ADC(1);

Of course you'd probably want to #define these values in a header file and then the code would look like this:

// this goes at the top of the source file or in a header file like robot.h
#define ARM_ELBOW_POT 1 // analog input one
#define ARM_WRIST_POT 2 // analog input two

unsigned int elbow_pot;
unsigned int wrist_pot;

elbow_pot = quick_adc(ARM_ELBOW_POT);
wrist_pot = quick_adc(ARM_WRIST_POT);

Because it's simpler, I would use quick_adc() if you're only using potentiometers on your 'bot.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org