Multiplexing QTR8RC?

I own a QTR 8RC and well 8 pins are becoming a little bit too much for my arduino UNO(will be a standalone ATMEGA328 soon), and I was wondering if I could still keep using the QTR libraries if I do decide to multiplex it. Also I think that the right multiplexer to use would be the 74151 instead of, say, a 74051 because it has digital outputs.

I haven’t really read how the libraries work but I have used them successfully in the past so it would be so much easier if it is possible to use the libraries with multiplexed sensors. Even if the sensor readings aren’t all at the same time I do believe the Mux can cycle quite rapidly.

If there’s also any tips to make them less pins besides multiplexing I’ll be much obliged.

And a slightly unrelated question, could I use only six sensors of the board without breaking it? Particularly using sensors 2-7 so that my board can still be centered.

Thank you very much!


The sensor works by measuring the amount of time needed to discharge a capacitor through a phototransistor below a logic threshold. That is an analog signal, but the microcontroller only cares that it drops below that consistent threshold, so it doesn’t matter whether the logic threshold is that of the MUX (in the case of the digital MUX) or you have an analog mux that simply passes the voltage of the sensor pin on to the microcontroller pin.

However, the GPIO pins on the microcontroller are also used as outputs to charge the capacitor for the sensor, so you must either use a bidirectional MUX or a bunch of diodes on a different GPIO pin to charge the capacitors. Generally, it seems like analog MUXs are more likely to be bidirectional.

Our library would probably provide some basic functionality if you had a bidirectional mux and treated the entire array as a single sensor, but the array specific functions of the library would not work with a mux like that without modification and you would also need to modify it if you used a different output pin to charge the capacitors.

The boards should work just fine if you only use a subset of any of the sensors on them.



Since you are already talking about using a discrete ATmega328, how about adding a second AVR dedicated to sensor processing? Then you could use our library functions on that processor and stream the sensor data out over a single UART pin.