Infrared sensors initialization

Hello all,

I was wondering how to initialize an infrared sensor, as my team wishes to use them for line tracking. It wasn’t very clear how I would go about initializing one, and I’m quite confused.

So far, we have
AnalogInput analog = new AnalogInput(1);
double v = analog.getAverageVoltage();

Programmer 6323

What model sensor are you using? Some are analog, and others are digital.

It’s the QTRXL-MD-01RC Reflectance Sensor Array. Digital.

Here’s a link to the Pololu page.
QTRXL-MD-01RC Reflectance Sensor

As you noted, it’s a digital sensor, so it will connect to a DIO, and be declared as a digital sensor. Here’s the key bullet:

  • Output format: digital I/O-compatible signal that can be read as a timed high pulse

Also, I note from the table that this particular model is recommended for ranges up to 30mm, just a bit over an inch. If you’re planning to look at the carpet, you’ll want to find some way to make sure this doesn’t hit the hab ramp as you drive up and down (perhaps drive up and down backwards from your normal operation).

It looks like in wpilib, you’ll want to use a counter in semi-period mode. I’ve never done that one, but it looks pretty straightforward.