Multiplex QTR-8RC line sensor

Hello, I've got a QTR-8RC line sensor but it uses a lot of pins (8 for the sensors + 1 for de led's) So i figured there should be a way to multiplex it. But couldn't find one. The main problem is it uses the digital pins as both input and output. Is there anyone who has an idea of how to multiplex it ?

Maybe an analog multiplexer like the 4051. It needs 3 lines to do the addressing for 8 io and 1 for the enable (which can be be hard wired to be always on thus eliminating that one pin). You have one common io that goes to your arduino and the other 8 go to the sensor board.

I've tried but it doesn't work... the problem is the outputs doesn't latch, so if you select another output the other ones go back to low. Is there anyone who has a solution for this problem ?

Doesn’t latch?

Have you actually got it to work without the multiplexer? Do you know how this sensor works?

Basically you set the pin of the arduino to an output then drive it high to charge the capacitor of the QTR then switch it back to an input ( you would also need to turn off the internal pullup on the pin) and see how long it takes to go low depending on how much light is reflected back to the sensor.

With the 4051 which is just a bi-directional switch you would first set the address of the sensor that you would want to look at then do what I described in the last paragraph. This only looks at one sensor at a time but the process can happen pretty fast.

The sensor type you have was meant for processors that do not have an analog input capability (like the basic stamp) which use the time of discharge to figure out the analog value.

There are other analog switches that can look at more than one at a time. I just gave the one that would take the least amount of pins (4) to read 8 sensors.

Maybe a slick way to do it would be to use a pin change interrupt to sense when the pin has gone low and just cycle thru them in the interrupt and that would let you do other things instead of sitting in a timing loop.