Arduino TVout Light Pen Demo

So, here to prove that we can take decades-old technology and re-use it, poorly…

The Arduino Light Pen!

Another fun little TVout project, I’m now coming up with a few improvements and seeing what kind of interesting and fun uses this little HID blast from the past can give us…

I’ll be documenting it up shortly, but you really don’t get much simpler!

#include <TVout.h>
#include <fontALL.h> 
#include <video_gen.h>

long s1,s2;
TVout TV;
int sz=8;

void setup() {

void loop() {  
  for (int x=3; x<112; x=x+16) {
    for (int y=32; y<40; y=y+16) {
      if (abs(s2-s1)>10) {

Thats cool!

First thing I thought of was a "shooting" game. I still have one of those really old 70's game consoles that came with 2 "paddles" and a light "pistol".

I'm going to have to try this! I saw a Playstation gun @the second hand shop for $10 today.

Yep-- good old "Duck Hunt" from Nintendo worked just like this.

Last night, I swapped out the phototransistor for an LDR (photocell) and was surprised to discover that it was both fast enough to work as the sensor (I figured LDR response would be too slow) and substantially more sensitive... though to be fair, I think I'm using IR phototransistors and really ought to use visible range.. where LDR is more sensitive by nature.

I then stuck the sensor a few inches down the middle of a piece of PVC pipe to act as a "barrel", to shield from "non aimed" areas better and allow for simple aiming, and discovered that with the LDR and "barrel", in a darkened room I could reliably "aim" my "gun" from across the room, approximately twelve to fifteen feet away... PERFECT for a shooting game. In that form, an 8x8 grid could sensed pretty reliably.. workable. Done the other way, minimum resolving power.. with my TV and a dimly lit room with the current code and circuit I could reliably detect a "dot" six pixels wide/high (of a 128x96, 40" LCD display). That's not bad resolving power, and well within workable for a shooting game.

Duck hunt worked like this: Pull the trigger, and it blacks out the screen..takes a read.. flash on only the "duck".. take a read. If the readings differ then the gun (sensor) was pointed at the duck, if they don't, it wasn't. Since it only is functioning as a GUN rather than a tracking PEN, scan rates aren't a problem and the whole game becomes simple to create.

If nothing else pulls me away today, I may re-create Duck Hunt in simple form.... I'm thinking a simple "skeet" shooting game ought to be pretty workable and operate in a similar fashion..

What's funny is that I did all of this a few decades back with Atari 400 Joystick ports, 6502 assembler, and an issue of ANTIC! (or was it Byte.. or Compute.. hmm). For that matter it could have been a Forrest Mimms thing...

I was always amazed at how accurate lightpens were. The pens that came with VT100 and VT132's worked when you pushed the pen on the screen, I used to modify them with to have a button.

The pens that came with some ISA Hercules graphics adapters that I was using with (groan) Autocad V1 (groan) had single pixel accuracy on an 800 x 600 displays from a couple of feet away.

Same goes for the PlayStation light guns, we used to play things like Time Crisis on the big ol' 3 tube cinema video projector and get single pixel accuracy from 20 - 30 feet away from the wall we were projecting onto. Considering the video image was around 20 feet wide by 15 high, it was pretty good going.

The "console" I referred to was one that used an AY-xxxx chip, games were selected with a switch on the front. There were a couple of versions of those AY-xxxxx chips, you got games like tennis, pong, skeet, tank battle. I started seeing them in arcade machines in the mid - late 70's, which was a bit of a shock/joy, one or two 40 pin LSI chips on a board, as opposed to a couple of A3 sized boards packed with 7400 series chips.

It's worth mentioning to folks unfamiliar with light pens that virtually ANY display can be used with a light pen type setup if run like I did in the code above. The thing is, the light pens you refer to (and I loved the VT ones myself.. I wish I had never sold the '52 with the Thermal printer in the top I had up until about five years back.. would be perfect for Arduino fun) are all based upon that CRT scanline technology.. which worked great. Unfortunately, LCD's and newer displays just don't work like CRT's.. there's no electron gun flicker to take advantage of, we have to wait for a whole screen refresh to test a pixel, if not several. CRT scan could locate within a single pass- while a 60-sensed location layout takes a full second to scan, even if we only allow for a single refresh per pixel. To use lightpen displays now requires manually scanning the locations, at a huge time overhead due to that wait-for-refresh problem. In the demo, the offshoot is that the "scan" is VERY visible, where it was totally invisible in CRT implementations. I'm going to try to get creative, but no matter how you cut it, an LCD is not going to refresh any faster than 60Hz if given NTSC video.

16x2 LCD's, a row of LED's, virtually anything that will provide a visible light level change will work.. coupled with a light sensor and a little creative timing, virtually any form of visual display will work. If your eyes can see the change, then a sensor can too..

Another cute implementation I may try in a little bit is Poor Man's Imaging:

Set the Sensor up so it "sees" the whole screen (no barrel). Stand in front of the screen or place an object in front of the screen. Scan through a grid on the screen... if a location is blinked but the sensor doesn't see it, that means that the object is obstructing the sensor's view. By scanning through the grid of the screen, you get a "shadow" outline of whatever is obstructing the view... voila, poor man's imaging. If you think through the potential things this could be used for with a little ingenuity, it's a lot of bang for a little technology buck. Consider that you know the location of the sensor, the location of any illuminated dot, and therefore the incident angles - by using a couple of sensors you could get extremely accurate optical measurements without physical contact of the object...

Could it be used ona monitor to move the cursor and click on buttons ?
Easier than reaching for the mouse.

What about me writing text with it ?
Drawing pictures etc.

Geez I play poker all the time . Could it deal the cards for me ?
Well…roably not . if it just brought me a beer that would be OK

selecting textboxes? No problem. This setup would work well for selection from a range of choices, etc.

Painting and drawing was possible with the old CRT type. Because today's monitors operate in a different way, a light pen with high enough resolution to do drawing has prohibitively slow response.. it can take several seconds for a single pixel to register if scanned manually, as is required. "Back in the day", designs based upon scanline interval on CRT's would often have single-pixel accuracy at a distance of several feet on a 800x600 14" CRT. Painting and drawing with light pens was for a short time a fad amongst artists and such.. but today's displays just don't work.

A possible solution might be predictive location, but that assumes the pen is never "lifted" from the "paper". Once the pen location is found, only the immediate pixels around it are scanned for the pen being moved. By only scanning a small number of pixels, a higher refresh rate can be had.. but if the pen is "lifted" from the "paper", you are right back to taking seconds to locate the pen.

Alternatively, location by approximation, by locating successively smaller blocks to pinpoint- can be faster, but given the refresh times, results in a strobing screen that's user-hostile. Convulsions are normally considered a show-stopper when it comes to HID design....

This project was selected and featured in Make Magazine's blog today!

(Little goofy dance ensues on my part)