How to make a computer controlled etch-a-sketch

Feedback, questions: send mail to eoinmcl at netsoc.tcd.ie
Go go gadget backwards

Ingredients:
1 (one) Etch-a-sketch
2 Motors
Some form of pcb you can alter
2 9 volt batteries and clips
Loads of wire
4 ic sockets
1 7408 ic
1 7404 ic
2 ld293d ics
1 parallel port cable
1 parallel port-thing that allows for soldering unto


Photos: here

1: Draw up the logic
Truth table, kmap and equations here
This part isnt really necessary, as it can all be controlled with software, but, sure, why-the-hell-not. Its much cooler this way, and also this way prevents you from wiring a +9 volts directly to ground. The 7408 chip isnt really common, you can use a 7400 instead, which is what I did, and itll work out nicely.


2: Draw up the LD293D chip
This is the part that controls the direction of the motor. See diagram here and an ikkle attempt at an explanation here
ON1 and ON2 are the outputs (left and right) from the previous step.
The Mb pins go to one end of the motor, and Mr go to the other end.
Each of the 9 volts come from the same battery, but seperate batteries are used on each ic. This prevents the motors slowing down if they're both turned on... The LD293D can accept up to 36 volts as power, so the 5 volts can be replaced with the battery power, but if youre powering the other ics, you may as well use the same ones...


3: Solder it all up
From the last two steps, the circuit is something like this
Not much to explain here, really... Youll have 4 wires for each motor, 2 going to each port. The inputs to the LD293D will change them between 9 volts and ground. There will be 4 inputs from the computer's parallel port to the logic, but you can use a fifth to turn on the logic, saving you a battery (which you should).


4: Connect all the nonsense to the parallel port. The important parts of the parallel port are these
Wire the ground in the circut to any of the ground pins, and the logic inputs to some of the data ports. I advise using the least significant bit for power to the logic (that way, always sending an odd number down the cable will have the logic turned on.

Finished product is, unsurprisingly a computer controlled etch a sketch
More useless images of production here

5: Code, code, code, code, code
Sample code. You input a number to manually have it sent to the parallel port. You may need root.

#include <stdio.h>
#include <unistd.h>
#include <asm/io.h>
#define BASE 0x378

int main(){
        int n;
        if (ioperm(BASE,1,1))
                exit(1);
        for(;;){
                scanf("%i",&n);
                outb(n, BASE);
        }
}


6: Better code code code
A more interactive version is here. Uses nethack keys. Simple control
Ever used logo? If you ever programmed as a six year old, you will have. I wrote a basic (easily segfaultable) logo interpreter which will send signals to the motors and act like the turtle would (without a penup feature, or a colour feature) --Motor signal timing not quite finished--

Notes:
Some people will suggest using stepper motors complaining about timing and accuracy, and you can still use them but I find that the amount of torque required to turn the knobs is pretty big so it stops moving almost instantly. And I'm not that bothered, really. It should be very easy to set it up, if you've gotten that far. You still have 3 data bits left to abuse. If that fails, try sticking some resistors in between the motor and LD293D

Sudoku on an etch-a-sketch

This is really easy. Pure nonsense. You'll need this to draw the sudoku and my project ssudoku to do the actual solving. Compile them to sudosketch and ssudoku respectively, put them in your $PATH and run (you may need root):
ssudoku | sudosketch

And youre set.

Photos of sketches as soon as the camera is done charging and I can be bothered