Light Pen Draws On LED Matrix


Who needs a 1920×1080 OLED display when you can have an 8×8 matrix of LED goodness? That’s the question [Kathy] asked when she built this LED matrix light pen project. It looks simple enough – a 64-LED matrix illuminates as the pen draws shapes. But how does the circuit know which LED is under the pen? Good old fashioned matrix scanning is the answer. Only one LED is lit up at any time.

[Kathy] used a pair of 74LS138 3-to-8 line decoders to scan the matrix. The active low outputs on the ‘138 would be perfect for a common cathode matrix. Of course [Kathy] only had a common anode matrix, so 8 PNP transistors were pressed into service as inverters.

The pen itself is a phototransistor. [Kathy] originally tried a CdS photoresistor, but found it was a bit too slow for matrix scanning. An LM358 op-amp is used to get the signal up to a reasonable level for an Arduino Uno to detect.

The result is impressive for such a simple design. We’d love to see someone use this platform as the start of an epic snake game.

34 thoughts on “Light Pen Draws On LED Matrix

    1. I agree. Although I wonder how well it’d work at turning the LED pixels off. I guess it depends on how fast the voltage drop off is when changing from output to input.

    2. I was also thinking the same thing, but I don’t think you need the LED in the pen. If the LED matrix is barely lit the pen might reflect enough of the light that you could detect when an LED is covered.

  1. I wonder if you could instead use the LEDs in the matrix as photodiodes. Between frames, turn off the matrix, turn on a red LED in the tip of the pen, and go through each row and column with an amp to see who is seeing the most light.

    I can’t image how to wire it, and if the LEDs-turned-photodiodes would respond fast enough, but it would eliminate the problem of all the “off” LEDs on the display having to emit a little light.

    1. There are a lot of downsides to that. You need an amp for every LED, and then a discriminator as well so you could try to multiplex it. You couldn’t do it digitally because the ambient light in the room would change the threshold level.

      The ‘off’ LEDs can be made to be emitting arbitrarily tiny amounts of light, really, by just scanning faster.

      1. “You couldn’t do it digitally because the ambient light in the room would change the threshold level.”

        You could sample all the LEDs that aren’t lit and use their average as a reference so the threshold changes based on ambient light.

        1. Right, which is a lot more work. Here she’s just using an op-amp as an open-loop comparator, with a single potentiometer, which is fine because you’re putting a fair amount of light out.

          You could have that adjust to ambient light as well, of course, by sampling the light sensor’s output when you have no LED lit, and setting the threshold based on that. But you need to do the scanning fast, and adding any ADCs, etc. will take time.

    2. The physical connection would be like this:
      >The most interesting part in this game is that the game uses a laser pointer as a two-dimensional input device in conjunction with a matrix LED.

      If you need to detect the difference in ambient light (vs a laser), you would need something more sensitive that detect minute changes in electrical charge instead of being lazy with ADC. Typically you are going to measure the time for the logic threshold for diode photo current to charge up parasitic capacitances like touch sensor application.

    3. First off: Cool project!

      For accurate or low light level measurements you’ll want a transimpedance amp(I-V converter) for each photodiode for sure as Pat stated. With a premade matrix I don’t think that’s possible.

      In this case since you only want detection and will have a lot of light available you might be able to get away with muxing the matrix directly without too much impact from the other photodiodes, even though they behave as current sources.

      At this point you could look at the charge as tekkie described, use a transimpedance amplifier to translate the shortcircuit current to an output voltage or maybe you can even get away with just a large load resistor (The output will not be linear to the received flux, but in this case I doubt that really matters).

      I’m unsure if measuring the charge is any more accurate than sampling the output of a transimpedance amp or maybe even just a load resistor in this case.

      What are typically the benefits measuring the charge decay time? I guess you don’t need any analogue inputs as long as you can cross your logic threshold. For a capacitive sensor I guess it’s nice to be able to measure a small charge without having to worry about it decaying before you can measure it (since that is exactly what you measure), but for a photodiode that can behave as a current source, what makes this a better option than sampling whatever output with an ADC? And how reproducible would relying on parasitic capacitances and leakages for your measurment usually be? It feels kind of icky to me, but then again I’ve never done it.

  2. Cool project! :) To some of the folks talking about using an LED on the pen instead, do you know if (clear) LEDs working as photo-diodes are only sensitive to the wavelength they emit or if their spectral response is based on their composition or something else?

    1. I believe they’re most sensitive to their emission wavelength. But if plotted on a graph, the reception curve isn’t nearly as sharp as the emission curve, and you could theoretically pick up any visible wavelength (and IR) given enough amplification.

  3. I know most people only complain, but I’ll counter and say I appreciate the animated GIFs and if you stop using them, I’ll turn on adblock. You are now break even either way you go and free to do what you want… for the time being. ;)

  4. I strongly disagree with his opinion. I like the GIFs. after only one loop I had a full knowledge of what this article would be about. A still standing image never can provide this kind of information-gathering. I like skimming thru here and those GIFs help me to determine if one article is worth the time of diving into it.

    1. While I agree with you, this doesn’t make still-pictures any less descriptive. This just takes more bandwidth for what it’s worth when I would have read the article anyway.

  5. Why not use a capacitive touch-screen like film on-top of the led matrix, and then use a capacitive stylus. A micro controller would process the touch of the pen and would allow the led that was touched to change state (ie from off to on, and vice versa)

      1. Unless you need to be extremely accurate — a finger’s width might be, too, large — as you only want to change the state of a single LED instead of however many fit under your finger.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.