3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

How to build a 8x8x8 led cube (English version)

Step 6The software

The control software is written in Visual Basic language. The code is to be inserted in a module in your Visual Basic project. It is also necessary
to insert the library inpout32.dll in c:\windows\system32 folder of your PC. You can this library typing the name on google or downloading the attached file PROGRAMMI.ZIP.
You can find some explanation (in English) about parallel port here: http://logix4u.net/Legacy_Ports/Parallel_Port.html
At every moment the status of the cube is stored in the StatoCubo matrix. Using a timer an event is generated every little ms and the state stored in the matrix is rappresented on the cube.
PS: the function of this module is to visualize on the cube the content of StatoCubo matrix. YOU MUST MANAGE BY YOURSELF THE CHANGES OF THE VALUES OF MATRIX!

If you want something already written, in attached file PROGRAMMI.ZIP you can found some programs that practically do everything:
Gestione led cube 0.5.3 --> manual management of the cube (including timeline)
level meter con monoton --> a free MP3 reader that controls led cube (equalization of output signal)
inpout32.dll --> library to manage parallel port (necessary for the execution of programs)

The StatoCubo matrix:
The StatoCubo matrix is composed by 8 vectors of 64 elements. Each vector represents the state of an entire layer, every element of the vector represents the state of 1 single one led: 1 = on, 0 = off

The ScriviCubo function:
This function is called by the timer event and his function is to transmit the content of the StatoCubo matrix to the real cube.

The ClokkaLed function:
This function is called by ScriviCubo function and it works by sending a clock signal to shift register of the columns ONLY modifying the bit of the clock. In this way the bit placed on input of the first shift register of the columns becames acquired.

The ClokkaLivello function:
This function is called by ScriviCubo function and it works by sending a clock signal to shift register of the layer ONLY modifying the bit of the clock. If the layer to activate is the first, an high signal (1) is placed on input of the shift register, for the next layer the bit on input is 0. In this way the bit for activation slides from one layer to the next one. The layer will be lighted in sequence, one at each time.

The ClearAll function:
This function enables the clear pin on both shift registers. All the bits in the shift register will be set to 0 and the cube will totally switch off.

The Aspetta function:
This function is used to delay the cycle of updating of each layer. Without this function, the leds of the each layer turns on and off too quickly for properly lighting.

Now we can pass to the real code, comments in bold:


Public Declare Function Inp Lib "inpout32.dll" Alias "Inp32" (ByVal PortAddress As Integer) As Integer
Public Declare Sub Out Lib "inpout32.dll" Alias "Out32" (ByVal PortAddress As Integer, ByVal Value As Integer)

'--------------------------COSTANT FOR LPT1 ADDRESS--------------------------------
Public Const IndirizzoData As String = "&H378" 'DATA REGISTER: 8 bit

'-------------------------------------------------------GLOBAL VARIABLES----------------------------------------------------
Public StatoCubo(1 To 8, 1 To 64) As Integer 'variable that contains the actual state of cube

'-------------------------------------------------------------FUNCTIONS--------------------------------------------------------
Public Function ScriviCubo(NumeroCicli As Integer) 'function for write into cube the state stored in StatoCubo matrix
Dim ByteLpt As Byte
Dim ContaLivelli As Integer
Dim ContaLed As Integer
Dim ContaCicli As Integer

For ContaCicli = 1 To NumeroCicli

For ContaLivelli = 1 To 8

'set all bit of shift reg. of columns without clocking on shift reg. of layers and disabling EVER all clear pins (xx 01x _1_)
For ContaLed = 64 To 1 Step -1 'For ContaLed = 1 To 64
'SHIFT REG. LAYERS:
'MSB (D5) = 0 --> clock disables
'CENTRAL (D4) = 1 (valore=16)--> clear disabled
'LSB (D3) = not important

'SHIFT REG. LED:
'MSB (D2) = 0 --> clock disabled
'CENTRAL (D1) = 1 (valore=2)--> clear disabled
'LSB (D0) = StatoCubo(ContaLivelli, ContaLed)
ByteLpt = (0 + 16 + 0) + (0 + 2 + StatoCubo(ContaLivelli, ContaLed))
Call ClokkaLed(ByteLpt) 'send the value at function that give 1 clock signal to the shift reg. of columns
Next ContaLed

'SHIFT REG. LAYERS:
'MSB (D5) = 0 --> clock disabled
'CENTRAL (D4) = 1 (valore=16)--> clear disabled
'LSB (D3) = (if layer = 1--> 1(value=8); if layer <> 1--> 0) --> set 1 only the fist time

'SHIFT REG. LED:
'MSB (D2) = 0 --> clock disabled
'CENTRAL (D1) = 1 (valore=2)--> clear disabled
'LSB (D0) = not important

If ContaLivelli = 1 Then 'if Im setting the first layer I send a 1 at the shift reg. of layers, after I will send only the clock signal
ByteLpt = (0 + 16 + 8) + (0 + 2 + 0)
Else
ByteLpt = (0 + 16 + 0) + (0 + 2 + 0)
End If
Call ClokkaLivello(ByteLpt) 'send value to the function that give a clock signal to the shift reg. of layers

Call Aspetta(60000) 'calling the function for generate a delay (the cube stops flashing from 60.000 to 70.000 cycles)

Next ContaLivelli 'restart the cycle for setting the next layer

Call ClearAll 'call the function for activate clear on all shift register (switch off all leds)

Next ContaCicli

End Function

Public Function ClokkaLed(Valore As Byte)
Out Val(IndirizzoData), Val(Valore) 'clock DISABLED
'add 4 because I want to set at 1 the clock bit of shift register of columns for giving clock signal
Out Val(IndirizzoData), Val(Valore + 4) 'clock ENABLED
End Function

Public Function ClokkaLivello(Valore As Byte)
Out Val(IndirizzoData), Val(Valore) 'clock DISABLED
'add 32 because I want to set at 1 the clock bit of shift reg. of layers for giving clock signal
Out Val(IndirizzoData), Val(Valore + 32) 'clock ENABLED
End Function

Public Function ClearAll() 'function for enable the clear pin on all shift register
Dim ByteLpt As Byte
'enabling clear on all shift register (value=0) (xx x0x x0x)
ByteLpt = 0 '00 000 000
Out Val(IndirizzoData), Val(ByteLpt)
End Function

Public Function Aspetta(Ncicli As Long) 'function used to delay the cycle of updating the each layers
Dim Contatore As Long
Dim Contato As Long

For Contatore = 0 To Ncicli
Contato = Contatore 'assignment operation (only for do a CPU operation)
Next Contatore
End Function
« Previous StepDownload PDFView All StepsNext Step »
5 comments
Feb 8, 2011. 7:39 AMdangadave says:
hi guys...i have no idea how to get the software to work on my pc... im running windows 7... need help... do i have to download a program to run the software...? cause my itunes wants to try open it... but no success...:(

thanx
Aug 15, 2010. 12:43 PMlazardj says:
can any1 give me code without serial or USB control? i want whole program to put in microcontroler like 4x4x4 cube that is here on site. Thx
Dec 8, 2010. 4:30 AMR- says:
Here's one controlled by an Arduino

http://www.instructables.com/id/How-to-build-an-8x8x8-LED-cube-and-control-it-with/
Jul 20, 2010. 10:21 PMMorpheous87 says:
Do you have a microcontroller controlled version of this cube?
Nov 25, 2009. 2:14 AMdeanevans says:
Hi, i don't have a serial port on my computer but i do have a usb to 25pin serial adapter. would i have to change any of the code to make it work? and if so what parts?

Thanks in advance.
Sep 11, 2009. 6:30 AMwlk2 says:
can any one help me i'm try to understand the programming and interpret it in to c++ can anyone give me a hint/help plz

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
55
Followers
2
Author:agofi