Input Device Using LED And Four Photoresistors

[Julien] built an input device that uses reflected light detected by some photoresistors. Placing your hand above the device will reflect light from the LED back down onto the cadmium-sulfide sensors. The resistance of those sensors is read by four ADC pins on a Teensy microcontroller and translated to mouse movements. In the video after the break you can see that this works rather well in controlling the cursor. The source code is available on pastebin but we’re also going to host the code for posterity.


[Thanks Patrick]

38 thoughts on “Input Device Using LED And Four Photoresistors

  1. from
    a successful, flourishing, or thriving condition, esp. in financial respects; good fortune.
    prosperities, prosperous circumstances.

    succeeding or future generations collectively: Judgment of this age must be left to posterity.
    all descendants of one person: His fortune was gradually dissipated by his posterity.


    this seems like it could be used for a lot of other very sleek input solutions with a little modification. tack a bit of frosted glass over it and maybe do it in IR you can fairly easily make a poor man’s trackpad.

  2. hm.. interesting hack.
    this got me thinking, why not use a wheatstone bridge setup, and save on uc pins? all that is needed is a pseudosine wave (PWM) and this will work on a cheaper micro with more free pins for other functions.

    another worthwhile hack is to replace the sensors with infrared LEDs drilled and filled with ZnS glow in the dark compound to add dual functionality as both indicator and sensor.
    (ZnS flashes when exposed to IR light)

  3. Nice proof of concept but this is hardly very precise or responsive enough to be used in almost any situation. It wouldn’t be precise enough compared to a mouse or touchpad or nub, so high-precision applications are out. And it wouldn’t even be good enough for basic tasks like navigating a web browser. But like I said, it’s a really clever idea and pretty cool execution. I agree with the above poster that he should have used IR and IR sensors so it doesn’t blind you to use.

  4. Hey :)

    I’m the creator of this prototype.

    Just a few notes:
    – This project was made using only the few components I had in my room, while I was waiting for a bunch of new components (among which some IR emitter/receivers) to arrive by mail.
    – This is just a proof of concept, that was never intended for any practical use.
    – It has no practical use, since nobody wants to stay all day long with one hand in the air…
    – It’s fast to build, it’s fast to code, and it’s fun to do.

    About the video:
    – It was made in French and with a crappy quality since it was only intended for a friend.
    – I never thought more than 2 or 3 people would ever see it, else I would have made it in English, and with a way better quality.
    – I didn’t keep the prototype, and re-used its components a few days later. So I won’t make a new and better video, since I’m lazy to build it again.

    If anybody makes a better version (and I’m sure some of you will), using IR lights or other variations, post the video as a reply to this one :)

  5. Yes, there is a reason:
    Each photoresistor is used both for up-down and left-right detection;
    By having the 4 photoresistors at each corners, I have 2 horizontal and 2 vertical detectors:

    1 2

    3 4

    To detect the up-down movement, I use both [1;3] and [2;4].
    To detect the left-right movement, I use both [1;2] and [3;4].

    With the config you’re suggesting it would be like this:

    2 3

    To detect up-down I would be able to use only [1;4] and to detect left-right [2;3], which would be less precise.

  6. “It has no practical use, since nobody wants to stay all day long with one hand in the air”

    I wouldn’t say that. It does need some refinement – it’s a prototype, so that’s hardly surprising. But imagine building this into a laptop keyboard, or a public kiosk, or a terminal in a hospital.

    Not that this approach is the only way to get this result…but the hands-free approach is well suited to a number of applications, even if it’s not about to replace everyone’s mouse.

  7. Problem here seems that your hand is an irregular surface causing errors that need smoothing out.
    But you could use it with a flat square above it to make it more precise if you needed a contactless tilt indicator for something, although unfortunately I can’t think of such a situation right now :)
    Although.. it would work through a window, made from glass or armored glass/plactic, if you use something transparent to IR but not visible light it could also be made covert, maybe that has a use? Secret entrance handshake maybe?

  8. Keep in mind that due to the banned substance lists, that cadmium sulfide photosensors are an absolute no-no in ANY commmercial application.

    This means, solar cell LED garden lights and everything else.

    Just an FYI as I have not seen these used in a while. They were a good technology in things like self dimming mirrors 20 years ago, but they are banned now in commercial apps.

  9. I love this idea. It may have no immediate practical uses but it’s clever, simple and above all cheap. Plus, I’m sure it was fun to create. Let’s have some more of these type of projects, they don’t all have to solve real-world problems to be interesting or inspiring.

    Thanks for sharing this Hack A Day!

  10. @jeditalian – well done for spotting a slightly wobbly vid, but missing both the first complaint about it being wobbly AND the author’s statement that it was never meant for public consumption :)

  11. @Anonymouses: Why are photoresistors still sold if their’s banned from commercial applications?
    I bought these in February 2010 on an american website.

    But anyway, you could replace them with IR receptors, and it would probably be more stable, since there would be less ambient interferences to compensate for.

  12. i would like to say that anyone that sends a hack to hackaday and it gets posted is truly someone who has worked hard to make something no one else has or has improved upon an idea already out there, and to all of you that tear down and criticize the post should keep your comments to yourself. if you are so smart, then improve upon the hack and submit it yourself.

  13. You can get cadmium free photosensitive elements now like the AMS104Y.
    From the AMS104Y datasheet:

    Built-in optical filter for spectral response similar to the human eye

    Photocurrent is proportional to illumination (linear output)


    In 3 types of packages:
    Lead-type same as CdS cell
    Chip (miniature)

  14. –> Use a high frequency modulated light source
    to make the rig insensitive to ambient light
    (DC and 50, 60, 100, 120 Hz components)

    –> Use IR (same reason, plus it’s not so blinding)

    –> Use photodiondes because of the faster
    frequency response

    –> Calibrate the intensity response of the diodes

    –> Perform continuous, intermittent,
    re-calibration during operation

    –> Post the results once it works ;-)

  15. Make a VR room. Embed a bunch of this on the walls and something (accelerometers) to track movement of legs arms etc, combine inputs and you have the whole body as an input device

  16. I saw this from the Teensy page and was hoping it was the grid of LEDs that sense position somehow by themselves. Anyone got that link? It seems a logical Teensy project.

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.