Insert the DC female jack into the male
socket with the correct polarity and
voltage/current ratings of the DC adapter
(Figure 41). Slide the switch S1 to the on
position by lifting the cube. Once powered on,
the cube will blink all the LEDs five times
before beginning to display the other patterns
in the demo mode. Once all the patterns have
been run, the process will start again.
Figure 41. Power connection.
Figure 42. Button label.
There are four pushbutton switches (S2 to S5) for various functions.
These buttons can be accessed by lifting the cube since the switches
are mounted to the bottom side of the PCB (see Figure 42).
The S2 switch is for reset. The S5 switch is the mode switch.
Pressing it will toggle between the demo mode and user mode. In user
mode, a single pattern will run over and over again.
S3 and S4 act as previous/next (cycle) pattern switches in user
mode for selecting a particular pattern.
Code for the 16F877A is
provided at the article link
shown. If you aren’t satisfied
with the canned patterns
provided in the PIC, you can
try your hand at
programming the LED cube
Programming the LED is
not very difficult, but does
take some thought. Look at
Figure 43. Here’s how our LEDs are wired inside the cube.
We have common anode lines for each of the four layers.
Each vertical column (1-16) consists of four vertical LEDs
tied to a common cathode. We turn individual LEDs on and
Figure 43. LED
Test Program Function
Layers are scanned one by one. When a particular layer
is active, a two-byte/16-bit word is simultaneously outputted
on the cathode pins.
Byte-sized variables are:
• a and a are cathode data for Layer 0.
• a[ 2] and a[ 3] are cathode data for Layer 1.
• a[ 4] and a[ 5] are cathode data for Layer 2.
• a[ 6] and a[ 7] are cathode data for Layer 3.
off by bringing the I/O lines of the PIC high or low. We
control the current to the common anode lines using four
I/O lines (RC0-RC3) connected to four power transistors.
Bringing this line low will turn on the transistor, allowing
current to flow into the common anode line to the LEDs.
The individual LEDs are controlled by the I/O lines on
port B and port D. Bringing a port I/O line low will turn
on that LED.
Essentially, by controlling the I/O lines we can turn on
any individual LED inside the 3D matrix, any group of LEDs
inside the 3D matrix, or all of the LEDs inside the matrix.
Patterns are created by sequencing LED patterns on and off
rapidly. Here are some general rules:
Layer 0 is the bottommost; Layer 3 is the topmost.
• A high output (1) on an I/O line on port D or port B
will turn the LED off; low (0) will turn the LED on.
• A low (0) on port C will make the PNP layer transistor
turn on; a high (1) will turn it off.
• Sixteen cathode rows can be turned on/off by the
port pins directly (port B and port D).
• Four anode columns can be turned on/off by the port
pins via PNP drivers (port C).