I do not understand your questions fully, but I will try to answer them the best I can. The function you want to use to read an analog voltage is analog_read. The value of the result is described in the command reference. Unfortunately, there are only three available analog inputs on the 3pi and you are already using two. The other one to use is ADC6, but you have to give up battery voltage monitoring.
If i was reading some of 3pi ams and would have to desconetar the ADC6.
And my question was that I can read function used with the sensor connected ADC6 for reading when detecting the white or black, what are the simplest functions that I have read I can use the library functions lotengo 3pi but not very understood.
Sorry, if you asked any specific questions in your last post, I didn’t understand them. If you have any additional questions, can you try rephrasing them and elaborating?
Well I’m making a robot using the “3pi” and I need to connect a “QTR-1A Reflectance Sensor” additional connected to pin ADC6, my question is what function (program) I need to use to get the result of black or white?
set_analog_mode(MODE_10_BIT); // at the beginning of the program call this once
unsigned int reading = analog_read(6);
if (reading > 800)
{
//black
}
else
{
//white
}
I picked 800 somewhat arbitrarily. You will need to calibrate it for your application. The point is that high values will be blacker (less IR received) and low values will be whiter.
Thanks for the help!
Could I do it the same way with a QTR-1C?
The 3pi only supports maximum voltage 6v I could not adapt a battery “7.4v” or maximum “9v”?
No. With either sensor, you need to do what is described in the product page to use it. Please see the product page for the QTR-1RC for details on how to use it.
The 3pi is designed to be used with 4 x AAA NiMH or Alkaline cells, the battery voltages you are describing are not within spec.