the algorithm
The 8x8 display has 64 LEDs in it. They are treated as bits in a 64 bit binary number. By
counting from zero to 2^64 - 1, and displaying each number's bit pattern on the grid, we
cycle through all of the bit patterns/images possible with a 64 bit number.
It's easier to imagine using smaller numbers: let's say we're using a 2x2 grid. That would give
us 4 bits. With four bits we can represent 2^4 or 16 different numbers, and by counting from
zero to 15 and displaying the corresponding bit pattern for each number, we would cycle through
the 16 different possible images. The images in the 2x2 grid wouldn't be very interesting
though - there's not a lot you can do with just four pixels!
With a 2x2 grid we get 2^4 or 16 different images. with an 8x8 grid, we get 2^64 or
1.84467440737096E+19 (18,446,744,073,709,600,000) different images. At ten images per second,
it's going to take a really really really long time to display all of the images. Let's see,
10*60*60*24*365 gives us a rate of 315,360,000 images a year. 2^64/315360000 = 58,494,241,735.5
years to finish the cycle. Then allPossibleImages will start
again at the beginning.
The bits are arranged in a spiral starting from the center of the grid. Although we count
linearly from 0 to 2^64 - 1, we use Gray code to determine which LEDs to
turn on/off for each bit pattern. This lets the image develop/change smoothly, without the
mass turn-offs that would happen if we used straight binary. For example, going from
15 (01111) to 16 (10000) in binary is a pretty drastic change. Grey code ensures that
only one bit changes for each transition.
the hard and software
allPossibleImages is based on an ATMEL AVR microcontroller running at 4MHz.
The software is written in ATMEL Assembly. The display is refreshed ten times per second and
using eight 8-bit latches to drive the LEDs. There is no flicker, even at such a low refresh
rate, since the latches maintain their state during updates.
The components are mounted on a custom double-sided PC board, and are powered by a hardwired 6v
power supply. There is a reset button and a random button (which takes you to a random image
when pressed. Free time travel!)
making your own
schematics/board layout/code for allPossibleImages is available for free to anyone
who wishes to build their own version. UPDATE: Unfortunately the schemactics and board
layout have been lost.
|