**How
do you make a machine unpredictable?**
*This is a good question because anyone who's worked with electronics
knows that the devices are generally designed to produce precise intervals.
There's more to dancing than just counting. *

This machine has a circle of 16 leds driven by a one-of-sixteen
decoder, fed by a four bit binary up/down counter. When the counter is
clocked, the lighted led appears to move around the circle in the direction
determined by the state of the up/down line:

I wanted the led to appear to 'search' the perimeter of the
jar, in an unpredictable, arhythmic, back-and-forth motion. What I needed
was a 4-bit binary number that could be pre-loaded into the counter
to give a visually random count each time the led reversed direction (count
up 6, count down three,count up 14,...etc.). The answer was a circuit described
in Don Lancaster's __CMOS
Cookbook__. It's a psuedorandom sequence generator:
This is simply a four-stage shift register with a data input
that is an xor function of the two most significant bits. Note that
an all-zero state is disallowed. It produces a sequence of fifteen
numbers that are visually unpredictable, even though they repeat every
fifteen clock cycles. I enhanced the effect by including an audio pickup
and circuitry to change the starting point.
This was 1977, and my home made CP/M computer was running
well enough to tempt me to test the feedback connections in software. The
xor function in the above diagram looked like a parity check on those two
bits, so I guessed that the following Z80 assembly language routine would
generate some interesting sequences:

`ld a,(mask) ;load the accumulator with a mask
variable`

`or (hl) ;logical or the
mask with the virtual shift register`

`jp pe,noset ;if the parity of the result is even`

`scf
;shift a zero into the register`

` noset: rr (hl)
;else shift a one`
`ret
;return with the new number in (hl)`

The routine was used in many loops over the next few days
and became really rich when I found that any logical operation would produce
weird sequences. It became richer yet when the routine was put into a loop
that would print out the results in various ways.
This printout, for example, shows that a seed (hl) of 10000000b
and a mask of 0000001b will produce a sequence that is eight bytes long
before it begins to repeat. The whole printout is 256 lines and tests all
combinations of seeds and masks to give a maximal length for each combination.
Other printouts sorted the lines by maximal length and satisfied my need
to know that I had a source for interesting visual sequences. It is important
to remember that every configuration of the routine will have one disallowed
state.

This circuit is a hard-wired version of the routine. It continuously
plots sequences, at various plotting speeds, changing the mask upon sensing
a sound. In this case, an AND logical operation is used. click on it to
zoom.

If you've got it in you to wire up a 16x16 matrix of leds,
the following circuitry will display its output.

I am aware that this is probably the re-invention of some wheel. If
you have seen anything similar in the literature, please send me a note.