loading
When the robot overlords take over, they'll need to use our etch-a-sketches. Here's how to let a computer draw vector art using your favorite childhood toy.


**I'm going through and finishing a slew of old instructables I never published. I think I made this one sometime last year. Enjoy!
--alex
artiswrong.com



So, there I was, skipping class at MIT and hanging out at my favorite machine shop. While I was sitting in my favorite comfy chair, a flash of red shining from beneath a pile of books caught my eye.
"Aha!", I said, "What could that be?"
Further excavation yielded a classic red etch-a-sketch, perfectly preserved since Steve Cooke left it there twenty years ago.
I thought to myself, "I hold in my hands a perfect basis for a computer-controller vector drawer"

A maniacal grin crept across my face as I felt my plan grow to fruition inside my mind.

This, my friends, is the true story, complete with instructive pictures, of how a person such as yourself built a computer controlled etch a sketch. Sure, it's been done before. Now you can do it, too.

So, what are you waiting for? Skip a class and go build something!
 
Remove these adsRemove these ads by Signing Up

Step 1: Overview

Picture of overview
The general idea is this:
you're going to take an etch-a-sketch, pry off the knobs, put motors where the knobs once were, and then build a circuit that lets you control the motion of the etch-a-sketch from a computer

Step 2: First bit--figure out how to add the motors

Picture of First bit--figure out how to add the motors
OK, the first thing you need to do is pop off the two knobs on the etch-a-sketch. They're just pressed on, so jam a flathead screwdriver under them and pry them off. This entire setup is reversible, so hang on to the knobs in case you ever want a normal etch a sketch again.

You should be left with an etch-a-sketch with two metal nubs sticking up, each with a flat cut into it that used to mate with the hole in the knob.
Grab a calipers and measure the diameter of the metal nubs. Write it down somewhere.

Before you go on to the next step, play the song 'Neigborhood 1(tunnels)' by the Arcade Fire on your home entertainment and theater surround sound audio system and let its genius blow you away.

Step 3: Measure up the motors

Picture of Measure up the motors
Next up, measure the diameter of your motor shafts. Write that down, too.

Now, look around for an aluminum rod that's at least twice as big in diameter as the larger of the two shafts you found. You're going to use this to make a coupling between the motors and the nubs.

Step 4: Make the couplings (lathe time!)

Picture of Make the couplings (lathe time!)
The couplings you want to make are about an inch long. I always find it easier to machine my part while it's still on the stock and cut it off later.
For anyone interested, my stock was about a foot of 1" diameter aluminum.

Take your aluminum rod and mount it in a lathe. Find a drill bit that's a tiny bit smaller* than the smaller of the two shafts. Drill a hole in your stock for a little more than an inch. Now, find a drill bit a tiny bit smaller than the larger of the two shafts and drill that into your stock for 1/2"

Cut off inch you just machined. Make one more part the same way. While you're doing so, turn on the song 'Bottle up and Explode' by Elliott Smith.

  • You're going to put setscrews into your couplings, so if the drill bits are the same size, or even a little larger than your shafts, it's OK.

Step 5: Put on a flat and drill some holes

Picture of Put on a flat and drill some holes
Somehow, either using a file or grinder or anything else, flatten out one side of the rod.
I was feeling all fancy, so I used a mill. This just makes it easier to drill into.

Now, find a tap drill for an 8-32 screw and drill two holes in the coupling, about 1/4" from either end.

May I suggest the tune "Fake Palindromes" by Andrew Bird for this step?

Step 6: Tap the holes

Picture of Tap the holes
Grab an 8-32 tap, throw your coupling in a vice, and tap the holes. Afterwards, check to make sure that you can put an 8-32 screw far enough into the coupling to press against a shaft in the coupling.

While you're at it, take a look at your motor shafts. If there aren't flats, use a dremel or a bench grinder and add a flat on each shaft. This will help the setscrew hold the shaft in place.


"Take me to the Riot" off The Stars' new CD is a great song. In fact, the entire album is great--check it out.

Step 7: Check Out Your Couplings

Picture of Check Out Your Couplings
Round up 4 8-32 screws and slip your couplings onto your motors and the etch-a-sketch. Line up the tapped holes with the flats on the shaft and and put those setscrews in. Everything should be nice and tight once you've tightened down the setscrews.

hooray!


So, this step isn't terribly thrilling, but listening to "Holy Calamity" by Handsome Boy Modeling School will make assembling motors much more fun.

Step 8: Stiffen Everything up.

Picture of Stiffen Everything up.
fit onto.jpg
welded support.jpg
OK, well, there I was. My motors were pleasantly coupled to my shafts, but I had no way of keeping the motors from spinning. What I needed was some way of holding the motors still relative to the etch-a-sketch knobs.

Fortunately, I had used these motors for another project and I had made lots of nice waterjetted motor mounts(shown below). It's not a difficult part to make by hand--it's just a plate that goes on the front of the motor, with a hole for the motor shaft and three holes for mounting screws that screw into the motor. I can try to dig up my CAD file if anyone wants it, but the dimensions just took a few minutes with calipers to figure out. To make the mounting plate, I used 3/32" steel plate and there are four holes you have to drill.

I took a couple mounting plates and bolted them on to the motors. Then, I took the motors and put the couplings on them, coupling them to the etch-a-sketch. I grabbed a piece of 1" angle iron and measured out the distance between the two motor mounts, including the width of the mounts, and then cut my angle iron using a chopsaw.

Next, I rotated the motors and motor mounts so that the long parts of the motor mounts were both sticking off the etch-a-sketch, exactly parallel. I then put the angle iron over the overhanging part of the motor mounts, making sure that they were flush with the inside edge of the angle iron(the elucidating pictures below should illuminate your path through the darkness of confusion)

In retrospect, I didn't need to spend so much time making sure the motor mounts were parallel, but this made my finished product sexier.


Now that I had my angle iron lined up on my motor mounts, I grabbed a MIG welder and did a light tack weld on both motor mounts, where the mount overlapped with the angle iron. I didn't want to do a full weld with the motors still attached to the mounts for fear of heating up the motor too much and screwing up a bearing or winding.

Then, I valiantly uncoupled the motors from the etch-a-sketch and un-bolted the motors from the motor mounts, leaving me with the two motor mounts tacked onto the angle iron. I put some sturdier welds joining both mounts to the angle iron(see below) and casually slew a dragon that kept sticking its nose into the machine shop.

I sat atop the dragon carcass and admired my work(see below) while feasting on fresh dragonflesh--there's nothing like it!

Step 9: Painting

Picture of Painting
silver.jpg
federal safety yellow.jpg
My friend Mars had recently made an incredibly tall bike from scratch, which he named Phobos. He had just painted it hot pink, which resulted in everything else in the shop turning hot pink as well. Inspired, I figured I ought to paint this sucker.
Rooting through the shop paint cabinet, I dug up Federal Safety Yellow and Flat Silver. They would have to do.

My fingers were also painted Federal Safety Yellow after this step. Everybody knew to stay away!

Step 10: It's time for a haircut

Picture of It's time for a haircut
Thanks, stasterisk!

Step 11: Moving on to electronics

Picture of Moving on to electronics
At this point I was pretty much done with the hardware. I screwed the motors back into their mounts, screwed the couplings back on, and set it aside for a moment.

If you like, take a 9V battery and touch it to the terminals of each motor and watch them draw stuff on the etch-a-sketch screen. It's pretty cool, isn't it? Science is definitely happening.

The next steps of the instructable will explain how to hook up the etch-a-sketch to a microcontroller and program it to draw stuff.

The schematic below is frustrating to read. Hover your mouse over it and click the small italic 'i' at the bottom left corner. It should show the same frustrating image on a new page, but with a link to the original ~1000x1000 pixel image. Click the link, and the schematic should pop up with blinding clarity. Sorry about that.

As I mentioned at the start of the instructable, I used an Atmega48 micro. I used an stk500 to program it, and I breadboarded up an L293D motor driver, which I powered with a 6V battery pack. I kept the atmel on board the stk500.

If you haven't checked out the L293 chip, I highly suggest you do. It's called (somewhat irritatingly) a quad half-H chip. An H-bridge is a name for an electrical circuit that allows you to create a forward or backward potential difference across a load (i.e. drive a motor forward or backward). This gorgeous chip can handle up to .6A at 35V if you ask it nicely (heat sink the crap out of it) and control two different brushed motors simultaneously, or you could use it to drive one unipolar or bipolar stepper motor. I use them like they were candy. Circuit candy. That I put in my breadboards instead of gorging myself on their sweet silicony flavors.

If you're not familiar with atmel programming, may I suggest some of these fabulous instructables?

Step 12: Wire up your breadboard

Picture of Wire up your breadboard
Wire up the L293D on the breadboard according to the schematic. Don't forget the 10K pull-down resistors--this is one of the handiest things I learned when dealing with L293 chips--the inputs have a tendency to 'float' high, and turn on even if your micro is asking it to stay low. The pull-down resistors keep this from happening.

If you're using an stk500, throw your mega48 into the green socket, and plug one of the 10-pin connectors into the portB header. Don't forget to wire the 5V and (more importantly) circuit grounds together. If you want to put the mega48 on the breadboard, that's fine, too. If I'm building a temporary circuit, I just like to use the stk so I don't have to wire up as much.

You'll also notice on the schematic that there are two power supplies, VCC and VDD. Vcc is the 5V supply that powers the atmega and the logic side of the L293 chip. There's another side of the L293 chip that deals with the power that actually goes to the motors, and it's a very good idea for these two power supplies to be separate. I used a pack of 4C cells to power the motors, and that lasted for three weeks of playing off and on with this thing.

Step 13: Programming

Picture of Programming
Now it's time to program the atmel. I used avr-gcc (a free compiler) to compile my code, and avrdude to burn it on to my chip.

Unfortunately, I left my code behind on the shop computer when I moved out to LA at the beginning of the summer, and there's a possibility that the code is lost and gone forever. Rather than try to rewrite it(although I'll probably find a copy when I get back to LA in a few days--I'm in frisco now), I'll try to walk you through programming techniques you can use for this baby. Wouldn't you rather learn to fish than eat fish, anyway?

Here' s the basic theory behind the code:
Drawing is an open-loop process. The only way we have of knowing how far the etch-a-sketch has drawn is by figuring out how long we've been turning the motor at a constant speed. The problem, of course, is that the motors vary their speed based on the battery voltage, which could change from day to day. I could regulate the motor voltage, but I find that idea abhorrent and unnecessary. Instead I'll sit back and listen to the song 'Frankly, Mr Shankly' by the Smiths with a smug expression on my face.

To get around this, I pretend I'm drawing vector images (i.e. images that are composed of scalable lines and curves). I make a global variable in my code called scale, and if I had a function such as drawLine(angle, length), I would call it with an arbitrary number for length, say 3. Inside the function, I have code that says: Draw a line at the proper angle for 3*scale seconds

Does that make sense? Good.

Here are some basic functions:

void drawRight(unsigned char distance)
{
PORTB=1;
wait(distance*scale);
PORTB=0;
}

void drawLeft(unsigned char distance)
{
PORTB=2;
wait(distance*scale);
PORTB=0;
}

void drawUp(unsigned char distance)
{
PORTB=4;
wait(distance*scale);
PORTB=0;
}

void drawDown(unsigned char distance)
{
PORTB=8;
wait(distance*scale);
PORTB=0;
}

for those of you who don't want to write it, here's the wait function:
void wait(int time)
{
int count, count2;
for(count=0;count<1000;count++) //we're going to burn lots of cycles here.
for(count2=0;count2<time;count2++)
;
}

OK, this ought to get you going. Play around with this code for a bit and draw lots of horizontal and vertical lines. Maybe a box. In the next section I'll talk to you about curves.

While you program, check out the indie label Kill Rock Stars. Next to Matador, it's one of my favorite labels. ok, cool.

Step 14: More programming(angles and curves)

Picture of more programming(angles and curves)
To make the etch-a-sketch draw at an angle, you just gotta run both motors at the same time. Drawing at 45 degrees is pretty easy--just turn both motors on in the proper direction and it works. Angles other than 45 degrees are a little trickier. Let's say you wanted (for the sake of a round number) to draw a 26.6 degree line. This means you have to draw one unit vertically for every two units you draw horizontally. You could alternate back and forth between the horizontal and vertical motors in tiny increments, saying
drawLeft(2)
"drawUp(1)"
and loop that for a while, but that'll never be all that smooth.

Wouldn't it be much cooler to run both motors at the same time, and run the vertical motor(in this case) half as fast as the vertical motor?

The way to do this is with PWM. For those of you who aren't familiar with this wonderful thing, PWM stands for "Pulse Width Modulation" and is a way of approximating a value between 0 and 1 in a digital circuit.
Here's a brief rundown:
Let's say I have a chip that can produce either 0 or 5 volts. This chip drives an electric motor, and I'd really like to run it at half speed, or 2.5 volts. I can't produce that voltage directly from my digital chip, but maybe if I output 0 volts for a while and then 5 volts for the same amount of time, the average output would be 2.5 volts. If I do this really slowly, the motor will jerk on and off, but if I switch between 0 and 5 volts really quickly, the motor will run smoothly. This is because the motor has a damping effect, and for some high frequency, can't respond as quickly as the signal is changing, effectively averaging the voltage across it. Hooray! Now I can control a motor's speed!

"If I want to produce a different voltage, say, 3 volts, I would just keep the signal at 5 volts for 3/5 of the time. 2 volts, 2/5 of the time. Ad nauseum"

OK, so practically, I'd like to write a PWM routine that can output a pwm wave to both motors simultaneously.

void pwm(unsigned char horizontal, unsigned char vertical, unsigned char horizontal_direction, unsigned char vertical_direction, int magnitude)
{
unsigned char count,output;
output=0;
int length;
for(int length=0;length<magnitude;length++)
for(count=0;count<255;count++)
{
if(count<horizontal)
output|=_bv(horizontal_direction);
if(count<vertical)
output|=_bv(vertical_direction);
PORTB=output;
}
}

The angle you draw at (from the horizontal) will be pretty close to atan(vertical/horizontal).

Now you have a function that lets you specify the magnitude and direction of a drawn vector. This is the basic, fundamental component of any vector graphics renderer. Sweet!

Step 15: Delicious!

Picture of delicious!
DSCF5848.jpg
Well, I wish I had some half-decent code to share with you, but unfortunately all the programs I wrote for my etch-a-sketch were lost in the epic molasses flood of ought-7, where computer memory-erasing molasses poured through the streets of boston. Also, I am in LA now, and I left my etch-a-sketch in Boston.

here are a few examples, though, to get you started:

draw_square(int side)
{
pwm(255,0,1,0,side);
pwm(0,255,0,1,side);
pwm(255,0,0,0,side);
pwm(0,255,0,0,side);
}

//I use trig functions in this example, and you'll need to find some avr library that supports them
//or just whip up a table
draw_circle(int radius)
{
double x,y,xp, yp, int mag;
unsigned char xval, yval;
xp=radius;
yp=0;
unsigned char xdir,ydir;
for(double theta=0;theta<360;theta++)
{
x=radius*cos(theta);
y=radius*sin(theta);
if(x>xp)
xdir=1;
else
xdir=0;
if(y>yp)
ydir=1;
else
ydir=0;
angle=atan((y-yp)/(x-xp));
xval=255*abs(cos(angle));
yval=255*abs(sin(angle));
mag=sqrt(pow((y-yp),2)+pow((x-xp),2));
pwm(xval,yval,xdir,ydir,mag);
}
}

Foster the dog wishes you good luck in your programming endeavors!
Valerie the dog suggests you listen to DJ Z-trip. Wait, that's not Valerie. That's me.

Step 16: Done!

Picture of done!
Well, that should be enough to get you up and drawing! Enjoy, draw some cool stuff, send me some pictures if you make one of these. One thing that would make this project a lot better is wrapping some feedback around the etch-a-sketch. The drawing mechanism has a lot of slop in it, and drawing open-loop, as you can see from the pictures, has some bugs. You can try to account for the slop in the code, but putting a camera over this sucker and wrapping the entire device in a closed loop is the 'right' way to do it, although it kinda defeats the purpose of having a cool self-contained etch-a-sketch that draws all by itself.

Well, this instructable's done! I'm going to go and do something unwise now (see image).

--alex
www.artiswrong.com
Bobey2 years ago
Operation to the echa sketch
would it be possible for you to mod an old printer one that runs on guide polls in order to virtually print things onto an etch a sketch... black and white images for example?
prank (author)  DavidWalsh109207 years ago
Do you mean that I'd print to the printer, but it would send the image to the etch-a-sketch instead? If I was going to do that, I wouldn't bother with a printer--I'd just write my own 'print driver' and send commands directly from a computer to the etch a sketch. There's a more fundamental problem, however, which is that an etch-a-sketch is a vector printer, not a raster printer. What that means is that etch-a-sketches are great at drawing paths, but not going through a drawing and saying "let's color this pixel white, the next pixel white, and the next one black." If you could modify and etch-a-sketch so that you could lift up the pen, it would be both much cooler as a vector drawer, and it would also be possible to use it to print images.
srilyk prank5 years ago
You know, you could probably take apart an etch-a-sketch and add a 3rd motor or servo or actuator or something that would lift the glass up and down. Although that aluminum dust gets over EVERYTHING! (I'd recommend respiratory protection)
http://www.howstuffworks.com/question317.htm
I didn't just mean mod the printer i also meant to mod the printer drivers so it would understand printing constant line through vectors, and to not break the line and to stay on that track instead of printing line by line.
prank (author)  DavidWalsh109207 years ago
Well, there's not much similarity between vector and raster printers, so you might be better off writing your printer driver from scratch, especially since many drivers I know aren't open source. Writing a program in processing that would take a vector file and output the right set of serial command to the etch-a-sketch would be pretty easy.
long before windows i had a vector(called a plot ) printer that used inkpens .4 foot wide 12 foot long bed have to print each color one at a time ( then change the pen ) it was run from a BASIC program mostly had to do with PEEK/POKE commands .it would lift the pen but didn't have too. could make wonderful Blueprints,the hard part was the system running it did not have a VGA monitor altho did have a mouse think about how good that works
a mouse with out a monitor? that reminds me of the stupid keyboard error. "KEYBOARD NOT FOUND PRESS F12 TO CONTINUE" or some such nonsense.
the mouse lives on a large board on the front it has a little clear plastic tab with a crosshair. one corrner of the board is a "home "positition click that then click the icon wanting to input . if the mouse gets lost then take it to home , and it does. this was used to write fanuc programs to can for a cnc lathe. Fanuc is very close to basic type program using commands like basic peek/poke
oh that's cool, I'd never heard of that.
Thank you for the clarification.
H3xx prank5 years ago
Speaking of this, I'd like to see some one use this instructable to make a laser etching system, using a dvd burner diode and the etch a sketch guts. I'd like to do it my self, but I'm putting the idea out there cause I'm strapped for cash and parts.
trumpkin6 years ago
where is the ground from the motor battery supposed to go?
trumpkin6 years ago
would the pullup resistors be a different value if you used deifferent motors?
trumpkin6 years ago
so pin 1, 16, and 9 are all connected to 5 volts?
prank (author)  trumpkin6 years ago
yup
balisticjoe7 years ago
I am in the process of doing something like this but making it r/c hopefully being able to make circles.
bennor37 years ago
ouch
A_squared7 years ago
If it were to draw boobs.... Would they still turn out square?
prank (author)  A_squared7 years ago
is this some sort of zen koan?
stasterisk7 years ago
4 C-cells to get 6V, or for life, liberty and the pursuit of amps?
prank (author)  stasterisk7 years ago
wey-all, them amps don't hurt much, but dem L-293s need at least 6V on the power side to work well. Ja coulda useda four AAs, but dey'd just do dead fasta
stasterisk7 years ago
L293D! Whee! Hey, were we ripping apart atoms before hair-chopping, or was that buzzer just really loud?
bkopke7 years ago
I built one at work a few years ago to test some code for an X-Y table we were retrofitting. I used stepper motors and a Trio CNC controller, a bit of overkill I know, but it worked pretty good. All of the parts eventually got donated to other projects after the fun wore off. I like the bracket you made for your motors; far superior to the jack leg job I did on mine:-) B.
dillweed7 years ago
i heart mars.
prank (author)  dillweed7 years ago
In a way, I think of mars as my mother. The way where I have a life-sized Mars doll I hug before going to sleep every night. On Saturdays, I dress up the doll in floral gowns!
ll.137 years ago
I love those things, they're just plain awesome!
Crash21087 years ago
Awesome! It's pretty ironic that you post this now; my math theory professor was (for some reason or another) talking about automated etch-a-sketches at the end of last year.... I'm surprised I didn't get to see your etch-a-sketch when I visited MITERS a few weekends ago... I'll just have to ask Star to show me it next time I visit ;-) +!
prank (author)  T3h_Muffinator7 years ago
I'm not sure if it's still around miters. I wouldn't be surprised if it's been put to other uses by now.