Quote:
Originally Posted by Generalx5
How do I set the digital inputs to low on default?  I'm using an optical sensor that inputs voltage when it senses an object, I'm using this on the EDU Mini RC, so is there a solution to setting it low? the sensor doesn't work like a switch so it doesnt short the Sig to Gnd.
 Also how do you printf the Analog inputs? I have 3 analog channels and this is how I printf mine:
printf("rc_ana_in01 %3d, rc_ana_in02 %3d, rc_ana_in03 %3d\n",(int)rc_ana_in01,(int)rc_ana_in02,(int)rc_a na_in03),
Is this correct? because im getting readings that look like this:
rc_ana_in01 135, rc_ana_in02 143, rc_ana_in03 151
so please help me out. Thanks!
|
First up, you're probably going to need an inverter for the sensors, they sell them in a little chips at Radio Shack (hopefully). The digital I/O lines are hardwired to be pulled high unless grounded I believe, can someone else confirm this?
As far as the analog inputs, those variables are actually addresses used by a function to sample the ADC, this function is Get_Analog_Value(). It should used like this:
Code:
printf("rc_ana_in01 %d, rc_ana_in02 %d, rc_ana_in03 %d\n",Get_Analog_Value(rc_ana_in01), Get_Analog_Value(rc_ana_in02), Get_Analog_Value(rc_ana_in03));
Good luck!
EDIT: Also, Get_Analog_Value() returns the value of the ADC you choose, so you can store the information in a variable for use later like this:
Code:
unsigned int sensor_var;
sensor_var = Get_Analog_Value(rc_ana_in01);