2
\$\begingroup\$

I have seen a couple of videos and instructables where people have created a matrix of LEDs controlled by photodiodes/photoresistors inside coffee tables, so that when you put your hand over the table or put a mug down, the lights under the object light up.

I want to take this to the next level by controlling the matrix with a microcontroller. Reason being: I can do even more with the matrix, maybe turn it into a VU meter or do cool light shows.

Here is what I was thinking:
A 9x5 matrix of LEDs (blue) with a 8x4 matrix of sensors (photoresistors): enter image description here

I have a couple of PIC microcontrollers with 36 I/O pins lying around plus some other smaller ones. I haven't used PIC MCs before so I thought this might be a good project to use them for.

Do you have any recommendations for the controller design? Maybe I could use 2 MCs, one for the LEDs and one for sensors? Maybe just use one MC and use demultiplexers to switch in the many sensors?

Lay it on me fellas!

\$\endgroup\$
  • \$\begingroup\$ Which PICs do you have? \$\endgroup\$ – Olin Lathrop Aug 8 '11 at 21:14
  • \$\begingroup\$ I have 2 PIC16F1519s and 2 smaller 8-pin ones..i don't remember the part# \$\endgroup\$ – Shubham Aug 9 '11 at 15:40
  • \$\begingroup\$ LEDs can be used as light sensors, too. \$\endgroup\$ – endolith Aug 9 '11 at 15:51
  • \$\begingroup\$ Interestingly, LEDs can be used as photo sensors as well: blog.makezine.com/archive/2009/08/… \$\endgroup\$ – davr Aug 14 '11 at 21:13
  • \$\begingroup\$ Shubham is it possible for you to share your circuit diagram if you are done with you table , because i am planning to make the LED interactive floor but i am not quite sure about how to go about it. thankyou \$\endgroup\$ – user18368 Jan 28 '13 at 19:24
2
\$\begingroup\$

Much depends on the PICs you have available, particularly how much and which type of I/O they have, think analog multiplexed ADC.

Sharing rows or columns between sensors and LEDs, like Chris suggests, is often done if sensors are digital like the LEDs I/O, for instance for a matrix of pushbuttons. It's not so evident for mixing analog (photoresistors) and digital (LEDs). What you could share is the I/Os controlling (de)multiplexers if you would need those.

Having a separate controller for sensors and LEDs, like you suggest, could be a good idea, as the extra I/Os may make some multiplexers unnecessary. You'll also need a few lines on each for communication between the two. As I understand it you'll want to start with a simple "action!" signal, but when the interaction becomes more advanced you may want to pass the coordinates of the mug to the other controller, so that its actions can depend on these coordinates. A simple UART will do, but still needs 2 I/Os on each controller (even if you only have communication in one direction).

For the sensors I'm thinking of two CD4051 multiplexers, one for the rows, the other for the columns of a matrix. If your PIC has an analog multiplexer for its ADC you can do with just one CD4051, but this uses a few more I/Os.
Select one of the photoresistors to place in series with a fixed resistor to make a voltage divider, so that you can determine the photoresistor's value with an ADC.

For driving the LEDs you can use a 74HC138 demultiplexer to select one row, and use the low level active output to drive a PNP transistor which will source the current to drive a column. For driving the columns you can use an I/O port of the PIC directly.
Like I said you can share the driving lines for one of the analog multiplexers with those of the 74HC138. Just saves you 3 I/O lines.

\$\endgroup\$
  • \$\begingroup\$ I have 2 PIC16F1519s. The ADC is something I wanted to ask about too: it says on Microchips site about the MC that it has a 28 channel ADC, what does this mean? Does it mean 28 I/O pins can read an analog signal? microchip.com/wwwproducts/Devices.aspx?dDocName=en549053 \$\endgroup\$ – Shubham Aug 9 '11 at 16:01
  • \$\begingroup\$ Also as far as power goes, I have an old phone charger I'm using as my power supply: 5.9V at 350mA. Of course I will regulate this to 5V, but will it be enough to power 2 microcontrollers: what if I turn on 36 of the 72 pins which output 5V at 25mA (I'm pretty sure)? Will that draw too much current or dim out the LEDs? \$\endgroup\$ – Shubham Aug 9 '11 at 16:11
  • \$\begingroup\$ @Shubham - Yes, you can have that many analog inputs. Of course, if you configure them all as analog input you'll have very few (if any) digital I/O left. I'd suggest to combine a number of pins configured as analog with an analog multiplexer, like I explained in my answer. \$\endgroup\$ – stevenvh Aug 9 '11 at 16:13
  • \$\begingroup\$ @Shubham - 45 LEDs x 25mA = 1.125A, so the charger won't be able to drive the LEDs. When multiplexing you typically drive them for short periods of time with higher currents, but on average it will still be 25mA. \$\endgroup\$ – stevenvh Aug 9 '11 at 16:16
  • \$\begingroup\$ Could you post the circuit diagram or schematic of this project considering different options you mentioned ?? thanks :) \$\endgroup\$ – user95018 Dec 21 '15 at 11:39
2
\$\begingroup\$

You might consider using IO expanders, cpld's or yes, you could use slave microcontrollers. Since such a project only has to respond in human timeframes, the internal architecture can require a long series of things to be done to produce one human-visible result.

Your sensors could easily be placed in a row-column matrix that you would scan.

Your LEDs can be matrixed to the degree that you are willing to drive them with pulses rather than continuously (which is fairly common).

You may be able to share one set (the row or column) lines between the sensors and LED's.

You might look into a technique called "charlieplexing" though as with everything it has tradeoffs.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.