Go Down

Topic: Help understanding this led cube code, my wife brought me for Christmas.  (Read 697 times) previous topic - next topic


if this is in the wrong place, could a mod move it or direct me to the correct place please.

Hi, I am fairly new to coding and am currently working through the arduino ide tutorials, some not all as i have just have a box of components left over from other electronic repairs (nothing fancy) an UNO and a mega 2560, I have made 2 full projects (if you will call them that) 1st was a basic temperate and humidity monitor with LCD + i added have started to implement a switch that will eventually stop or start a flow of water depending on the floating switch state
The other was the'O' so cool adadlight (not brought  as a kit) but with a string of 25 ws2081 leds that i purchased a while back for another project witch never got started.

Now my biggest issue is education, my attention span can be rather short but once I start in on something (understand it) I can't help but push it forward a kind of A.D.D if you will.

the project.

My wife brought me one of these kits
 from ebay which i built with my daughter and had a load of fun, but after a week she asked me if i could get more patterns for it, so i dug a little deeper and eventually, managed to get the source code from the supplier and took a look, now this is my problem it seems way over my coding skill to figure out the actual portion of code where i edit or add the code to make new patterns this isn't my 1st ledcube. I built a 4x4x4 cube a while back also with my daughter but i did not use shift registers or anything fancy just the basics and an arduino mega controlling it using the B0000 < depending on if it was a 0 or 1 turned on a led as most will know, but i can't get my head around this code that i sourced, there is not many notes in the code, or poorly as they are chinese made, the cube uses the STC12C5A60S2, i have the hardware part sorted.
By using my uno as a serial programmer
bypassing the atmega 328p with reset to gnd and connecting the tx and rx to the right pin's i was able to use the stc flashing program to send the original hex to the chip and do a few other basic test's to assure a connection..

so the code, i will attach the 888.c file that i was given for someone to take a peak at and see if they can give me a laymens run down on how to configure my cubes patterns or even a way to loose the dedicated stc chip and put some headers in for arduino controls would be another option if anyone would like the schematics files for the cube just give me a shout and i'll post them, also if you need help hooking the hardware side to program the stc i can help there :)

Thank's in advance


22 views and not even a simple, figure it out yourself lol,

I'm going to attach all the files i received from this Chinese guy, maybe someone could help me ditch the STC12C5A60S2, and make it arduino controlled, i do some 328p chips at my disposal that could embed with an icsp header for programming, I can't be the only person not able to understand how this works surely

translate the page and download as i did.
Thanks again,


looks like I'm in the same boat...  identical kit, I'll I've got is a pictorial for assembly, but no code at all!

and your download link isn't functional... Figured out the link think you can  upload it somewhere -- I'm at about your level, but I'd like to give it a go.
Warranty void if seal is broken


Jan 21, 2015, 07:27 am Last Edit: Jan 21, 2015, 07:32 am by uronour Reason: added link
I managed to figure a piece of the code out (dirty way) trial and error and random changes i set everything in this line shown bellow to 0x00 then changed the 1st bit to 0x01 and it lit a single led and scrolled it round the cube like it's suppsed to, when the flash() calls for the uchar code table_id, it points to this specific code.
looking @ this line, i was able to change the scrolling text in flash 1. i think it was a test image or something i read, ideasoft.

it controls each pixel by hex value so 0x01 on my cube is top left at the rear i swear my cube is backwards, because i had to right my letters backwards and upside down.

each 8 hex portions are 1 frame, so fill in 1 box on the code generator then paste only the 8 hex value's that changed,then change the picture in the box again and copy the 8 hex vales that changed, over the next 8 portions of code, i tried more than 1 box at a time but i din't seem to work.

/*the *ideasoft*/
uchar code table_id[40]={0x01,0xff,0x00,0x00,0xff,0x81,0x81,0x7e,0x00,0xff,0x89,0x89,0x00,0xf8,0x27,0x27,0xf8,0x00,0x8f,0x89,0x89,0xf9,0x00,0xff,0x81,0x81,0xff,0x00,0xff,0x09,0x09,0x09,0x01,0x0,0x01,0x01,0xff,0x01,0x01,0x00};

If you download a cube code generator, there's one in the the download link i posted all files you need are there, to program the stc12c5a60s2 i use the tx/rx pins from arduino and connected them up to the pins on the cube board. p30 <->RX arduino P31<-> tx and gnd vcc respectively
then download the stc flash tool,

download kiel c compiler to compile the .c file into a flashable hex, pm me and i'll help you get setup
I am really trying here to make this work as stock, for when i need my spare arduino.

Would anyone be willing to help me do what I really want and remove the stc chip and direct wire up a header for arduino uno or mega either will do, i am extremely lost here, reading the data sheets gave me a headache although i am going to throw something together later on today to try and use the arduino....

looks like I'm in the same boat...  identical kit, I'll I've got is a pictorial for assembly, but no code at all!

and your download link isn't functional... think you can  upload it somewhere -- I'm at about your level, but I'd like to give it a go.


I'm finally getting the code downloaded -- I'll give it a look tomorrow night.
I've got some ideas about what might be able to work -- If they are right, I'll follow up with what I figure out.
Warranty void if seal is broken


I haven't assembled my kit yet, but I'm tracing pins on the printed circuit board to figure out how to replace thestc12c5a60s2  with an arduino.

I haven't figured out the reset pins, or really anything else but you probably could remove the stc12c5a60s2  from the socket, and run 24 wires from your arduino to the appropriate sockets...

in brief:
pins 32-39 on stc12c5a60s2  are brought to high to select which y axis is lit
pins 21-28 on stc12c5a60s2 are brought to high to select which y axis is lit
pins 1-8 on stc12c5a60s2 are brought high to enable matching z-axis

to light any particular led, 3 pins need to be brought high, one from each axis:
(32-39) x axis
(21-28) y axis
(1-8) z axis
if you enable multiples (say 1,2 and 8 ) of y, all selected x will also light.
this is also true of z

notes below:
looks like pins 32-39 on the stc12c5a60s2  all hook up to a resistor network which then go from 39 on the stc12c5a60s2 ->10k resistor ->  pin 8 on all but one SN74HC573AN latches. the output side of each of these corresponds with a LED column on the x access so:
pin 19 on SN74HC573AN (u1) connects to x 1, y 1
pin 18 on SN74HC573AN (u1) connects to x 2, y 1
pin 19 on SN74HC573AN (u2) connects to x 1, y 2
pin 18 on SN74HC573AN (u3) connects to x 2, y 3

this leaves us figuring out the enable and reset for each SN74HC573AN latch (u1-u8)
as well as the pins for z access, (u-9)

(u9) pins:
pins 1-8 on stc12c5a60s2 map to pins 1-8 on the (u9) darlington array ULN2803APG
these lead (via resistors) to the matching z access darlingtons don't have an enable or reset, you would just drive (for example) pin 1 on the stc12c5a60s2 high to allow any led on z axis 1 to potentially light up

now to figure out the enable and reset pins:
pins 21-28 on the stc12c5a60s2 go to the enable pins on the corresponding (U1-8) SN74HC573AN latch
the OE or reset pin on all the latches is tied to ground, so soon as you take the enable to low, the latch resets...
thus pins 21-28 select the y axis

Warranty void if seal is broken


An arduino uno doesn't have enough pins to run this 8x8x8 cube. but a Mega is kinda costly to tie up.

maybe use an uno or digispark to just send the serial commands to the stc12c5a60s2? kinda ugly solution there...

I did understand that you've been able to send commands to the stc12c5a60s2, not just sending new programs over and over, right?
Warranty void if seal is broken


I haven't had much luck sending the patterns direct to the cube however, i did flash a different firmware over that enabled me to use the serial (i could read it and see what was happening) but there was no visual effect on the cube (wrong firmware).
which leads me to believe we need to implement the serial() in the firmware we have, before we can start sending the cube data.

I don't mind tying up a mega, it's not like the cube runs 24/7. i'll just make a shield and make a dummy socket of sorts to go into the dip socket, so it's plug and play essentially


How may pins does the MPU need ?

You may be able to use something like a Maple Mini  , which has 32 available outputs, and is approximately the same size as that MPU (though the pinout is different)


(See the Maple mini thread in the microcontrollers section, as you can compile for it using version 1.6 of the Arduino IDE.)

The only issue could be that the Maple mini is a 3.3V device, but normally latches operate at 2.5V for high so it should be OK, but you'd need to check the latch spec

Shame this kit doesn't just contain an ATMega328 and 74HC595 shift registers etc to make it Arduino compatible, rather than using some other MPU
Freelance developer and IT consultant


As someone with a 4x4x4 RGB cube - a Seeed Studios Rainbow Cube - I would love to have an 8x8x8 one. You can do some glorious things with a smaller one, but as with so much in computing, it would often be great to have more :)

Two things put me off doing it via a kit: the cost and the soldering. Even though the cost of RGB LEDs has fallen from what they used to be, having 512 of them mean that it's never going to be cheap. And it's at least 2048 bits of soldering just to connect them together. As someone whose sense of smell can barely cope with one bit...

Does this one cope with doing multiple levels of red, green and blue?

It looks from the source code like it can only do eight colours per LED: each component is either on or off, with no PWM allowing considerably more. (In theory, setups that can do PWM typically allow 256 levels for each of RGB, but in practice it's hard to distinguish between more than about ten levels.)

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131