Atari LED Cube
Overview
This instructable looks at using the Atari 800 joystick port for outputs with an LED cube as an example.
Introduction
Ever seen one of those LED cubes? They're totally cool. Ever wondered if your Atari could do something similar? Me too.
Supplies
An 8 bit Atari - I'm using an 800 XL
16 channel multiplexer - search for CD74HC4067 using your favourite search engine
A ton of LEDs - I made a 4x4x4 matrix which uses 64
Wires
Resistors
Female 9 pin D connector x 2
Building It
Suffice it to say that building these things is much harder than it looks (if you have paws instead of fingers), and fixing bad joins is like doing key hole surgery with a soldering iron.
I'm not going to spend any time on the construction of the matrix as there are guys who have done it so much better. Have a look at
https://www.instructables.com/id/LED-Cube-4x4x4/
or
https://www.instructables.com/id/8x8x8-RGB-LED-Cub...
Multiplexing
This is the clever bit. Having 64 LEDs normally means 64 wires to control them, but the Atari doesn't have that many pins that can be used to write.
Enter the multiplexer!
The cube is divided into 16 columns and 4 rows. Each column of LEDs share a +v input from the multiplexer, and each row shares a 0v. So to turn on an LED we work out which column it's in, and switch on the +v line, then turn on the appropriate ground.
However, you can only light up one LED at a time. If you try two or more, other LEDs will turn on as well.
Be aware that your multiplexer might have different connections to mine! Check your instructions first.
The Atari Code - BASIC
In addition to their normal operation, joystick ports can also write. There's a bit of a trick to make it work;
1) Poke port A control $D302 with $38
2) Poke port A $D300 with $FF
3) Poke port A control $D302 with $3C. This turns on bit 2 allowing us to write to the port.
There's a bit more about using the joystick ports as an interface here
https://www.atariarchives.org/creativeatari/Interf...
Port A is structured so that bits 0 to 3 take care of stick 0, and bits 4 to 7 deal with stick 1. By poking bits 0 to 3 with 1 to 15 we can control the multiplexer and switch on a column of LEDS. If we then switch on bits 4 to 7, we can control a row. Where the column and row coincide, an LED turns on.
You don't have to switch individual rows on; by combining bits 4 to 7, two or more rows will be on. Just beware that other LEDs that you don't want turned on, might light up as well.
5 LIMIT=60
10 PORT=54016
20 PCTL=54018
30 POKE PCTL,56
40 POKE PORT,255
50 POKE PCTL,60
60 I=RND(1)*239+16
70 POKE PORT,I
75 FOR WAIT=0 TO LIMIT:NEXT WAIT
90 GOTO 60
Nothing flash going on here; the code sets port A for writing then turns on an LED at random. The effect is a bit like a computer from a cheesy early 80's sci-fi show.
The Atari Code - 6502 Assembly
Basic's okay for switching on one LED at a time, but the fancy stuff happens when you start turning them on an off rapidly which gives the illusion that several LEDS are on at once. The effect is called persistence of vision and relies on the LEDs switching faster than the eye is able to detect. Basic's just too slow so it's assembly time.
This code switches on the corner LEDS
10 *=$6000
20 PORT = 54016
30 PCTL = 54018
70 LDA #56
80 STA PCTL
90 LDA #$FF
100 STA PORT
110 LDA #60
120 STA PCTL
130 LDY #0
140 MAIN
150 CLC
160 LDA SEQ,Y
170 STA PORT
180 INY
190 CPY #8
200 BNE MAIN
210 LDY #0
220 JMP MAIN
310 SEQ
320 .BYTE 16,18,24,26
330 .BYTE 64,66,72,74
There's some 'experimental' files in the Leds.atr attachment.
Enjoy