Вы находитесь на странице: 1из 197

(http://cdn.instructables.com/FUX/O1RW/GICYBAOS/FUXO1RWGICYBAOS.LARGE.

jpg)

Createyourown8x8x8LEDCube3dimensionaldisplay!
WebelievethisInstructableisthemostcomprehensivestepbystepguideto
buildan8x8x8LEDCubeeverpublishedontheintertubes.Itwillteachyou
everythingfromtheoryofoperation,howtobuildthecube,totheinnerworkings
ofthesoftware.Wewilltakeyouthroughthesoftwarestepbystep,boththelow
leveldrivers/routinesandhowtocreateawesomeanimations.Thesoftware
aspectofLEDcubesisoftenoverlooked,butaLEDcubeisonlyasawesome

AboutThisInstructable
3,855,842views

Posted:
Jan1,2011

asthesoftwareitruns.

2,995favorites

AbouthalfwaythroughtheInstructable,youwillactuallyhaveafullyfunctional
LEDcube.Theremainingstepswillshowyouhowtocreatethesoftware.

chr(/member/chr/)
Follow

Avideoisworthathousandwords.I'lljustleaveituptothisvideotoconvince
youthatthisisthenextprojectyouwillbebuilding:

License:

1288

(/member/chr/)
Bio: IlikemicrocontrollersandLEDs:D
Morebychr

(/id/ReverseEngineering
RGBLEDBulbwithIRremote)

(/id/Iceboxairconditioner)

(/id/USBcontrolledhome
automationhack)
Tags:
ledcube(/tag/typeid/categorytechnology/keyword
ledcube/)

ImadethisLEDcubetogetherwithmyfriendchiller.Thebuildtookabout4
daysfromsmallscaleprototypingtocompletedcube.Thenanothercoupleof
hourstodebugsomefaultytransistors.
Thesoftwareisprobablyanother45daysofworkcombined.

ledcubeavratmega(/tag/typeid/category
technology/keywordledcubeavratmega/)
microcontroller(/tag/typeid/category
technology/keywordmicrocontroller/)
programmingc(/tag/typeid/category
technology/keywordprogrammingc/)

Addinstructableto:
Group

Step1:Skillsrequired
Related
LEDCube4x4x4(/id/LED
Cube4x4x4/)
bychr(/member/chr/)

CHR's8X8X8LEDCube
Revisitedwith
improvements!(/id/CHRs
8X8X8LEDCube
Revisitedwith
444LedCube(/id/Led
Cube8/)
bypbajusz(/member/pbajusz/)

SimpleLEDCube4xwith
Arduino/328p(/id/Simple
LEDCube4xwith
Arduino328p/)
byakki5230

Makingaflexibleringof
LED's(/id/Makinga
flexibleringofLEDs/)

(http://cdn.instructables.com/FOL/S1PK/GI0TMHA2/FOLS1PKGI0TMHA2.LARGE.jpg)

bycontrechoc
(/member/contrechoc/)

SeeMore(/tag/typeid/?q=)

Atfirstglancethisprojectmightseemlikeanoverlycomplexanddauntingtask.
However,wearedealingwithdigitalelectronicshere,soeverythingiseitheron
oroff!
I'vebeendoingelectronicsforalongtime,andforyearsistruggledwithanalog
circuits.Theanalogcircuitsfailedoverhalfthetimeevenififollowed
instructions.Oneresistororcapacitorwithaslightlywrongvalue,andthecircuit
doesn'twork.
About4yearsago,Idecidedtogivemicrocontrollersatry.Thiscompletely
changedmyrelationshipwithelectronics.Iwentfromonlybeingabletobuild
simpleanalogcircuits,tobeingabletobuildalmostanything!
Adigitalcircuitdoesn'tcareifaresistoris1kohmor2kohm,aslongasitcan
distinguishhighfromlow.Andbelieveme,thismakesitALOTeasiertodo
electronics!
Withthatsaid,therearestillsomethingsyoushouldknowbeforeventuringout
andbuildingthisratherlargeproject.
Youshouldhaveanunderstandingof:
Basicelectronics.(Wewouldrecommendagainstbuildingthisasyourvery
firstelectronicsproject.ButpleasereadtheInstructable.You'llstilllearna
lot!)
Howtosolder.
Howtouseamultimeteretc.
WritingcodeinC(optional.Weprovideafullyfunctionalprogram,readyto
go)
Youshouldalsohavepatienceandagenerousamountoffreetime.

Step2:Componentlist

(http://cdn.instructables.com/FIB/V133/GI0TMHAK/FIBV133GI0TMHAK.LARGE.jpg)

(http://cdn.instructables.com/F8I/9FOL/GI0TK31D/F8I9FOLGI0TK31D.LARGE.jpg)
(http://cdn.instructables.com/FEM/Q0VK/GICYB3TQ/FEMQ0VKGICYB3TQ.LARGE.jpg)

ShowAll12Items

HereiswhatyouneedtomakeaLEDcube:
512xLEDs(plussomeextraformakingmistakes!)
(http://cdn.instructables.com/FHU/MXDO/GI0TK42U/FHUMXDOGI0TK42U.LARGE.jpg)
64xresistors.(seeseparatestepforohmvalue)
1xor2xlargeprototypePCBs.Thetypewithcopper"eyes",seeimage.
1xATmega32microcontroller(youcanalsousethepincompatible
ATmega16)
(http://cdn.instructables.com/FYF/VSSI/GI0TMHAI/FYFVSSIGI0TMHAI.LARGE.jpg)
3xstatusLEDs.Youchoosecolorandsize.
3xresistorsforthestatusLEDs.
8x74HC574ICs
16xPN2222transistors
(http://cdn.instructables.com/FE7/QJ1V/GI0TDOUJ/FE7QJ1VGI0TDOUJ.LARGE.jpg)
16x1kresistors
1x74HC138IC
1xMaximMAX232IC
1x14.7456MHzcrustal
2x22pFceramiccapacitors
16x0.1uFceramiccapacitors
3x1000uFelectrolyticcapacitor
3x10uFelectrolyticcapacitor

1x100uFelectrolyticcapacitors
8x20pinICsockets
1x40pinICsocket
2x16pinICsocket
1x2pinscrewterminal
1x2wirecablewithplugs
9x8pinterminalpins
1x4pinterminalpins,rightangle
2x16pinribboncableconnector
1x10pinribboncableconnector
Ribboncable
2xpushbuttons
2xribboncableplugs
9x8pinfemaleheaderplugs
Serialcableand4pinfemalepinheader
Pieceofwoodfortemplateandbase
8xoptionalpullupresistorsforlayers
5vpowersupply(seeseparatestepforpowersupply)
Totalestimatedbuildcost:67USD.Seeattachedpricelist.

pricelist.xls

(/files/orig/FI7/UP2U/GIJG3QAC/FI7UP2UGIJG3QAC.xls)12KB

Step3:Orderingcomponents

(http://cdn.instructables.com/FOZ/UK3Y/GICYB6W6/FOZUK3YGICYB6W6.LARGE.jpg)

(http://cdn.instructables.com/FR2/AFHF/GICYB6W3/FR2AFHFGICYB6W3.LARGE.jpg)

(http://cdn.instructables.com/FLU/D611/GICYB6W1/FLUD611GICYB6W1.LARGE.jpg)

WeseealotofpeopleaskingforpartnumbersforDigiKey,Mouserorotherbig
(http://cdn.instructables.com/F9G/M4VV/GICYB6W2/F9GM4VVGICYB6W2.LARGE.jpg)
electronicsstores.
Whenyou'reworkingwithhobbyelectronics,youdon'tnecessarilyneedthe
mostexpensivecomponentswiththebestquality.
(http://cdn.instructables.com/FDU/N9GO/GICYB6W0/FDUN9GOGICYB6W0.LARGE.jpg)
Mostofthetime,itismoreimportanttoactuallyhavethecomponentvalueat
handwhenyouneedit.
WearebigfansofbuyingreallycheapcomponentlotsoneBay.Youcanget
assortmentsofresistor,capacitors,transistorsandeverythinginbetween.Ifyou
buythesetypesofassortments,youwillalmostalwayshavethepartsyouneed
(http://cdn.instructables.com/FWL/G825/GICYB6VZ/FWLG825GICYB6VZ.LARGE.jpg)
inyourpartcollection.
For17USDyoucanget2000resistorsof50differentvalues.Greatvalue,and
veryconvenient.
TrydoingsomeBaysearchesandbuysomecomponentsforfutureprojects!
AnotheroneofourfavoritestoresisFuturlec(http://www.futurlec.com/
(http://www.futurlec.com/)).Theyhaveeverythingyouneed.Thethingtheydon't
haveis1000differentversionsofthatthingthatyouneed,sobrowsingtheir
inventoryisalotlessconfusingthanbuyingfromthosebiggercompanies.

Step4:WhatisaLEDcube

(http://cdn.instructables.com/F9W/CPGS/GICYB3QA/F9WCPGSGICYB3QA.LARGE.jpg)

(http://cdn.instructables.com/F7U/FAFE/GI0TK41S/F7UFAFEGI0TK41S.LARGE.jpg)

ALEDcubeislikeaLEDscreen,butitisspecialinthatithasathirddimension,
makingit3D.Thinkofitasmanytransparentlowresolutiondisplays.Innormal

displaysitisnormaltotrytostackthepixelsascloseaspossibleinorderto
makeitlookbetter,butinacubeonemustbeabletoseetroughit,andmore
spacingbetweenthepixels(actuallyit'svoxelssinceitisin3d)isneeded.The
spacingisatradeoffbetweenhoweasythelayersbehinditisseen,andvoxel
fidelity.
SinceitisalotmoreworkmakingaLEDcubethanaLEDdisplay,theyare
usuallylowresolution.ALEDdisplayof8x8pixelsisonly64LEDs,butaLED
cubein8x8x8is512LEDs,anorderofmagnitudehardertomake!Thisisthe
reasonLEDcubesareonlymadeinlowresolution.
ALEDcubedoesnothavetobesymetrical,itispossibletomakea7x8x9,or
evenoddlyshapedones.

Step5:HowdoesaLEDcubework

(http://cdn.instructables.com/FTI/0UCQ/GICYB3A7/FTI0UCQGICYB3A7.LARGE.jpg)

(http://cdn.instructables.com/FIV/IJHX/GICYB39I/FIVIJHXGICYB39I.LARGE.jpg)

ThisLEDcubehas512LEDs.Obviously,havingadedicatedIOportforeach
LEDwouldbeveryimpractical.Youwouldneedamicrocontrollerwith512IO
(http://cdn.instructables.com/FY9/VSJ6/GI0TK33H/FY9VSJ6GI0TK33H.LARGE.jpg)
ports,andrun512wiresthroughthecube.
Instead,LEDcubesrelyonanopticalphenomenoncalledpersistenceofvision
(POV).
Ifyouflashaledreallyfast,theimagewillstayonyourretinaforalittlewhile
aftertheledturnsoff.
Byflashingeachlayerofthecubeoneafteranotherreallyreallyfast,itgivesthe
illusionofa3dimage,whenintfactyouarelookingataseriesof2dimages
stackedontoponeanother.Thisisalsocalledmultiplexing.
(http://cdn.instructables.com/F55/OUWY/GI0TMH4I/F55OUWYGI0TMH4I.LARGE.jpg)
Withthissetup,weonlyneed64(fortheanodes)+8(foreachlayer)IOportsto
controltheLEDcube.
Inthevideo,theprocessissloweddownenoughforyoutoseeit,thenitruns
fasterandfasteruntiltherefreshrateisfastenoughforthecameratocatchthe
POVeffect.

Step6:TheanatomyofaLEDcube

(http://cdn.instructables.com/FHT/WYK3/GI0TDMW9/FHTWYK3GI0TDMW9.LARGE.jpg)

(http://cdn.instructables.com/F4B/H8ND/GI0TK2DZ/F4BH8NDGI0TK2DZ.LARGE.jpg)

Wearegoingtobetalkingaboutanodes,cathodes,columnsandlayers,solets
takeamomenttogetfamiliarwiththeanatomyofaLEDcube.
AnLEDhastwolegs.Onepositive(theanode)andonenegative(cathode).In
ordertolightupanLED,youhavetoruncurrentfromthepositivetothe
negativeleg.(Ifiremembercorrectlytheactualflowofelectronsistheotherway
around.Butlet'ssticktotheflowofcurrentwhichisfrompositivetonegativefor
now).
(http://cdn.instructables.com/FJX/R7WS/GI0TDMW5/FJXR7WSGI0TDMW5.LARGE.jpg)

TheLEDcubeismadeupofcolumnsandlayers.Thecathodelegsofevery
LEDinalayeraresolderedtogether.Alltheanodelegsinonecolumnare
solderedtogether.
Eachofthe64columnsareconnectedtothecontrollerboardwithaseparate
wire.Eachcolumncanbecontrolledindividually.Eachofthe8layersalsohave
aseparatewiregoingtothecontrollerboard.
Eachofthelayersareconnectedtoatransistorthatenablesthecubetoturnon
andofftheflowofcurrentthrougheachlayer.
Byonlyturningonthetransistorforonelayer,currentfromtheanodecolumns
canonlyflowthroughthatlayer.Thetransistorsfortheotherlayersareoff,and
theimageoutputtedonthe64anodewiresareonlyshownontheselected
layer.
Todisplaythenextlayer,simplyturnoffthetransistorforthecurrentlayer,
changetheimageonthe64anodewirestotheimageforthenextlayer.Then
turnonthetransistorforthenextlayer.Rinseandrepeatveryveryfast.
Thelayerswillbereferredtoaslayers,cathodelayersorgroundlayers.
Thecolumnswillbereferredtoascolumns,anodecolumnsoranodes.

Step7:CubesizeandIOportrequirements

(http://cdn.instructables.com/FKD/2RXG/GI0TMG91/FKD2RXGGI0TMG91.LARGE.jpg)

(http://cdn.instructables.com/FM4/9FA0/GI0TMG94/FM49FA0GI0TMG94.LARGE.jpg)

TodriveaLEDcube,youneedtwosetsofIOports.OnetosourcealltheLED
anodecolumns,andonetosinkallthecathodelayers.
Fortheanodesideofthecube,you'llneedx^2IOports,wherex^3isthesizeof
yourLEDcube.Foran8x8x8(x=8),youneed64IOportstodrivetheLED
anodes.(8x8).Youalsoneed8IOportstodrivethecathodes.
KeepinmindthatthenumberofIOportswillincreaseexponentially.Sowillthe
numberofLEDs.YoucanseealistofIOpinrequirementfordifferentcube
sizesintable1.

ForasmallLEDcube,3x3x3or4x4x4,youmightgetawaywithconnectingthe
cathodelayersdirectlytoamicrocontrollerIOpin.Foralargercubehowever,
thecurrentgoingthroughthispinwillbetoohigh.Foran8x8x8LEDcubewith
only10mAperLED,youneedtoswitch0.64Ampere.Seetable2foran
overviewofpowerrequirementsforaLEDlayerofdifferentsizes.Thistable
showsthecurrentdrawwithallLEDson.
Ifyouareplanningtobuildalargercubethan8x8x8orrunningeachLEDat
morethan10ishmA,remembertotakeintoconsiderationthatyourlayer
transistorsmustbeabletohandlethatload.

Step8:IOportexpansion,moremultiplexing

(http://cdn.instructables.com/F84/E01I/GI0TK2FJ/F84E01IGI0TK2FJ.LARGE.jpg)

Wegatheredfromthelaststepthatan8x8x8LEDcuberequires64+8IOlines
tooperate.NoAVRmicrocontrollerwithaDIPpackage(thekindofthrough
holechipyoucaneasilysolderoruseinabreadboard,DualInlinePackage)
havethatmanyIOlinesavailable.
Togetgettherequired64outputlinesneededfortheLEDanodes,wewill

createasimplemultiplexercircuit.Thiscircuitwillmultiplex11IOlinesinto64
outputlines.
Themultiplexerisbuiltbyusingacomponentcalledalatchoraflipflop.Wewill
callthemlatchesfromhereon.
Thismultiplexerusesan8bitlatchICcalled74HC574.Thischiphasthe
followingpins:
8inputs(D07)
8outputs(Q07)
1"latch"pin(CP)
1outputenablepin(OE)
Thejobofthelatchistoserveasakindofsimplememory.Thelatchcanhold8
bitsofinformation,andthese8bitsarerepresentedontheoutputpins.Consider
alatchwithanLEDconnectedtooutputQ0.ToturnthisLEDon,applyV+(1)to
inputD0,thenpulltheCPpinlow(GND),thenhigh(V+).
WhentheCPpinchangesfromlowtohigh,thestateoftheinputD0is"latched"
ontotheoutputQ0,andthisoutputstaysinthatstateregardlessoffuture
changesinthestatusofinputD0,untilnewdataisloadedbypullingtheCPpin
lowandhighagain.
Tomakealatcharraythatcanremembertheon/offstateof64LEDsweneed8
oftheselatches.TheinputsD07ofallthelatchesareconnectedtogetherinan
8bitbus.
Toloadtheon/offstatesofallthe64LEDswesimplydothis:Loadthedataof
thefirstlatchontothebus.pulltheCPpinofthefirstlatchlowthenhigh.Load
thedataofthesecondlatchontothebus.pulltheCPpinofthesecondlatchlow
thenhigh.Loadthedataofthethirdlatchontothebus.pulltheCPpinofthe
thirdlatchlowthenhigh.Rinseandrepeat.
Theonlyproblemwiththissetupisthatweneed8IOlinestocontroltheCPline

foreachlatch.Thesolutionistousea74HC138.ThisIChas3inputlinesand8
outputs.Theinputlinesareusedtocontrolwhichofthe8outputlinesthatwill
bepulledlowatanytime.Therestwillbehigh.Eachouttheoutputsonthe
74HC138isconnectedtotheCPpinononeofthelatches.
Thefollowingpseudocodewillloadthecontentsofabufferarrayontothelatch
array:
//PORTA=databus
//PORTB=addressbus(74HC138)
//charbuffer[8]holds64bitsofdataforthelatcharray
PORTB=0x00//ThispullsCPonlatch1low.
for(i=0i<8i++)
{
PORTA=buffer[i]
PORTB=i+1
}
Theoutputsofthe74HC138areactiveLOW.Thatmeansthattheoutputthatis
activeispulledLOW.Thelatchpin(CP)onthelatchisarisingedgetrigger,
meaningthatthedataislatchedwhenitchangesfromLOWtoHIGH.Totrigger
therightlatch,the74HC138needstostayonestepaheadofthecounteri.Ifit
hadbeenanactiveHIGHchip,wecouldwritePORTB=iYouareprobably
thinking,whathappenswhenthecounterreaches7,thatwouldmeanthatthe
outputonPORTBis8(1000binary)onthelastiterationofthefor()loop.Only
thefirst8bitsofPORTBareconnectedtothe74HC138.SowhenportB
outputs8or1000inbinary,the74HC138reads000inbinary,thuscompleting
itscycle.(itstartedat0).The74HC138nowoutputsthefollowingsequence:12
345670,thusgivingachangefromLOWtoHIGHforthecurrentlatch
accordingtocounteri.

multiplex_theoretical.sch

(/files/orig/FHJ/ASA2/GICYB6DA/FHJASA2GICYB6DA.tmp)21KB

Step9:IOportexpansion,alternativesolution

(http://cdn.instructables.com/FMS/0ULI/GI0TMG9R/FMS0ULIGI0TMG9R.LARGE.jpg)

Thereisanothersolutionforprovidingmoreoutputlines.Wewentwiththelatch
basedmultiplexerbecausewehad8latchesavailablewhenbuildingtheLED
cube.
Youcanalsouseaserialinparalleloutshiftregistertoget64outputlines.
74HC164isan8bitshiftregister.Thischiphastwoinputs(mayalsohavean
outputenablepin,butwewillignorethisinthisexample).
data
clock
Everytimetheclockinputchangesfromlowtohigh,thedatainQ6ismoved
intoQ7,Q5intoQ6,Q4intoQ5andsoon.Everythingisshiftedonepositionto
theright(assumingthatQ0istotheleft).Thestateofthedatainputlineis
shiftedintoQ0.
Thewayyouwouldnormallyloaddataintoachiplikethis,istotakeabyteand
bitshiftitintothechiponebitatatime.ThisusesalotofCPUcycles.However,
wehavetouse8ofthesechipstogetourdesired64outputlines.Wesimply
connectthedatainputofeachshiftregistertoeachofthe8bitsonaportonthe
microcontroller.Alltheclockinputsareconnectedtogetherandconnectedtoa
pinonanotherIOport.
Thissetupwilluse9IOlinesonthemicrocontroller.
Intheprevioussolution,eachbyteinourbufferarraywasplacedinit'sown
latchIC.Inthissetupeachbytewillbedistributedoverall8shiftregisters,with
onebitineach.
Thefollowingpseudocodewilltransferthecontentsofa64bitbufferarrayto
theshiftregisters.
//PORTA:bit0connectedtoshiftregister0'sdatainput,bit1toshiftregister1
andsoon.

//PORTB:bit0connectedtoalltheclockinputs
//charbuffer[8]holds64bitsofdata
for(i=0i<8i++)
{
PORTB=0x00//Pulltheclocklinelow,sowecanpullithighlaterto
triggertheshiftregister
PORTA=buffer[i]//LoadabyteofdataontoportA
PORTB=0x01//Pulltheclocklinehightoshiftdataintotheshift
registers.
}
Thisisperhapsabettersolution,butwehadtousewhatwehadavailablewhen
buildingthecube.Forthepurposesofthisinstructable,wewillbeusingalatch
basedmultiplexerforIOportexpansion.Feelfreetousethissolutioninsteadif
youunderstandhowtheybothwork.
Withthissetup,thecontentsofthebufferwillbe"rotated"90degreescompared
tothelatchbasedmultiplexer.Wireupyourcubeaccordingly,orsimplyjustturn
it90degreestocompensate)

multiplex_alternative.sch

(/files/orig/FAH/098K/GICYB6DK/FAH098KGICYB6DK.tmp)10KB

Step10:Powersupplyconsiderations

(http://cdn.instructables.com/FNB/P4Z6/GI0TK41W/FNBP4Z6GI0TK41W.LARGE.jpg)

Thisstepiseasytooverlook,asLEDsthemselvesdon'tdrawthatmuchcurrent.
Butrememberthatthiscircuitwilldraw64timesthemAofyourLEDsiftheyare
allon.Inadditiontothat,theAVRandthelatchICsalsodrawscurrent.
TocalculatethecurrentdrawofyourLEDs,connectaledtoa5Vpowersupply
withtheresistoryouintendtouse,andmeasurethecurrentinmA.Multiplythis
numberby64,andyouhavethepowerrequirementsforthecubeitself.Addto
that1520mAfortheAVRandacoupleofmAforeachlatchIC.

Ourfirstattemptatapowersupplywastouseastepdownvoltageregulator,
LM7805,witha12Vwallwart.Atover500mAand12Vinput,thischipbecame
extremelyhot,andwasn'tabletosupplythedesiredcurrent.
Welaterremovedthischip,andsolderedawirefromtheinputtotheoutputpin
wherethechipusedtobe.
Wenowusearegulatedcomputerpowersupplytogetastablehighcurrent5V
supply.

Step11:Buyapowersupply

(http://cdn.instructables.com/FAY/1SNJ/GI0TDMXN/FAY1SNJGI0TDMXN.LARGE.jpg)

(http://cdn.instructables.com/FL7/ZQWV/GI0TK2FS/FL7ZQWVGI0TK2FS.LARGE.jpg)

Ifyoudon'thavethepartsnecessarytobuilda5VPSU,youcanbuyone.

eBayisagreatplacetobuythesethings.
Searchfor"5vpowersupply"andlimitthesearchto"Business&Industrial",and
you'llgetalotofsuitablepowersupplies.About15buckswillgetyouanice
PSU.

Step12:Buildapowersupply

(http://cdn.instructables.com/FSC/AS9Q/GI0TK41X/FSCAS9QGI0TK41X.LARGE.jpg)

(http://cdn.instructables.com/FOV/5AJW/GICYB3QU/FOV5AJWGICYB3QU.LARGE.jpg)

AcoupleofyearsbeforewebuilttheLEDcube,wemadeourselfanicelittlelab
powersupplyfromanoldexternalSCSIdrive.Thisiswhatwehavebeenusing
topowertheLEDcube.
PCpowersuppliesarenice,becausetheyhaveregulated12Vand5Vrailswith
highAmpereratings.
YoucanuseeitheraregularATorATXpowersupplyorandoldexternalhard
driveenclosure.
(http://cdn.instructables.com/FTP/ON1Y/GI0TK41Y/FTPON1YGI0TK41Y.LARGE.jpg)
IfyouwanttouseanATXpowersupply,youhavetoconnectthegreenwireon
themotherboardconnectortoground(black).Thiswillpoweritup.
Externalharddriveenclosuresareespeciallynicetouseaspowersupplies.
Theyalreadyhaveaconvenientenclosure.Theonlythingyouhavetodoisto
addexternalpowerterminals.
Powersupplieshavealotofwires,buttheeasiestplacetogetthepoweryou
needisthroughamolexconnector.Thatisthekindofplugyoufindonhard
drives(beforetheageofSATA).
BlackisGNDYellowis+12VRedis+5V
HereisanimageofourlabPSU.Wehave12Voutput,5Voutputwithan
amperemeterand5Voutputwithoutanamperemeter.Weusethesecond5V
outputtopoweran80mmPCfantosuckorblowfumesawaywhenwesolder.
Wewon'tgetintoanymoredetailsofhowtomakeapowersupplyhere.I'm
sureyoucanfindanotherinstructableonhowtodothat.

Step13:ChooseyourLEDs

(http://cdn.instructables.com/F4P/ZYNZ/GI0TMHA5/F4PZYNZGI0TMHA5.LARGE.jpg)

(http://cdn.instructables.com/FB7/MNVU/GICYB3R9/FB7MNVUGICYB3R9.LARGE.jpg)

TherearemanythingstoconsiderwhenchoosingLEDs.
(http://cdn.instructables.com/F7C/E14Y/GICYB3RH/F7CE14YGICYB3RH.LARGE.jpg)

1)
YouwanttheLEDcubetobeequallyvisiblefromallsides.Thereforewe
stronglyrecommendusingdiffusedLEDs.AclearLEDwillshootthemajorityof
it'slightoutthetopoftheLED.AdiffusedLEDwillbemoreorlessequallybright
fromallsides.ClearLEDsalsocreateanotherproblem.Ifyourcubeismadeup
ofclearLEDs.TheLEDswillalsopartiallyilluminatetheLEDsabovethem,
sincemostofthelightisdirectedupwards.Thiscreatessomeunwanted
ghostingeffects.
(http://cdn.instructables.com/F1U/XKRK/GI0TDOU4/F1UXKRKGI0TDOU4.LARGE.jpg)

WeactuallyordereddiffusedLEDsfromeBay,butgot1000clearLEDsinstead.
ShippingthembacktoChinatoreceiveareplacementwouldhavetakentoo
muchtime,sowedecidedtousedtheclearLEDsinstead.Itworksfine,butthe
cubeisalotbrighterwhenviewedfromthetopasopposedtothesides.
TheLEDsweorderedfromeBaywereactuallydescribedas"DefusedLEDs".
Maybeweshouldhavetakenthehint)Defusingissomethingyoudotoabomb
whenyouwanttopreventitfromblowingup,hehe.
2)
LargerLEDsgivesyouabiggerandbrighterpixel,butsincesincethecubeis8
layersdeep,youwantenoughroomtoseeallthewaythroughtothefurthest
level.Wewentwith3mmLEDsbecausewewantedthecubetobeas
"transparent"aspossible.Ourrecommendationistouse3mmdiffusedLEDs.

3)
Youcanbuyverycheaplotsof1000LEDsoneBay.Butkeepinmindthatthe
qualityoftheproductmaybereflectedinit'sprice.Wethinkthatthereisless
chanceofLEDmalfunctionifyoubuybetterquality/moreexpensiveLEDs.
4)
SquareLEDswouldprobablylookcoolto,butthenyouneedtomakea
solderingtemplatethatcanaccommodatesquareLEDs.With3mmroundLEDs,
allyouneedisa3mmdrillbit.
5)
Sincethecubereliesonmultiplexingandpersistenceofvisiontocreateimages,
eachlayerisonlyturnedonfor1/8ofthetime.Thisiscalleda1/8dutycycle.To
compensateforthis,theLEDshavetobebrightenoughtoproducethewanted
brightnesslevelat1/8dutycycle.
6)
Leglength.ThecubedesigninthisinstructableusesthelegsoftheLEDs
themselvesastheskeletonforthecube.TheleglengthoftheLEDsmustbe
equaltoorgreaterthanthedistanceyouwantbetweeneachLED.

Step14:Chooseyourresistors

(http://cdn.instructables.com/F5S/0LOM/GICYB3SB/F5S0LOMGICYB3SB.LARGE.jpg)

Therearethreethingstoconsiderwhenchoosingthevalueofyourresistors,the
LEDs,the74HC574thatdrivetheLEDs,andthetransistorsusedtoswitchthe

layersonandoff.
1)
IfyourLEDscamewithadatasheet,thereshouldbesomeampereratingsin
there.Usually,therearetworatings,onemAforcontinuousload,andmAfor
burstloads.TheLEDswillberunningat1/8dutycycle,soyoucanrefertothe
burstrating.
2)
The74HC574alsohassomemaximumratings.IfalltheLEDsononeanode
columnareon,thischipwillsupplycurrent8/8ofthetime.Youhavetokeep
withinthespecifiedmaximummAratingfortheoutputpins.Ifyoulookinthe
datasheet,Youwillfindthisline:DCOutputSourceorSinkCurrentperOutput
Pin,IO:25mA.AlsothereisaVCCorGNDcurrentmaximumratingof50mA.In
ordernottoexceedthis,yourLEDscanonlyrunat50/8mAsincethe74HC574
has8outputs.Thisgivesyou6.25mAtoworkwith.
3)
Thetransistorshavetoswitchonandoff64xthemAofyourLEDs.Ifyour
LEDsdraw20mAeach,thatwouldmeanthatyouhavetoswitchonandoff1.28
Ampere.
Theonlytransistorswehadavailablehadamaximumratingof400mA.
Weendedupusingresistorsof100ohms.
WhileyouarewaitingforyourLEDcubepartstoarriveinthemail,youcanbuild
theguyinthepicturebelow:http://www.instructables.com/id/Resistorman/
(http://www.instructables.com/id/Resistorman/)

Step15:Choosethesizeofyourcube

(http://cdn.instructables.com/FOT/II3A/GI0TDN1V/FOTII3AGI0TDN1V.LARGE.jpg)

WewantedtomaketheLEDcubeusingasfewcomponentsaspossible.We
hadseensomepeopleusingmetalrodsfortheirdesigns,butwedidn'thaveany
metalrods.Manyofthemetalroddesignsalsolookedalittlecrooked.
Wefiguredthattheeasiestwaytobuildaledcubewouldbetobendthelegsof
theLEDssothatthelegsbecomethescaffoldingthatholdstheLEDsinplace.

WebentthecathodelegononeoftheLEDsandmeasuredittobe26mmfrom
thecenteroftheLED.BychoosingaLEDspacingof25mm,therewouldbea
1mmoverlapforsoldering.(1inch=25.4mm)
Withasmall3mmLED25mmbetweeneachledgaveusplentyofopenspace
insidethecube.Seeingallthewaythroughtothefurthestlayerwouldn'tbea
problem.Wecouldhavemadethecubesmaller,butthenwewouldhavetocut
everysingleleg,andvisibilityintothecubewouldbecompromised.
OurrecommendationistousethemaximumspacingthatyourLEDcanallow.
Add1mmmarginforsoldering.

Step16:Howtomakestraightwire

(http://cdn.instructables.com/FSF/CNSP/GI0TMGB4/FSFCNSPGI0TMGB4.LARGE.jpg)

InordertomakeanicelookingLEDCube,youneedsomestraightsteelwire.
Theonlywirewehadwasonspools,soithadtobestraightened.
Ourfirstattemptatthisfailedhorribly.Wetriedtobenditintoastraightwire,but
nomatterhowmuchwebent,itjustwasn'tstraightenough.
Thenwerememberedanepisodeof"Howit'smade"fromtheDiscovery
Channel.Theepisodewasabouthowtheymakesteelwire.Theystartoutwith

aspoolofreallythickwire,thentheypullitthroughsmallerandsmallerholes.
Werememberedthatthewirewastotallystraightandsymmetricalafterbeing
pulledlikethat.
Sowefiguredweshouldgivepullingatry,anditworked!100%straightmetal
wirefromaspool!
Hereishowyoudoit.
cutofthelengthofwireyouneedfromthespool,plusaninchortwo.
Removetheinsulation,ifany.
Getafirmgripofeachendofthewirewithtwopairsofpliers
Pullhard!
Youwillfeelthewirestretchalittlebit.
Youonlyneedtostretchitacoupleofmillimeterstomakeitniceandstraight.
Ifyouhaveavice,youcansecureoneendintheviceanduseonepairofpliers.
Thiswouldprobablybealoteasier,butwedon'townavice.

Step17:Practiceinsmallscale

(http://cdn.instructables.com/FJN/F0KM/FE7ITU05/FJNF0KMFE7ITU05.LARGE.jpg)

WheneverMythBustersaretestingacomplexmyth,theystartbysomesmall
scaleexperiments.
Werecommendthatyoudothesamething.
Beforewebuiltthe8x8x8LEDcube,westartedbymakingasmallerversionof
it,4x4x4.Bymakingthe4x4x4versionfirst,youcanperfectyourcubesoldering
techniquebeforestartingonthebigone.

Checkoutour4x4x4LEDcubeinstructableforinstructionsonbuildingasmaller
"prototype".
http://www.instructables.com/id/LEDCube4x4x4/
(http://www.instructables.com/id/LEDCube4x4x4/)

Step18:Buildthecube:createajig

(http://cdn.instructables.com/FEM/G3OZ/GI0TDN4A/FEMG3OZGI0TDN4A.LARGE.jpg)

(http://cdn.instructables.com/F51/ATJT/GI0TK2HA/F51ATJTGI0TK2HA.LARGE.jpg)

InordertomakeanicelookingLEDcube,itisimportantthatitiscompletely
symmetrical,thatthespacebetweeneachLEDisidentical,andthateachLED
(http://cdn.instructables.com/FRY/BMXF/GI0TK2H9/FRYBMXFGI0TK2H9.LARGE.jpg)
pointsthesameway.Theeasiestwaytoaccomplishthisistocreatea
temporarysolderingjig/template.
1)
Findapieceofwoodorplasticthatislargerthanthesizeofyourcube.
2)
FindadrillbitthatmakesaholethatfitsaLEDsnuglyinplace.Youdon'twantit
tobetotight,asthatwouldmakeitdifficulttoremovethesolderedlayerfrom
thejigwithoutbendingit.Iftheholesaretoobig,someoftheLEDsmightcome
outcrooked.
(http://cdn.instructables.com/FPR/52ON/GI0TMGC5/FPR52ONGI0TMGC5.LARGE.jpg)
3)
Usearulerandanangleirontodrawupagridof8by8linesintersectingat64
points,usingtheLEDspacingdeterminedinapreviousstep.
4)
Useasharppointyobjecttomakeindentionsateachintersection.These
indentionswillpreventthedrillfromslidingsidewayswhenyoustartdrilling.
5)
Drilloutalltheholes.

6)
TakeanLEDandtryeveryholeforsize.Iftheholeistoosnug,carefullydrillit
againuntiltheLEDfitssnuglyandcanbepulledoutwithoutmuchresistance.
7)
Somewherenearthemiddleofoneofthesides,drawasmallmarkorarrow.A
steelwirewillbesolderedinhereineverylayertogivethecubesomeextra
stiffening.

Step19:Buildthecube:solderingadvice

(http://cdn.instructables.com/FAX/RZD9/GI0TDOUE/FAXRZD9GI0TDOUE.LARGE.jpg)

(http://cdn.instructables.com/FR4/B3EM/GI0TMHA8/FR4B3EMGI0TMHA8.LARGE.jpg)

YouaregoingtobesolderingVERYclosetotheLEDbody,andyouare
probablygoingtobeusingreallycheapLEDsfromeBay.LEDsdon'tlikeheat,

cheapLEDsprobablymoresothanothers.Thismeansthatyouhavetotake
someprecautionsinordertoavoidbrokenLEDs.
Solderingironhygiene
Firstofall,youneedtokeepyoursolderingironniceandclean.Thatmeans
wipingitonthespongeeverytimeyouuseit.Thetipofyoursolderingiron
shouldbecleanandshiny.Whenevertheyouseethetipbecomingdirtywith
fluxoroxidizing,thatmeansloosingit'sshinyness,youshouldcleanit.Evenif
youareinthemiddleofsoldering.HavingacleansolderingtipmakesitALOT
easiertotransferheattothesolderingtarget.
Solderingspeed
WhensolderingsoclosetotheLEDbody,youneedtogetinandoutquickly.
Wipeyourironclean.Applyatinyamountofsoldertothetip.Touchthepartyou
wanttosolderwiththesideofyourironwhereyoujustputalittlesolder.Letthe
targetheatupfor0.51seconds,thentouchtheothersideofthetargetyouare
solderingwiththesolder.Youonlyneedtoapplyalittlebit.Onlythesolderthat
istouchingthemetalofbothwireswillmakeadifference.Abigblobofsolder
willnotmakethesolderjointanystronger.Removethesolderingiron
immediatelyafterapplyingthesolder.
Mistakesandcooldown
Ifyoumakeamistake,forexampleifthewiresmovebeforethesolderhardens
oryoudon'tapplyenoughsolder.Donottryagainrightaway.Atthispointthe
LEDisalreadyveryhot,andapplyingmoreheatwiththesolderingironwillonly
makeithotter.ContinuewiththenextLEDandletitcooldownforaminute,or
blowonittoremovesomeheat.
Solder
WerecommendusingathinsolderforsolderingtheLEDs.Thisgivesyoualot
morecontrol,andenableyoutomakenicelookingsolderjointswithoutlarge
blobsofsolder.Weuseda0.5mmgaugesolder.Don'tusesolderwithoutflux.

Ifyoursolderisveryoldandthefluxisn'tcleaningthetargetproperly,getnewer
solder.Wehaven'texperiencedthis,butwehaveheardthatitcanhappen.
Areweparanoid?
Whenbuildingthe8x8x8LEDCube,wetestedeachandeveryLEDbefore
usingitinthecube.WealsotestedeveryLEDafterwefinishedsolderinga
layer.SomeoftheLEDsdidn'tworkafterbeingsolderedinplace.We
consideredthesethingsbeforemakingasinglesolderjoint.Evenwithcareful
soldering,someLEDsweredamaged.
ThelastthingyouwantisabrokenLEDnearthecenterofthecubewhenitis
finished.Thefirstandsecondlayerfromtheoutsidecanbefixedafterwards,but
anyfurtherinthanthat,andyou'llneedendoscopicsurgicaltools)

Step20:Buildthecube:testtheLEDs

(http://cdn.instructables.com/FEW/IH1E/GI0TK33N/FEWIH1EGI0TK33N.LARGE.jpg)

WegotourLEDsfromeBay,reallycheap!
WetestedsomeoftheLEDbeforewestartedsoldering,andrandomlystumbled
onaLEDthatwasalotdimmerthantherest.SowedecidedtotesteveryLED
beforeusingit.WefoundacoupleofdeadLEDsandsomethatweredimmer
thantherest.
ItwouldbeverybadtohaveadimLEDinsideyourfinishedLEDcube,sospend

thetimetotesttheLEDsbeforesoldering!Thismightbelessofaproblemifyou
areusingLEDsthataremoreexpensive,butwefounditworthwhiletotestour
LEDs.
Getoutyourbreadboard,connectapowersupplyandaresistor,thenpopthe
LEDsinoneatatime.YoumightalsowanttohaveanotherLEDwithitsown
resistorpermanentlyonthebreadboardwhiletesting.Thismakesiteasierto
spotdifferencesinbrightness.

Step21:Buildthecube:solderalayer

(http://cdn.instructables.com/FYH/EBS4/GI0TMGE1/FYHEBS4GI0TMGE1.LARGE.jpg)

(http://cdn.instructables.com/FCQ/KLVJ/GI0TMGDW/FCQKLVJGI0TMGDW.LARGE.jpg)

(http://cdn.instructables.com/FXA/85QT/GI0TMGFF/FXA85QTGI0TMGFF.LARGE.jpg)

ShowAll13Items

(http://cdn.instructables.com/FWP/5C93/GI0TMGGL/FWP5C93GI0TMGGL.LARGE.jpg)

Eachlayerismadeupof8columnsofLEDsheldtogetherbythelegsofeach
LED.AtthetopofeachlayereachLEDisrotated90degreesclockwise,sothat
thelegconnectswiththetopLEDofthenextcolumn.Onthecolumntotheright
(http://cdn.instructables.com/FVW/932Y/GICYAZHY/FVW932YGICYAZHY.LARGE.jpg)
thislegwillstickoutofthesideofthelayer.Weleavethisinplaceanduseitto
connectgroundwhentestingalltheLEDsinalaterstep.
1)Prepare64LEDs
BendthecathodelegofeachLED90degrees.Makesurethelegsarebentin
thesamedirectiononalltheLEDs.LookingattheLEDsittinginaholeinthe
templatewiththenotchtotheright,webentthelegupwards.
(http://cdn.instructables.com/F3Q/IEC8/GI0TMGCZ/F3QIEC8GI0TMGCZ.LARGE.jpg)

2)Startwiththerowatthetop
StartbyplacingthetoprightLEDinthetemplate.Thenplacetheonetotheleft,
positioningitsothatit'scathodelegistouchingthecathodelegoftheprevious
LED.RinseandrepeatuntilyoureachtheleftLED.Solderallthejoints.
3)Solderall8columns
Ifyouarerighthanded,werecommendyoustartwiththecolumntotheleft.
Thatwayyourhandcanrestonthewoodentemplatewhenyousolder.Youwill
needasteadyhandwhensolderingfreehandlikethis.StartbyplacingtheLED
secondfromthetop,aligningitsoit'slegtouchesthesolderjointfromthe

previousstep.ThenplacetheLEDbelowthatsothatthecathodelegtouches
theLEDabove.Repeatuntilyoureachthebottom.Solderallthejoints.
4)Addbraces
Younowhavealayerthatlookslikeacomb.Atthispointthewholethingisvery
flimsy,andyouwillneedtoaddsomesupport.Weusedonebracingnearthe
bottomandonenearthemiddle.Takeastraightpeaceofwire,roughlyalignit
whereyouwantitandsolderoneendtothelayer.Finetunethealignmentand
soldertheotherendinplace.Now,makesolderjointstotheremaining6
columns.Dothisforbothbraces.
5)TestalltheLEDs
Thisiscoveredinthenextstep.Justmentioningheresoyoudon'tremovethe
layerjustyet.
6)Removethelayer
ThefirstlayerofyourLEDcubeisalldone,nowallyouhavetodoisremoveit
fromthetemplate.Dependingonthesizeofyourholes,someLEDsmighthave
moreresistancewhenyoutrytopullitout.Simplygrabbingbothendsofthe
layerandpullingwouldprobablybreakthewholethingifacoupleoftheLEDs
arestuck.
StartbyliftingeverysingleLEDacoupleofmillimeters.Justenoughtofeelthat
thereisn'tanyresistance.WhenalltheLEDsarefreedfromtheirholes,trylifting
itcarefully.Ifitisstillstuck,stopandpullthestuckLEDsout.
Repeat8times!
Noteonimages:
Ifyouarehavingtroubleseeingthedetailinanyofourpictures,youcanviews
thefullresolutionbyclickingonthelittleiiconinthetopleftcornerofevery
image.Allourcloseuppicturesaretakenwithaminitripodandshouldhave

excellentmacrofocus.Ontheimagepage,choosetheoriginalsizefromthe
"Availablesizes"menuonthelefthandside.

Step22:Buildthecube:testthelayer

(http://cdn.instructables.com/FIY/J2SY/GI0TMGJ2/FIYJ2SYGI0TMGJ2.LARGE.jpg)

SolderingthatclosetothebodyoftheLEDcandamagetheelectronicsinside.
WestronglyrecommendthatyoutestallLEDsbeforeproceeding.
Connectgroundtothetabyouleftstickingoutattheupperrightcorner.Connect
awireto5Vthrougharesistor.UseanyresistorthatlightstheLEDupand
doesn'texceeditsmaxmAratingat5V.470Ohmwouldprobablyworkjustfine.
Takethewireandtapitagainstall64anodelegsthatarestickingupfromyour
template.IfaLEDdoesn'tflashwhenyoutapit,thatmeansthatsomethingis
wrong.
1)Yoursolderingisn'tconductingcurrent.
2)TheLEDwasoverheatedandisbroken.
3)Youdidn'tmakeaproperconnectionbetweenthetestwireandtheled.(try
again).
Ifeverythingchecksout,pullthelayerfromthecubeandstartsolderingthenext
one.

Step23:Buildthecube:straigthenthepins

(http://cdn.instructables.com/FET/NJR0/GI0TMGKA/FETNJR0GI0TMGKA.LARGE.jpg)

(http://cdn.instructables.com/F4M/0QHY/GI0TMGKV/F4M0QHYGI0TMGKV.LARGE.jpg)

(http://cdn.instructables.com/FWO/UIPD/GI0TMGJR/FWOUIPDGI0TMGJR.LARGE.jpg)

Inouropinion,aLEDcubeisapieceofartandshouldbeperfectlysymmetrical
andstraight.IfyoulookattheLEDsinyourtemplatefromtheside,theyare
(http://cdn.instructables.com/FAA/LBKF/GI0TMGJT/FAALBKFGI0TMGJT.LARGE.jpg)
probablybentinsomedirection.
Youwantallthelegstopointstraightup,ata90degreeanglefromthe
template. (http://cdn.instructables.com/FBA/YE5U/GI0TMGK1/FBAYE5UGI0TMGK1.LARGE.jpg)
Whilelookingatthetemplatefromtheside,straightenallthelegs.Thenrotate
thetemplate90degrees,toviewitfromtheotherside,thendothesame
process.
Younowhaveaperfectlayerthatisreadytoberemovedfromthetemplate.
(http://cdn.instructables.com/FDU/97KW/GI0TMGKW/FDU97KWGI0TMGKW.LARGE.jpg)

Step24:Buildthecube:bendthepins

(http://cdn.instructables.com/F4Z/FIYQ/GISO5193/F4ZFIYQGISO5193.LARGE.jpg)

(http://cdn.instructables.com/FDM/2K6V/GI0TMGLZ/FDM2K6VGI0TMGLZ.LARGE.jpg)

IntheLEDcubecolumns,wewanteachLEDtositcenteredpreciselyabovethe
LEDsbelow.ThelegsontheLEDscomeoutfromtheLEDbodyhalfa
(http://cdn.instructables.com/F9V/CTZL/GI0TMGLQ/F9VCTZLGI0TMGLQ.LARGE.jpg)
millimeterorsofromtheedge.Tomakeasolderjoint,wehavetobendthe
anodelegsothatittouchestheanodelegontheLEDbelow.
Makeabendintheanodelegtowardsthecathodelegapproximately3mmfrom
theendoftheleg.ThisisenoughforthelegtobendaroundtheLEDbelowand
makecontactwithit'sanodeleg.

(http://cdn.instructables.com/FJL/OZ5V/GI0TMGLP/FJLOZ5VGI0TMGLP.LARGE.jpg)
Step25:Buildthecube:solderthelayerstogether

(http://cdn.instructables.com/FSU/YYBT/GICYAZPM/FSUYYBTGICYAZPM.LARGE.jpg)

(http://cdn.instructables.com/FJB/6THL/GI0TMGN4/FJB6THLGI0TMGN4.LARGE.jpg)

(http://cdn.instructables.com/FSU/XWOI/GI0TMGN5/FSUXWOIGI0TMGN5.LARGE.jpg)

ShowAll10Items

(http://cdn.instructables.com/FNW/MWL7/GICYAZQK/FNWMWL7GICYAZQK.LARGE.jpg)

Nowcomesthetrickypart,solderingitalltogether!
Thefirsttwolayerscanbequiteflimsybeforetheyaresolderedtogether.You
(http://cdn.instructables.com/FQ0/8FBN/GI0TMGN6/FQ08FBNGI0TMGN6.LARGE.jpg)
maywanttoputthefirstlayerbackinthetemplatetogiveitsomestability.
Inordertoavoidtotaldisaster,youwillneedsomethingtoholdthelayerinplace
beforeitissolderedinplace.Luckily,thewidthofa9Vbatteryisprettycloseto
25mm.Probablycloserto25.526mm,butthat'sOK.
Warning:The9voltsfroma9VbatterycaneasilyoverloadtheLEDsifthe
(http://cdn.instructables.com/FY9/34UO/GICYAZPB/FY934UOGICYAZPB.LARGE.jpg)
contactsonthebatterycomesincontactwiththelegsoftheLEDs.Wetaped
overthebatterypolestoavoidaccidentallyruiningtheLEDsweweresoldering.
Wehadplentyof9Vbatterieslyingaround,soweusedthemastemporary
supports.
Startbyplacinga9Vbatteryineachcorner.Makesureeverythingisaligned
perfectly,thensolderthecornerLEDs.
NowsolderalltheLEDsaroundtheedgeofthecube,movingthe9Vbatteries
alongasyougoaround.Thiswillensurethatthelayersaresolderedperfectly
paralleltoeachother.

Nowmovea9Vbatterytothemiddleofthecube.Justslideitinfromoneofthe
sides.SolderacoupleoftheLEDsinthemiddle.
Thewholethingshouldbeprettystableatthispoint,andyoucancontinue
solderingtherestoftheLEDswithoutusingthe9Vbatteriesforsupport.
However,ifitlookslikesomeoftheLEDsaresaggingalittlebit,slideina9V
batterytoliftthemup!
Whenyouhavesolderedallthecolumns,itistimetotesttheLEDsagain.
Rememberthattabstickingoutfromtheupperrightcornerofthelayer,thatwe
toldyounottoremoveyet?Nowit'stimetouseit.Takeapieceofwireand
solderthetabofthebottomlayertothetabofthelayeryoujustsolderedin
place.
Connectgroundtothethegroundtab.
Testeachledusingthesamesetupasyouusedwhentestingtheindividual
layers.Sincethegroundlayershavebeenconnectedbythetesttabs,andall
theanodesineachcolumnsareconnectedtogether,allLEDsinacolumn
shouldlightupwhenyouapplyvoltagetothetopone.IftheLEDsbelowitdoes
notlightup,itprobablymeansthatyouforgotasolderjoint!ItisALOTbetterto
figurethisoutatthispoint,ratherthanwhenallthelayersaresolderedtogether.
Thecenterofthecubeisvirtuallyimpossibletogettowithasolderingiron.
Younowhave2/8ofyourLEDcubesolderedtogether!Yay!
Forthenext6layers,usetheexactsameprocess,butspendevenmoretime
aligningthecornerLEDsbeforesolderingthem.Lookatthecubefromabove,
andmakesurethatallthecornerLEDsareonastraightlinewhenlookingat
themfromabove.

Rinseandrepeat!

Step26:Buildthecube:createthebase

(http://cdn.instructables.com/FD4/UR9R/GI0TK2M6/FD4UR9RGI0TK2M6.LARGE.jpg)

(http://cdn.instructables.com/FR4/HJCM/GICYAZVW/FR4HJCMGICYAZVW.LARGE.jpg)

Wedidn'thaveanyfancytoolsatourdisposaltocreateafancystandorboxfor
ourLEDcube.Instead,wemodifiedthetemplatetoworkasabaseforthecube.
(http://cdn.instructables.com/FTC/Q6FC/GI0TK2M9/FTCQ6FCGI0TK2M9.LARGE.jpg)

WeencourageyoutomakesomethingcoolerthanwedidforyourLEDcube!
Forthetemplate,weonlydrilledacoupleofmmintothewood.Totransformthe
templateintoabase,wejustdrilledalltheholesthroughtheboard.Thenwe
drilled8smallerholesforthe8cathodewiresrunninguptothe8cathode
layers.
Ofcourse,youdon'twanttohaveyourLEDcubeonawoodcoloredbase.We
didn'thaveanyblackpaintlyingaround,butwedidfindagiantblackmagic
(http://cdn.instructables.com/FJZ/6KGY/GICYAZW5/FJZ6KGYGICYAZW5.LARGE.jpg)
marker!Stainingthewoodblackwithamagicmarkerworkedsurprisinglywell!I
thinktheoneweusedhada10mmpoint.

Step27:Buildthecube:mountthecube

(http://cdn.instructables.com/FGZ/RAUG/GI0TDNGW/FGZRAUGGI0TDNGW.LARGE.jpg)

Mountthecube.Thatsoundsveryeasy,butit'snot.Youhavetoalign64LED
legstoslidethrough64holesatthesametime.It'slikethreadinganeedle,
times64.
Wefounditeasiesttostartwithoneend,thengraduallypoppingthelegsinto
place.UseapenorsomethingtopokeattheLEDlegsthatmisstheirholes.
Onceall64LEDlegsarepokingthroughthebase,carefullyturnitonit'sside.

Thenbendall64legs90degrees.Thisisenoughtoholdthecubefirmly
mountedtothebase.Noneedforglueoranythingelse.

Step28:Buildthecube:cathoderisers

(http://cdn.instructables.com/FBD/G9GB/GI0TDOUF/FBDG9GBGI0TDOUF.LARGE.jpg)

(http://cdn.instructables.com/FKN/0CRX/GICYB3SX/FKN0CRXGICYB3SX.LARGE.jpg)

YounowhaveaLEDcubewith64anodeconnectionsontheundersideofthe
base.Butyouneedtoconnectthegroundlayerstoo.

Rememberthose8smallholesyoudrilledinapreviousstep?Wearegoingto
usethemnow.
Makesomestraightwireusingthemethodexplainedinapreviousstep.
Westartwithgroundforlayer0.Takeashortpieceofstraightwire,Makea
bendapproximately10mmfromtheend.Pokeitthroughtheholeforground
layer0.Leave10mmpokingthroughtheundersideofthebase.Positionitso
thatthebendyoumaderestsonthebackwireofgroundlayer0.Nowsolderit
inplace.
Layer1through7arealittletrickier.Weusedahelpinghandtoholdthewirein
placewhilesoldering.
Takeastraightpieceofwireandbendit90degrees10mmfromtheend.Then
cutittolengthsothat10mmofwirewillpokeoutthroughtheundersideofthe
base.
Pokethewirethroughtheholeandletthewirerestonthebackwireofthelayer
youareconnecting.Clampthehelpinghandontothewire,thensolderitin
place.
Rinseandrepeat7moretimes.
Carefullyturnthecubeonit'ssideandbendthe8groundwires90degrees.

Step29:Buildthecube:attachcables

(http://cdn.instructables.com/FIF/65W8/GICYAZYL/FIF65W8GICYAZYL.LARGE.jpg)

(http://cdn.instructables.com/FNN/OY41/GI0TK2MK/FNNOY41GI0TK2MK.LARGE.jpg)

(http://cdn.instructables.com/FT4/9LPK/GICYAZZ1/FT49LPKGICYAZZ1.LARGE.jpg)

ShowAll10Items

(http://cdn.instructables.com/FG3/56N6/GI0TK2ML/FG356N6GI0TK2ML.LARGE.jpg)

64+8wireshavetogofromthecontrollertotheLEDcube.Weusedribbon
cabletomakethingsalittleeasier.
(http://cdn.instructables.com/FA3/XZVS/GI0TDNI6/FA3XZVSGI0TDNI6.LARGE.jpg)

Thegroundlayersusean8wireribboncable.

Thecathodesareconnectedwith416wireribboncables.Eachoftheseribbon
cablesaresplitintwoateitherend,togettwo8wirecables.
Atthecontrollerside,weattached0.1"femaleheaderconnectors.Theseplug
intostandard0.1"singlerowPCBheaderpins.
(http://cdn.instructables.com/FW5/S541/GI0TMGO2/FW5S541GI0TMGO2.LARGE.jpg)

Theheaderconnectorisamodularconnectorthatcomesintwoparts,metal
insertsandaplasticbody.
Themetalinsertsaresupposedtobecrimpedonwithatool.Wedidn'thavethe
appropriatetoolonhand,soweusedpliers.Wealsoaddedalittlesolderto
makesurethewiresdidn'tfallofwithuse.
1)Prepareone8wireribboncableand416wireribboncablesofthedesired
length
2)Crimporsolderonthemetalinserts.

3)Insertthemetalinsertintotheplasticconnectorhousing.
4)Solderthe8wireribboncabletothecathoderisers.Pretinthecablesbefore
soldering!
5)Solderintherestofthecables.Theredstripeonthefirstwireindicatesthat
thisisbit0.
6)Tightenthescrewsonthestrainrelieftomakesureeverythingstaysinplace.
7)ConnectalltheribboncablestothePCBsinthecorrectorder.Seepictures
below.Our8wireribboncabledidn'thavearedwire.Justfliptheconnector180
degreesifyourcubeisupsidedown.

Step30:Buildthecontroller:layout

(http://cdn.instructables.com/FB6/QBNQ/GI0TMGO5/FB6QBNQGI0TMGO5.LARGE.jpg)

(http://cdn.instructables.com/FYZ/8EHJ/GI0TK2MU/FYZ8EHJGI0TK2MU.LARGE.jpg)

WetookoutthebiggesttypeofPCBwehadavailable(9x15cm)andstarted
experimentingwithdifferentboardlayouts.Itsoonbecameclearthatcramming
(http://cdn.instructables.com/FJ4/7RE1/GICYB6CI/FJ47RE1GICYB6CI.LARGE.jpg)
allthecomponentsontooneboardwasn'tagoodsolution.Insteadwedecided
toseparatethelatcharrayandpowersupplypartofthecircuitandplaceitona
separateboard.Aribboncabletransfersdatalinesbetweenthetwoboards.
Choosingtwoseparateboardswasagooddecision.Thelatcharraytookup
almostallthespaceofthecircuitboard.Therewouldn'thavebeenmuchspace
forthemicrocontrollerandotherparts.
Youmaynothavetheexactsamecircuitboardsaswedo,ormaywantto
(http://cdn.instructables.com/FJA/4IZJ/GICYB5XH/FJA4IZJGICYB5XH.LARGE.jpg)
arrangeyourcomponentsinadifferentway.Trytoplaceallthecomponentson
yourcircuitboardtoseewhichlayoutbestfitsyourcircuitboard.

multiplexer_board.sch

avr_board.sch

(/files/orig/FAU/I50K/GICYB6CJ/FAUI50KGICYB6CJ.tmp)238KB

(/files/orig/FA9/26YI/GICYB6CH/FA926YIGICYB6CH.tmp)249KB

Step31:Buildthecontroller:clockfrequency

(http://cdn.instructables.com/F2K/WL27/GI0TK2MZ/F2KWL27GI0TK2MZ.LARGE.jpg)

(/files/deriv/F7Q/4LXV/GI0TMGO6/F7Q4LXVGI0TMGO6.LARGE.jpg)

(http://cdn.instructables.com/FJZ/61SE/GI0TMGOE/FJZ61SEGI0TMGOE.LARGE.jpg)
(http://cdn.instructables.com/F89/AREY/GI0TK2MY/F89AREYGI0TK2MY.LARGE.jpg)

Weuseanexternalcrystalof14.7456MHztodrivetheATmegasystemclock.
Youmaybethinkingthatthisisanoddnumbertouse,andwhywedidn'trun
theATmegaatthe16MHzitisratedfor.
WewanttobeabletocontroltheLEDcubefromacomputer,usingRS232.
Serialcommunicationrequiresprecisetiming.Ifthetimingisoff,onlybyalittle
bit,somebitsaregoingtobemissedorcounteddoublefromtimetotime.We
won'tberunninganyerrorcorrectingalgorithmsontheserialcommunications,
(http://cdn.instructables.com/FGI/NT42/GI0TK2N0/FGINT42GI0TK2N0.LARGE.jpg)
soanyerroroverthelinewouldberepresentedintheLEDcubeasavoxel
beingonoroffinthewrongplace.
Togetflawlessserialcommunication,youhavetouseaclockfrequencythat
canbedividedbytheserialfrequencyyouwanttouse.
14.7456MHzisdividablebyallthepopularRS232baudrates.
(14.7456MHz*1000*1000)/9600baud=1536.0
(14.7456MHz*1000*1000)/19200baud=768.0
(14.7456MHz*1000*1000)/38400baud=384.0
(14.7456MHz*1000*1000)/115200baud=128.0

TheformulainsidetheparenthesesconvertsfromMHztoHz.First*1000gives
youKHz,thenextHz.
AsyoucanseealloftheseRS232baudratescanbecleanlydividedbyour
clockrate.Serialcommunicationwillbeerrorfree!

Step32:Buildthecontroller:protoboardsolderingadvice

(http://cdn.instructables.com/FME/U2JU/GI0TK2NC/FMEU2JUGI0TK2NC.LARGE.jpg)

WeseepeopledoalotofweirdstuffwhentheysolderonprototypePCBs.

Beforeyoucontinue,wejustwanttosharewithyoutheprocessweuseto
createtracksonprototypePCBswithsoldereyes.Onceyoumasterthis
technique,youwillprobablystartusingitalot.
1)Filleachpointofthetrackyouwanttomakewithsolder.
2)Connecteveryotherpointsbyheatingthemandaddingalittlesolder.
3)Connectthe2holelongpiecesyounowhavespanningthedesiredtrack.
4)Lookhowbeautifultheresultis.
Youcanseeinthevideohowwedoit.Wehadtotouchsomeofthepointstwice
tojointhem.Itwasabithardtohavethecamerainthewaywhenwewere
soldering)

Step33:Buildthecontroller:Powerterminalandfiltering
capacitors

(http://cdn.instructables.com/FJG/78B4/GI0TMGP4/FJG78B4GI0TMGP4.LARGE.jpg)

Thecubeiscomplete,nowallthatremainsisamonstercircuittocontrolthe
thing.
(http://cdn.instructables.com/F6B/65GZ/GI0TDNNW/F6B65GZGI0TDNNW.LARGE.jpg)

Let'sstartwiththeeasiestpart,the"powersupply".
ThepowersupplyconsistsofascrewterminalwhereyouconnecttheGNDand
VCCwires,somefilteringcapacitors,aswitchandaanLEDtoindicatepower
on.
Initially,wehaddesignedanonboardpowersupplyusinganLM7805step
downvoltageregulator.However,thisturnedouttobeabigfail.
Weusedthiswitha12Vwallwart.Butasyoumayalreadyknow,mostwall
(http://cdn.instructables.com/FUC/ZDZ6/GI0TK2NG/FUCZDZ6GI0TK2NG.LARGE.jpg)
wartsoutputhighervoltagesthantheonesspecifiedonthelabel.Ours
outputtedsomethinglike14volts.TheLM7805isn'taverysophisticatedvoltage
regulator,itjustusesresistancetostepdownthevoltage.Toget5voltsoutput
from14voltsinputmeansthattheLM7805hastodrop9volts.Theexcess
energyisdispersedasheat.Evenwiththeheatsinkthatyouseeinthepicture,
itbecameveryveryhot.Waytohottotouch!Inadditiontothat,theperformance
wasn'tgreateither.Itwasn'tabletosupplythenecessarycurrenttorunthecube
atfullbrightness.
TheLM7805waslaterremoved,andawirewassolderedbetweentheinputand
outputpins.Insteadweusedanexternal5Vpowersource,ascoveredina

previousstep.
Whysomanycapacitors?
TheLEDcubeisgoingtobeswitchingabout500mAonandoffseveralhundred
timespersecond.Themomentthe500mAloadisswitchedon,thevoltageis
goingtodropacrosstheentirecircuit.Manythingscontributetothis.Resistance
inthewiresleadingtothepowersupply,slownessinthepowersupplyto
compensatefortheincreaseinload,andprobablysomeotherthingsthatwe
didn'tknowabout)
Byaddingcapacitors,youcreateabufferbetweenthecircuitandthepower
supply.Whenthe500mAloadisswitchedon,therequiredcurrentcanbedrawn
fromthecapacitorsduringthetimeittakesthepowersupplytocompensatefor
theincreaseinload.
Largecapacitorscansupplylargercurrentsforlongerperiodsoftime,whereas
smallercapacitorscansupplysmallbutquickburstsofenergy.
Weplaceda1000uFcapacitorjustafterthemainpowerswitch.Thisworksas
ourmainpowerbuffer.Afterthat,thereisa100uFcapacitor.Itiscommon
practicetohavealargecapacitorattheinputpinofanLM7805andasmaller
capacitoratit'soutputpin.The100uFcapacitorprobablyisn'tnecessary,butwe
thinkcapacitorsmakeyourcircuitlookcooler!
TheLEDisconnectedtoVCCjustafterthemainpowerswitch,viaaresistor.

Step34:Buildthecontroller:ICsockets,resistorsand
connectors

(http://cdn.instructables.com/FA7/8F69/GI0TK2NJ/FA78F69GI0TK2NJ.LARGE.jpg)

(http://cdn.instructables.com/FUM/BFZQ/GI0TDNOM/FUMBFZQGI0TDNOM.LARGE.jpg)

Inthisstepyouwillbesolderinginthemaincomponentsofthemultiplexer
array.

Ourmaindesignconsiderationherewastominimizesolderingandwiring.We
optedtoplacetheconnectorsasclosetotheICsaspossible.Ontheoutput
side,thereisonlytwosolderjointsperLEDcubecolumn.ICresistor,resistor
connector.Theoutputsofthelatchesarearrangedinorder07,sothisworks
outgreat.Ifweremembercorrectly,thelatchweareusingisavailableintwo
versions,onewiththeinputsandoutputsinsequentialorder,andonewiththe
inandoutputsinseeminglyrandomorder.Donotgetthatone!)Don'tworry,it
hasadifferent74HCxxxname,soyou'llbegoodifyousticktoourcomponent
list.
Inthefirstpicture,youcanseethatwehaveplacedalltheICsockets,resistors
andconnectors.Wesqueezeditastightaspossible,toleaveroomfor
unforeseenstuffinthefuture,likebuttonsorstatusLEDs.
Inthesecondpicture,youcanseethesolderjointsbetweentheresistorsand
theICsocketsandconnectors.NotethattheinputsideofthelatchICsockets
haven'tbeensolderedyetinthispicture.

Step35:Buildthecontroller:PowerrailsandICpower

(http://cdn.instructables.com/FVY/329L/GICYB1BJ/FVY329LGICYB1BJ.LARGE.jpg)

(http://cdn.instructables.com/FDG/RX36/GICYB1BM/FDGRX36GICYB1BM.LARGE.jpg)

Rememberthatprotoboardsolderingtrickweshowedyouinapreviousstep?
Wetoldyouitwouldcomeinhandy,andhereiswhereyouuseit.

Largecircuitboardslikethisone,withlotsofwires,canbecomequiteconfusing.
WealwaystrytoavoidliftingtheGNDandVCClinesofftheboard.Wesolder
themascontinuoussolderlines.Thismakesitveryeasytoidentifywhatis
GND/VCCandwhatissignallines.
IftheVCCandGNDlinesneedstocrosspaths,simplyrouteoneofthemover
theotherusingapieceofwireonthetopsideofthePCB.
Inthefirstpictureyoucanseesomesoldertracesinplace.
Thetwohorizontaltracesisthe"mainpowerbus".ThelowestoneisVCCand
thetoponeisGND.ForeveryrowofICsaGNDandVCClineisforkedoffthe
mainpowerbus.TheGNDlinerunsundertheICs,andtheVCClinerunsunder
theresistors.
Wewentalittleoverboardwhenmakingstraightwireforthecube,andhad
somepiecesleftover.WeusedthatfortheVCClinethatrunsunderthe
resistors.
Inthebottomrightcorner,youcanseethatwehavestartedsolderingthe8+1bit
busconnectingallthelatchICs.Lookhoweasyitistoseewhatissignalwires
andwhatispowerdistribution!
Inthesecondpicture,youcanseetheboardrightsideup,withsomeadditional
componentssolderedin,justignorethemforthemoment.
ForeverylatchIC(74HC574),thereisa100nF(0.1uF)ceramiccapacitor.
Thesearenoisereductioncapacitors.Whenthecurrentontheoutputpinsare
switchedonandoff,thiscancausethevoltagetodropenoughtomesswiththe
internalworkingsoftheICs,forasplitsecond.Thisisunlikely,butit'sbetterto
besafethansorry.Debuggingacircuitwithnoiseissuescanbeveryfrustrating.

Besides,capacitorsmakethecircuitlookthatmuchcoolerandprofessional!The
100nFcapacitorsmakesurethatthereissomecurrentavailablerightnexttothe
ICincasethereisasuddendropinvoltage.Wereadsomewherethatitis
commonengineeringpracticetoplacea100nFcapacitornexttoeveryIC,"Use
themlikecandy".Wetendtofollowthatprinciple.
Beloweachrowofresistors,youcanseeatinypieceofwire.ThisistheVCC
linemakingalittlejumptothetopsideoftheboardtocrossthemainGNDline.
Wealsoaddedacapacitoronthefarendofthemainpowerbus,forgood
measure.

Step36:Buildthecontroller:ConnecttheICs,8bitbus+OE

(http://cdn.instructables.com/FUO/UVFT/GI0TDNOZ/FUOUVFTGI0TDNOZ.LARGE.jpg)

Inthepicture,you'llnoticealotofwireshavecomeintoplace.
Allthetinybluewiresmakeupthe8+1bitbusthatconnectsallthelatchICs.8
bitsarefordata,andthe+1bitistheoutputenableline.
Atthetopoftheboard,wehaveaddeda16pinconnector.Thisconnectsthe
latchboardtothemicrocontrollerboard.Nexttothat,youseethe74HC138.

ThetinybluewiresareKynarwire.Thisisa30or32AWG(americanwire
gauge)wire.Verytiny.Weloveworkingwiththistypeofwire.Becauseitisso
thin,itdoesn'ttakeupthatmuchspaceonthecircuitboard.Ifwehadused
thickerwire,youwouldn'tbeabletoseetheboardthroughallthewires.Kynar
wireiscoatedwithtin,soyoucansolderdirectlyafterstrippingit.Noneedfor
pretinning.ThetinybluewiresareconnectedtothesamepinoneverylatchIC.
Fromtheconnectoratthetop,youcansee8greenwiresconnectedtothebus.
Thisisthe8bitdatabus.Weuseddifferentcolorsfordifferentfunctionsto
bettervisualizehowthecircuitisbuilt.
Theorangewireconnectedtothebusistheoutputenable(OE)line.
Ontherighthandsideoftheconnector,thefirstpinisconnectedtoground.

Step37:Buildthecontroller:Addressselector

(http://cdn.instructables.com/FFC/WI1T/GICYB1D8/FFCWI1TGICYB1D8.LARGE.jpg)

(http://cdn.instructables.com/F9F/H61T/GI0TK2NV/F9FH61TGI0TK2NV.LARGE.jpg)

The74HC138isresponsiblefortogglingtheclockpinonthe74HC574latch
ICs.Wecallthisanaddressselectorbecauseitselectswhichoneofthe8bytes

inthelatcharraywewanttowritedatato.Thethreebluewiresrunningfromthe
connectortothe74HC138isthe3bitbinaryinputusedtoselectwhichofthe8
outputsispulledlow.Fromeachoftheoutputsonthe74HC138,thereisawire
(white)runningtotheclockpinonthecorresponding74HC574latchIC.
StartbysolderingtheGNDandVCCconnections.Ifyouusethesoldertrace
methodtorunGND/VCClinesyouwanttodothisbeforeyousolderanyother
wiresinplace.A100nFceramicfilteringcapacitorisplacedclosetotheVCC
andGNDpinsofthe74HC138.
Thenconnecttheaddresslinesandthe8clocklines.
Ifyoulookcarefullyattheconnector,youcanseetwopinsthatarenotused.
ThesewillbeusedforabuttonanddebugLEDlater.

Step38:Buildthecontroller:AVRboard

(http://cdn.instructables.com/F47/L5JE/GICYB1EZ/F47L5JEGICYB1EZ.LARGE.jpg)

(http://cdn.instructables.com/F45/JMFQ/GICYB1F5/F45JMFQGICYB1F5.LARGE.jpg)

Braaaaainzz!!!
(http://cdn.instructables.com/FWE/P48I/GI0TMGRB/FWEP48IGI0TMGRB.LARGE.jpg)

ThisboardisthebrainoftheLEDcube.ThemaincomponentisanAtmelAVR
ATmega32.
Thisisan8bitmicrocontrollerwith32KBofprogrammemoryand2KBRAM.
TheATmega32has32GPIO(GeneralPurposeIO)pins.Twoofthesewillbe
usedforserialcommunication(TX+RX).ThreeIOpinsareusedforISP(In
circuitSerialProgramming).Thisleavesuswith27GPIOtodrivetheLEDcube,
buttonsandstatusLEDs.
Agroupof8GPIO(8bits,onebyte)iscalledaport.TheATmega32has4ports.
PORTA,PORTB,PORTCandPORTD.OnPORTCandPORTDsomeofthe
(http://cdn.instructables.com/FDS/0O6S/GI0TMGRC/FDS0O6SGI0TMGRC.LARGE.jpg)
pinsareusedforTX/RXandISP.OnPORTAandPORTB,allthepinsare
available.Weusetheseportstodrivethedatabusofthelatcharrayandlayer
selecttransistorarray.
PORTAisconnectedtothedatabusonthelatcharray.
EachpinonPORTCisconnectedtoapairoftransistorsthatdriveaground
layer.
Theaddressselectoronthelatcharray(74HC138)isconnectedtobit02on
PORTB.Outputenable(OE)isconnectedtoPORTBbit3.

Inthefirstimage,youseetheAVRboardrightsideup.
Thelarge40pinPDIP(PlasticDualInlinePackage)chipinthecenterofthe
boardistheATmega32,thebrainz!JusttotheleftoftheATmega,youseethe
crystaloscillatorandit'stwocapacitors.OneithersideoftheATmegathereisa
100nFfilteringcapacitor.OneforGND/VCCandoneforAVCC/GND.
Inthetopleftcorner,thereisatwopinconnectorsandtwofilteringcapacitors.
One10uFandone100nF.TheLEDisjustconnectedtoVCCviaaresistor,and
indicatespoweron.
Thelarge16pinconnectordirectlyabovetheATmegaconnectstothelatch
arrayboardviaaribboncable.Thepinoutonthiscorrespondstothepinouton
theotherboard.
Thesmaller10pinconnectortotheleft,isastandardAVRISPprogramming
header.IthasGND,VCC,RESET,SCK,MISOandMOSI,whichareusedfor
programming.Nexttoit,thereisajumper.Whenthisisinplace,theboardcan
bepoweredfromtheprogrammer.
Caution:DONOTpowertheboardfromtheprogrammerwhentheactualLED
cubeisconnectedtothecontroller.Thiscouldpossiblyblowtheprogrammer
andeventheUSBporttheprogrammerisconnectedto!
Thesecondimageshowstheunderside.AgainallGNDandVCClinesare
solderedastracesontheprotoboardorbarewire.Wehadsomemoreleftover
straightmetalwire,soweusedthis.
TheorangewiresconnecttheATmega'sRESET,SCK,MOSIandMISOpinsto
theISPprogrammingheader.

TheGreenwiresconnectPORTAtothedatabus.
Thebluewiresaretheaddressselectlinesforthe74HC138andoutputenable
(OE)forthelatcharray.
1)Startbyplacingthe40pinICsocket,the10pinISPconnectorwithajumper
nexttoitandthe16pindatabusconnector.
2)Solderinplacethepowerconnector,capacitorsandpowerindicatorLED.
3)ConnectalltheGNDandVCClinesusingsoldertracesorwire.Placea
100nFcapacitorbetweeneachpairofGND/VCCpinsontheATmega.
4)Solderinthecrystalandthetwo22pFcapacitors.Eachcapacitoris
connectedtoapinonthecrystalandGND.
5)Runallthedatabus,addressselectandOEwires,andtheISPwires.
Transistors,buttonsandRS232willbeaddedinlatersteps.
Atthistime,theAVRboardcanbeconnectedtoanISPprogrammerandthe
ATmegashouldberecognized.

Step39:Buildthecontroller:Transistorarray

(http://cdn.instructables.com/FM4/3HOU/GI0TK43T/FM43HOUGI0TK43T.LARGE.jpg)

(http://cdn.instructables.com/F9Z/FMQ9/GI0TK43P/F9ZFMQ9GI0TK43P.LARGE.jpg)

ThetransistorarrayisresponsibleforswitchingonandoffGNDforeachlayerin
theLEDcube.
Ourfirstattemptatthiswasanepicfail.Weboughtsometransistorsratedfor
over500mA,thinkingthatwouldbeplentyofjuice.Wedon'trememberthe
modelnumber.
TheLEDcubeworked,butitwasn'tverybright,andthebrightnesswas
inverselyproportionaltothenumberofLEDsswitchedoninanygivenlayer.In
(http://cdn.instructables.com/F5A/9M3H/GI0TDOUP/F5A9M3HGI0TDOUP.LARGE.jpg)
additiontothat,therewassomeghosting.Layersdidn'tswitchcompletelyoff
whentheyweresupposedtobeoff.
Needlesstosay,wewerekindofdisappointed,andstarteddebugging.Thefirst
thingwedidwastoaddpullupresistorstotrytocombattheghosting.This
removedalmostalltheghosting,yay!Butthecubewasstillverydim,bah!
Wedidn'thaveanypowerfultransistorsorMOSFETslyingaround,sowehadto
comeupwithanothersolution.
WepostedathreadintheelectronicssectionoftheAVRFreaks.netforum,
askingifitwaspossibletousetwosmallertransistorsinparallel.Thisistheonly
optionavailabletoususingthepartswehadonhand.Thegeneralresponse
was,thiswillneverworksodon'tevenbothertrying.Theyevenhadvalid
theoriesandstuff,butthatdidn'tdeterusfromtrying.Itwasouronlysolution
thatdidn'tinvolvewaitingfornewpartstoarriveinthemail.
WeendeduptryingPN2222A,NPNgeneralpurposeamplifier.Ideally,you'd
wantaswitchingtransistorforthiskindofapplication,butweneeded16
transistorsofthesametype.Thistransistorwasratedat1000mAcurrent,sowe
decidedtogiveitatry.

Foreachlayer,weusedtwoPN2222Asinparallel.Thecollectorsconnected
togethertoGND.Theemittersconnectedtogether,thenconnectedtoaground
layer.Thebaseofeachtransistorswasconnectedtoit'sownresistor,andthe
tworesistorsconnectedtoanoutputpinontheATmega.
Wesolderedinallthetransistorsandturnedthethingonagain,anditworked,
perfectly!
Ifyouknowwhatyouaredoing,youshouldprobablydosomeresearchandfind
amoresuitabletransistororMOSFET.Butoursolutionistriedandtestedand
alsodoesthetrick!
1)Startbyplacingall8alltransistorsonthePBCandsolderingeachoftheir
pins.
2)Runasoldertracebetweenthetheemittersofall16transistors.Connectthis
soldertracetoGND.
3)Solderinaresistorforeachtransistor,thesoldertheresistorstogetherin
pairsoftwo.
4)RunkynarwirefromtheoutputpinsontheATmegatoeachofthe8resistor
pairs.
5)Soldertogetherthecollectorsofthetransistorsinpairsoftwoandrunsolder
traceorwirefromthecollectorpairstoan8pinheader.

Step40:Buildthecontroller:ButtonsandstatusLEDs

(http://cdn.instructables.com/F02/189Q/GI0TMGRN/F02189QGI0TMGRN.LARGE.jpg)

YoucanmakeaLEDcubewithoutanybuttonsatall,butit'snicetohaveat
leastonebuttonandsomestatusLEDsfordebugging.
WeaddedoneawesomelookingbuttonwithtwobuiltinLEDs,andoneregular
buttonwithanLED.
ThefirstbuttonismountedonthelatcharrayPCB,sincethiswillsitontopof
theAVRboard,andwewantthebuttoneasilyaccessible.Thewiresarerouted
(http://cdn.instructables.com/F2I/9WBT/GI0TK2P3/F2I9WBTGI0TK2P3.LARGE.jpg)
throughtheribboncable.ThesecondbuttonandLEDsitsontheAVRboard
andwasmostlyusedfordebuggingduringconstruction.
ThebuttonsareconnectedbetweenGNDandtheIOpinontheATmega.An
internalpullupresistorinsidetheATmegaisusedtopullthepinhighwhenthe
buttonisnotpressed.Whenthebuttonispressed,theIOpinispulledlow.A
logic0indicatesthatabuttonhasbeenpressed.
TheLEDsarealsoconnectedbetweenGNDandtheIOpinviaaresistorof
appropriatesize.Don'tconnectanLEDtoamicrocontrollerIOpinwithout
havingaresistorconnectedinseries.Theresistoristheretolimitthecurrent,
(http://cdn.instructables.com/FBX/85NJ/GI0TMGRM/FBX85NJGI0TMGRM.LARGE.jpg)
andskippingitcanblowtheIOportonyourmicrocontroller.
Tofindtheappropriateresistor,justplugtheledintoabreadboardandtest
differentresistorswitha5vpowersupply.Choosetheresistorsthatmakethe
LEDlightupwiththebrightnessyouwant.IfyouuseLEDswithdifferentcolors,
youshouldtestthemsidebyside.DifferentcolorLEDsusuallyrequiredifferent
resistorstoreachthesamelevelofbrightness.
WewillleaveituptoyoutodecidetheplacementofyourstatusLEDs,butyou
canseeinthepicturesbelowhowwedidit:

Step41:Buildthecontroller:RS232

(http://cdn.instructables.com/FRS/SY2Q/GICYB1I2/FRSSY2QGICYB1I2.LARGE.jpg)

(http://cdn.instructables.com/FO2/ULPZ/GI0TMGRR/FO2ULPZGI0TMGRR.LARGE.jpg)

Togetthetrulyamazinganimations,weneedtoconnecttheLEDcubetoaPC.
ThePCcandofloatingpointcalculationsthatwouldhavetheAVRworkingin

slowmotion.
TheATmegahasabuiltinserialinterfacecalledUSART(Universal
SynchronousandAsynchronousserialReceiverandTransmitter).
TheUSARTcommunicatesusingTTLlevels(0/5volts).Thecomputertalks
serialusingRS232.ThesignallevelsforRS232areanywherefrom+/5voltsto
+/15volts.
ToconverttheserialsignalsfromthemicrocontrollertosomethingtheRS232
portonaPCcanunderstand,andviceversa,weusetheMaximMAX232IC.
Actually,thechipweareusingisn'tfromMaxim,butitisapincompatibleclone.
Therearesome100nFceramiccapacitorssurroundingtheMAX232.The
MAX232usesinternalchargepumpsandtheexternalcapacitorstostepupthe
voltagetoappropriateRS232levels.Oneofthe100nFcapacitorsisafilter
capacitor.
TheRS232connectorisata90degreeangleforeasyaccesswhenthelatch
arrayboardismountedontopoftheAVRboard.Weuseda4pinconnector
andcutoneofthepinsouttomakeapolarizedconnector.Thisremovesany
confusionastowhichwaytoplugintheRS232cable.
InthesecondpictureyoucanseetwoyellowwiresrunningfromtheATmegato
theMAX232.ThesearetheTTLlevelTXandRXlines.
1)ConnecttheGNDandVCCpinsusingsoldertraceorwire.Placea100nF
capacitorclosetotheGNDandVCCpins.
2)Solderinplacetherestofthe100nFcapacitors.Youcansolderthesewith
soldertraces,soitsbesttodothisbeforeyouconnectthetx/rxwires.

3)Solderinplacea4pin0.1"headerwithonepinremoved.Connectthepin
nexttotheonethatwasremovedtoGND.
4)Connectthetx/rxinputlinestothemicrocontroller,andthetx/rxoutputlines
tothe4pinheader.
Thewiresgoingtothe4pinheaderarecrossedbecausethefirstserialcable
weusedhadthispinout.

Step42:Buildthecontroller:MakeanRS232cable

(http://cdn.instructables.com/FFC/F3PV/GI0TK2Q0/FFCF3PVGI0TK2Q0.LARGE.jpg)

(http://cdn.instructables.com/FS1/EWQ8/GI0TMGRW/FS1EWQ8GI0TMGRW.LARGE.jpg)

(http://cdn.instructables.com/FF1/KJBJ/GI0TDNU0/FF1KJBJGI0TDNU0.LARGE.jpg)

ShowAll10Items

(http://cdn.instructables.com/F1M/DKJE/GICYB1J4/F1MDKJEGICYB1J4.LARGE.jpg)

ToconnecttheLEDcubetoaserialportonyourcomputer,youneedtomakea
serialcablewithafemaleDSub9pinconnector.
(http://cdn.instructables.com/F6P/8MWJ/GI0TDNU1/F6P8MWJGI0TDNU1.LARGE.jpg)

Ouremployerdeployed70Ethernetswitcheswithmanagementlastyear.With
eachswitchcomesanRS232cablethatisneverused.Weliterallyhadabig
pileofRS232cable,sowedecidedtomodifyoneofthose.
OntheLEDcube,a0.1"pinheaderisused,sotheRS232cableneedsanew
connectoronthecubeside.
(http://cdn.instructables.com/FJX/C1BV/GI0TK2PP/FJXC1BVGI0TK2PP.LARGE.jpg)

Wedidn'thavea4pinfemale0.1"connector,soweuseda4pinfemalePCB
headerinstead.
TheconnectorontheLEDcubePCBhasonepinremoved,tovisualizethe
directionalityoftheconnector.Thepinnumbersgoesfromrighttoleft.
PinoutoftheRS232connector:
1)GND(DSub9pin5)
2)Notconnected
3)RX(DSub9pin3)

4)TX(DSub9pin2)
FollowthesestepstomakeyourownRS232cable:
1)Cutoftheconnectoratoneendofthecable.Ifyourcablehasafemaleanda
maleconnector,makesuretoremovethemaleconnector!
2)Stripawaytheoutersheathontheendwhereyouremovedtheconnector.
3)Stripallthewiresinside.
4)Setyourmultimetertocontinuitytestmode.Thismakesthemultimeterbeep
whentheprobesareconnected.Ifyourmultimeterdoesn'thavethisoption,use
theresistancemode.Itshouldgetcloseto0ohmwhenyouconnecttheprobes.
5)ConnectonemultimeterprobetotheDSub9'spin5,thenprobeallthewires
untilyouthemultimeterbeeps.YouhavenowidentifiedthecolorofGNDinyour
cable.Repeatforpin2and3(TXandRX).
6)Writedownthecolorsyouidentified,thencutofftheotherwires.
7)Cutthethreewiresdowntosize,30mmshoulddo.
8)Pretinthewirestomakesolderingeasier.Justapplyheatandsoldertothe
strippedwires.
9)Slideashrinktubeoverthecable.Slidethreesmallershrinktubesoverthe
individualwires.
10)Solderthewirestotheconnector.
11)Shrinkthesmallertubesfirst,thenthelargeone.Ifyouusealighter,don't

holdtheshrinktubeabovetheflame,justholditclosetothesideoftheflame.
Don'tmakeyourcablebasedonthecolorsweused.Testthecabletofindthe
correctcolors.

Step43:Buildthecontroller:Connecttheboards

(http://cdn.instructables.com/F0P/JT0O/GICYB3E2/F0PJT0OGICYB3E2.LARGE.jpg)

(http://cdn.instructables.com/FUJ/6V1V/GICYB6R2/FUJ6V1VGICYB6R2.LARGE.jpg)

Thetwoboardsareconnectedbytwocables:
AribboncablefortheDATAandAddressBUS.

A2wirecableforGNDandVCC.
Afterconnectingthesetwocables,yourboardiscomplete.

Step44:Buildthecontroller:Connectthecube

(http://cdn.instructables.com/FER/UACC/GICYB1O0/FERUACCGICYB1O0.LARGE.jpg)

(http://cdn.instructables.com/FPC/6VY7/GICYB1O4/FPC6VY7GICYB1O4.LARGE.jpg)

Connecttheribboncablesaccordingtothepinoutsshowninpicture2and3.
Thegroundlayerribboncableconnectstothepinheadernearthetransistor
array.Ifthecubeisupsidedown,justplugitintheotherway.

(http://cdn.instructables.com/FZG/JCSY/GI0TDNV9/FZGJCSYGI0TDNV9.LARGE.jpg)

Step45:ProgramtheAVR:Setthefusebits

(http://cdn.instructables.com/FMJ/7V6H/GI0TMHB1/FMJ7V6HGI0TMHB1.LARGE.jpg)

(http://cdn.instructables.com/FAC/2E2E/GI0TMHE8/FAC2E2EGI0TMHE8.LARGE.jpg)

(http://cdn.instructables.com/F79/FMGC/GI0TMGS5/F79FMGCGI0TMGS5.LARGE.jpg)

(http://cdn.instructables.com/FI6/0DJN/GI0TDNVG/FI60DJNGI0TDNVG.LARGE.jpg)
(http://cdn.instructables.com/FUH/6PI2/GI0TK2QA/FUH6PI2GI0TK2QA.LARGE.jpg)

TheATmega32hastwofusebytes.Thesecontainsettingsthathavetobe
loadedbeforetheCPUcanstart,likeclocksourceandotherstuff.Youhaveto
programyourATmegatouseanexternalhighspeedcrystaloscillatorand
disableJTAG.
Wesetthelowerfusebyte(lfuse)to0b11101111,andthehighfusebyteto
0b11001001.(0bmeansthateverythingafterthebisinbinary).
WeusedavrdudeandUSBtinyISP(http://www.ladyada.net/make/usbtinyisp/)to
(http://cdn.instructables.com/FED/6901/GICYB1P3/FED6901GICYB1P3.LARGE.jpg)
programourATmega.
Inallthefollowingexamples,wewillbeusinganUbuntuLinuxcomputer.The
commandsshouldbeidenticalifyourunavrdudeonWindows.
avrdudecusbtinypm32Ulfuse:w:0b11101111:m
avrdudecusbtinypm32Uhfuse:w:0b11001001:m
Warning:Ifyougetthiswrong,youcouldeasilybrickyourATmega!Ifyoufor
exampledisabletheresetbutton,youwon'tbeabletoreprogramit.Ifyou
selectthewrongclocksource,itmightnotbootatall.

Step46:ProgramtheAVRwithtestcode

(http://cdn.instructables.com/FOS/NXR5/GI0TK2QC/FOSNXR5GI0TK2QC.LARGE.jpg)

(http://cdn.instructables.com/FDG/4UZQ/GI0TDNVP/FDG4UZQGI0TDNVP.LARGE.jpg)

TimetotestifyourbrandnewLEDcubeactuallyworks!
WehavepreparedasimpletestprogramtocheckifalltheLEDsworkandif

theyarewiredcorrectly.
Youcandownloadthefirmwaretest.hexinthisstep,ordownloadthesource
codeandcompileityourself.
Asinthepreviousstep,weuseavrdudeforprogramming:
avrdudecusbtinypm32B1Uflash:w:test.hex
cusbtinyspecifiesthatweareusingtheUSBtinyISPfromLadyadapm32
(http://cdn.instructables.com/F5T/13Q6/GI0TMGSL/F5T13Q6GI0TMGSL.LARGE.jpg)
specifiesthatthedeviceisanATmega32B1tellsavrdudetoworkatahigher
thandefaultspeed.Uflash:w:test.hexspecifiesthatweareworkingonflash
memory,inwritemode,withthefiletest.hex.

test.hex

(/files/orig/FQX/H9M5/GICYB93T/FQXH9M5GICYB93T.tmp)14KB

Step47:Testthecube

(http://cdn.instructables.com/FLU/2HHF/GICYB1R3/FLU2HHFGICYB1R3.LARGE.jpg)

Thetestcodeyouprogrammedinthepreviousstepwillletyouconfirmthat
everythingiswiredupcorrectly.
Itwillstartbydrawingaplanealongoneaxis,thenmovingitalongall8
positionsofthataxis.(byplanewemeanaflatsurface,notanairplane:p)The
testcodewilltraverseaplanethroughallthreeaxis.
Afterthat,itwilllighttheLEDsinalayeronebyone,startingatthebottomlayer.

Ifanyofthelayersorcolumnsseemtolightupinthewrongorder,youhave
probablysolderedthewrongwiretothewronglayerorcolumn.Wehadone
mistakeinourcube)
Ifyoufindanythingthatisoutoforder,justdesolderthewiresandsolderthem
backintherightorder.Youcouldofcoursemakeaworkaroundinsoftware,but
thatwouldeatCPUcycleseverytimetheinterruptroutineruns.
Youcancompareyourcubetothetestvideobelow:

Step48:ProgramtheAVRwithrealcode

(http://cdn.instructables.com/F3X/MRID/GICYB1RZ/F3XMRIDGICYB1RZ.LARGE.jpg)

(http://cdn.instructables.com/FII/HXWN/GI0TMGST/FIIHXWNGI0TMGST.LARGE.jpg)

Soeverythingcheckedoutinthetest.It'stimetoprogramtheATmegawiththe
realfirmware!
(http://cdn.instructables.com/FYS/SF2F/GI0TDNX8/FYSSF2FGI0TDNX8.LARGE.jpg)
(http://cdn.instructables.com/FG5/Q7SV/GI0TK2QP/FG5Q7SVGI0TK2QP.LARGE.jpg)
Forthemostpart,theprocessisthesameasinthepreviousprogrammingstep.
ButinadditionyouhavetoprogramtheEEPROMmemory.TheLEDcubehasa
basicbitmapfontstoredinEEPROM,alongwithsomeotherdata.
Firmwareisprogrammedusingthesameprocedureaswiththetestcode.
Firmware:
avrdudecusbtinypm32B1Uflash:w:main.hex

(http://cdn.instructables.com/FVB/35IW/GICYB1SC/FVB35IWGICYB1SC.LARGE.jpg)

EEPROM:
avrdudecusbtinypm32B1Ueeprom:w:main.eep
Ueeprom:w:main.eepspecifiesthatweareaccessingEEPROMmemory,in
writemode.AvrgccputsalltheEEPROMdatainmain.eep.
Ifyoudon'twanttoplayaroundwiththecode,yourLEDcubeisfinishedatthis
point.Butwerecommendthatyouspendsometimeonthesoftwaresideof
thingsaswell.That'satleastasmuchfunasthehardware!
Ifyoudownloadthebinaryfiles,youhavetochangethefilenamesinthe
commandstothenameofthefilesyoudownloaded.Ifyoucompilefromsource

thenameismain.hexandmain.eep.

ledcube_8x8x8_eeprom.eep

ledcube_8x8x8.hex

(/files/orig/F53/QFDQ/GICYB944/F53QFDQGICYB944.tmp)1KB

(/files/orig/FVZ/Y8K2/GICYB945/FVZY8K2GICYB945.tmp)46KB

Step49:Software:Introduction

(http://cdn.instructables.com/FI2/CBSY/GICYB7KV/FI2CBSYGICYB7KV.LARGE.jpg)

ThesoftwareiswritteninCandcompiledwiththeopensourcecompileravr
gcc.ThisisthemainreasonweuseAtmelAVRmicrocontrollers.ThePIC
seriesfromMicrochipisalsoanicechoice,butmostoftheCcompilerscost
money,andthefreeversionshavelimitationsoncodesize.
TheAVRrouteismuchmorehasslefree.Justaptgetinstalltheavrgcc
compiler,andyou'reinbusiness.

ThesoftwareontheAVRconsistsoftwomaincomponents,thecubeinterrupt
routineandeffectcodeformakingfancyanimations.
Whenwefinallyfinishedsoldering,wethoughtthiswouldbetheeasypart.Butit
turnsoutthatmakinganimationsinmonochromeatlowresolutionsisharder
thanitsounds.
Ifthedisplayhadahigherresolutionandmorecolors,wecouldhaveusedsin()
andcos()functionsandallthattomakefancyeyecandy.Withtwocolors(on
andoff)andlowresolution,wehavetousealotofif()andfor()tomake
anythingmeaningful.
Inthenextfewsteps,wewilltakeyouonatourofsomeoftheanimationswe
madeandhowtheywork.Ourgoalistogiveyouanunderstandingofhowyou
canmakeanimations,andinspireyoutocreateyourown!Ifyoudo,pleasepost
avideointhecomments!

ledcube_8x8x8v0.1.2.tar.gz

(/files/orig/FJG/AU0K/GICYB94U/FJGAU0KGICYB94U.tmp)20KB

Step50:Software:Howitworks

(http://cdn.instructables.com/F00/4K0H/GICYB3XX/F004K0HGICYB3XX.LARGE.jpg)

Asmentionedinthepreviousstep,thesoftwareconsistsoftwopars.The
interruptroutineandtheeffectcode.
Communicationbetweenthesetwohappensviaavoxelarray.Thisarrayhasa
bitforeveryLEDintheLEDcube.Wewillrefertothisasthecubearrayorcube
bufferfromnowon.
Thecubearrayismadeof8x8bytes.Sinceeachbyteis8bits,thisgivesusa
bufferthatis8voxelswide,8woxelshighand8voxelsdeep(1bytedeep).

volatileunsignedcharcube[8][8]
Theinterruptroutinereadsfromthecubearrayatgivenintervalsanddisplays
theinformationontheLEDcube.
TheeffectfunctionswritesthedesiredLEDstatusestothisarray.
Wedidnotuseanysynchronizationordoublebuffering,sincethereisonlyone
producer(eithertheeffectscurrentlyrunning,orinputfromRS232)andone
consumer(theinterruptcodethatupdatesthecube).Thismeansthatsome
voxelscouldbefromthenextorprevious"frame",butthisisnotaproblem,
sincetheframerateissohigh.
Whenworkingwithmicrocontrollers,codesizeiscritical.Tosavecodesizeand
programmingwork,andtomakethecodeeasiertoread,wehavetriedtowrite
reusablecodeasoftenaspossible.
TheLEDcubecodehasabaseoflowleveldrawingfunctionsthatareusedby
thehigherleveleffectfunctions.Thedrawfunctionscanbefoundindraw.c.
Drawfunctionsincludeeverythingfromsettingorclearingasinglevoxelto
drawinglinesandwireframeboxes.

Step51:Software:IOinitialization

(http://cdn.instructables.com/FC0/CBMR/GICYB7YO/FC0CBMRGICYB7YO.LARGE.jpg)

(http://cdn.instructables.com/F75/D9SJ/GICYB7YN/F75D9SJGICYB7YN.LARGE.jpg)

ThefirstthingtheATmegadoesafterboot,istocalltheioinit()function.
ThisfunctionsetsupIOports,timers,interruptsandserialcommunications.
AllIOportsontheATmegaarebidirectional.Theycanbeusedeitherasan
inputoranoutput.Weconfigureeverythingasoutputs,excepttheIOpinswhere
thetwobuttonsareconnected.TheRXpinfortheseriallineautomatically

becomesaninputwhenUSARTRXisenabled.
1)DDRxsetsthedatadirectionoftheIOpins.(DataDirectionRegister).1
meansoutput,0meansinput.
2)Afterdirectionalityhasbeenconfigured,wesetalloutputsto0toavidany
blinkingLEDsetcbeforetheinterrupthasstarted.
3)Forpinsconfiguredasinputs,thePORTxbitchangesitsfunction.Settinga1
inthePORTxregisterbitenablesaninternalpullupresistor.Theportispulled
uptoVCC.ThebuttonsareconnectedbetweentheportandGND.Whena
buttonispressedthecorrespondingPINxbitreadsalogic0.
4)Timer2isconfiguredandatimerinterruptenabled.Thisiscoveredina
separatestep.
5)Serialcommunicationsisconfiguredandenabled.Thisisalsocoveredina
separatestep.

Step52:Software:Modeselectionandrandomseed

(http://cdn.instructables.com/F1B/8RBN/GI0TK45B/F1B8RBNGI0TK45B.LARGE.jpg)

Whenwefirststartedwritingeffectsanddebuggingthem,wenoticedthatthe
functionsusingrandomnumbersdisplayedtheexactsameanimationsevery
time.Itwasrandomalright,butthesamerandomsequenceeverytime.Turns
outtherandomnumbergeneratorintheATmeganeedstobeseededwitha
randomnumbertocreatetruerandomnumbers.
Wewroteasmallfunctioncalledbootwait().Thisfunctionservestwopurposes.
1)Createarandomseed.2)Listenforbuttonpressestoselectmodeof
operation.

Itdoesthefollowing:
1)Setcounterxto0.
2)Startaninfiniteloop,while(1).
3)Incrementcounterxbyone.
4)Usexasarandomseed.
5)Delayforawhileandsetredstatusledon.
6)Checkforbuttonpresses.Ifthemainbuttonispressed,thefunctionreturns1.
IfthePGMbuttonispresseditreturnes2.Thereturnstatementsexitsthe
functionthusendingtheinfiniteloop.
7)Delayagainandsetgreenledon.
8)Checkforbuttonpressesagain.
9)Loopforeveruntilabuttonispressed.
Thelooploopsveryfast,sotheprobabilitythatyouwillstopitatthesamevalue
ofxtwotimesinarowisveryremote.Thisisaverysimplebuteffectivewayto
getagoodrandomseed.
Bootwait()iscalledfromthemain()functionanditsreturnvalueassignedtothe
variablei.
Ifi==1,themainloopstartsaloopthatdisplayseffectsgeneratedbythe
ATmega.Ifi==2,itentersintoRS232modeandwaitsfordatafroma
computer.

Step53:Software:Interruptroutine

(http://cdn.instructables.com/FJU/HIM1/GI0TK2QT/FJUHIM1GI0TK2QT.LARGE.jpg)

(http://cdn.instructables.com/FTH/KRXN/GI0TMGT7/FTHKRXNGI0TMGT7.LARGE.jpg)

(http://cdn.instructables.com/FCJ/8C6H/GI0TDNZS/FCJ8C6HGI0TDNZS.LARGE.jpg)

ShowAll7Items

(http://cdn.instructables.com/FH0/12UL/GI0TDNZR/FH012ULGI0TDNZR.LARGE.jpg)

TheheartoftheLEDcubecodeistheinterruptroutine.
(http://cdn.instructables.com/FNT/SQBI/GI0TMGT9/FNTSQBIGI0TMGT9.LARGE.jpg)
Everytimethisinterruptruns,thecubeiscleared,dataforthenewlayeris
loadedontothelatcharray,andthenewlayerisswitchedon.Thisremainson
untilthenexttimetheinterruptruns,wherethecubeisclearedagain,datafor
thenextlayerisloadedontothelatcharray,andthenextlayerisswitchedon.

TheATmega32has3timer/counters.Thesecanbesettocountcontinuously
andtriggeraninterruptroutineeverytimetheyreachacertainnumber.The
(http://cdn.instructables.com/F8Q/YQN0/GICYB7ZN/F8QYQN0GICYB7ZN.LARGE.jpg)
counterisresetwhentheinterruptroutineiscalled.
WeuseTimer2withaprescalerof128andanOutputComparevalueof10.
Thismeansthatthecounterisincrementedby1forevery128thcpucycle.
WhenTimer2reaches10,itisresetto0andtheinterruptroutineiscalled.With
acpufrequencyof14745600Hz,128prescalerandoutputcompareof10,the
interruptroutineiscalledevery1408thCPUcycle(128*11)or10472.7timesper
second.Itdisplaysonelayeratatime,soittakes8runsoftheinterrupttodraw
theentirecubeonce.Thisgivesusarefreshrateof1309FPS(10472.7/8).At
thisrefreshrate,theLEDcubeis100%flickerfree.Somemightsaythat1300
FPSisoverkill,buttheinterruptroutineisquiteefficient.Atthishighrefreshrate,
itonlyusesabout21%oftheCPUtime.Wecanmeasurethisbyattachingan

oscilloscopetotheoutputenableline(OE).Thisispulledhighatthestartof
eachinterruptandlowattheend,soitgivesaprettygoodindicationofthetime
spentinsidetheinterruptroutine.
Beforeanytimedinterruptscanstart,wehavetosetuptheTimer2.Thisis
doneintheioinit()function.
TCCR2(TimerCounterControlRegister2)isan8bitregisterthatcontains
settingsforthetimerclocksourceandmodeofoperation.Weselectaclock
sourcewitha1/128prescaler.ThismeansthatTimer/counter2isincrementet
by1every128thCPUcycle.
WesetittoCTCmode.(ClearonTimerCompare).Inthismode,thecounter
valueTCNT2iscontinuouslycomparedtoOCR2(OutputCompareRegister2).
EverytimeTCNT2reachesthevaluestoredinOCR2,itisresetto0andstarts
countingfromfrom0.Atthesametime,aninterruptistriggeredandtheinterrupt
routineiscalled.
Foreveryrunoftheinterrupt,thefollowingtakesplace:
1)Allthelayertransistorsareswitchedoff.
2)Outputenable(OE)ispulledhightodisableoutputfromthelatcharray.
3)Alooprunsthroughi=07.ForeverypassabyteisoutputedontheDATA
busandthei+1isoutputedontheaddressbus.Weaddthe+1becausethe
74HC138hasactivelowoutputsandthe74HC574clocklineistriggeredonthe
risingedge(transitionfromlowtohigh).
4)Outputenableispulledlowtoenableoutputfrothelatcharrayagain.
5)Thetransistorforthecurrentlayerisswitchedon.
6)current_layerisincrementedorresetto0ifitmovesbeyond7.

That'sit.Theinterruptroutineisquitesimple.I'msuretherearesome
optimizationswecouldhaveused,butnotwithoutcompromisinghuman
readabilityofthecode.Forthepurposeofthisinstructable,wethinkreadability
isareasonabletradeoffforaslightincreaseinperformance.

Step54:Software:Lowlevelfunctions

(http://cdn.instructables.com/F4N/M6VY/GICYB7QH/F4NM6VYGICYB7QH.LARGE.jpg)

Wehavemadeasmalllibraryoflowlevelgraphicfunctions.
Therearethreemainreasonsfordoingthis.

Memoryfootprint
Theeasiestwaytoaddresseachvoxelwouldbethroughathreedimensional
bufferarray.Likethis:
unsignedcharcube[x][y][z](charmeansan8bitnumber,unsignedmeansthat
it'srangeisfrom0to255.signedis128to+127)
Withinthisarrayeachvoxelwouldberepresentedbyaninteger,where0isoff
and1ison.Infact,youcouldusetheentireintegerandhave256different
brightnesslevels.Weactuallytriedthisfirst,butitturnedoutthatoureBayLEDs
hadverylittlechangeinbrightnessinrelationtodutycycle.Theeffectwasn't
noticeableenoughtobeworththetrouble.Wewentforamonochromesolution.
Onandoff.
Withamonochromecubeandathreedimensionalbuffer,wewouldbewasting
7/8ofthememoryused.Thesmallestamountofmemoryyoucanallocateis
onebyte(8bits),andyouonlyneed1bittorepresentonandoff.7bitsforeach
voxelwouldbewasted.512*(7/8)=448bytesofwastedmemory.Memoryis
scarceonmicrocontrollers,sothisisasuboptimalsolution.
Instead,wecreatedabufferthatlookslikethis:
unsignedcharcube[z][y]
InthisbuffertheXaxisisrepresentedwithineachofthebytesinthebuffer
array.Thiscanbequiteconfusingtoworkwith,whichbringsustothesecond
reasonformakingalibraryoflowleveldrawingfunctions:
Codereadability
Settingavoxelwiththecoordinatesx=4,y=3,z=5willrequirethefollowing
code:
cube[5][3]|=(0x01<<4)
Youcanseehowthiscouldleadtosomeseriousheadscratchingwhentryingto
debugyoureffectcode)

Indraw.cwehavemadeabunchoffunctionsthattakesx,y,zasargumentsand
doesthismagicforyou.
Settingthesamevoxelasintheexampleaboveisdonewithsetvoxel(4,3,5),
whichis_alot_easiertoread!
draw.ccontainsmanymorefunctionslikethis.Linedrawing,planedrawing,box
drawing,fillingetc.Havealookindraw.candfamiliarizeyourselfwiththe
differentfunctions.
Reusablecodeandcodesize
Asyoucanseeindraw.c,someofthefunctionsarequitelarge.Writingthat
codeoverandoveragaininsideeffectfunctionswouldtakeupalotofprogram
memory.Weonlyhave32KBtoworkwith.Itsalsoboringtowritethesame
codeoverandoveragain)

Step55:Software:Cubevirtualspace

(http://cdn.instructables.com/FAZ/UJHT/GI0TK2R0/FAZUJHTGI0TK2R0.LARGE.jpg)

(http://cdn.instructables.com/FW9/XO31/GI0TDNZV/FW9XO31GI0TDNZV.LARGE.jpg)

(http://cdn.instructables.com/F4J/KMDE/GI0TDNZW/F4JKMDEGI0TDNZW.LARGE.jpg)

Nowthatwehaveacubebufferandanicelittlecollectionoflowleveldraw
(http://cdn.instructables.com/FCT/XDX6/GI0TK2QY/FCTXDX6GI0TK2QY.LARGE.jpg)
functionstopopulateit,weneedtoagreeonwhichwaysiswhat,andwhatisup
andwhatisdown)
Fromnowon,thenativepositionoftheLEDcubewillbewiththecablescoming
(http://cdn.instructables.com/FJA/KB9R/GI0TK2QZ/FJAKB9RGI0TK2QZ.LARGE.jpg)
outtotheleft.
Inthisorientation,theYaxisgoesfromlefttoright.TheXaxisgoesfromfrontto
back.TheZaxisgoesfrombottomtotop.
Coordinatesinthisinstructableisalwaysrepresentedasx,y,z.
Position0,0,0isthebottomleftfrontcorner.Position7,7,7isthetoprightback
corner.
(http://cdn.instructables.com/FYK/X4F6/GI0TMGTQ/FYKX4F6GI0TMGTQ.LARGE.jpg)
WhydidweusetheYaxisforleft/rightandXforback/front?Shouldn'titbethe
otherwayaround?Yes,wethinksotoo.WedesignedthetheLEDcubetobe
viewedfromthe"front"withthecablescomingouttheback.However,thiswas
quiteimpracticalwhenhavingtheLEDcubeonthedesk,itwasmorepractical
tohavethecablescomingouttheside,andhavingcubeandcontrollersideby
side.Alltheeffectfunctionsaredesignedtobeviewedfromthisorientation.

Step56:Software:Effectlauncher

(http://cdn.instructables.com/F8G/TGAI/GICYB83H/F8GTGAIGICYB83H.LARGE.jpg)

(http://cdn.instructables.com/FTG/5NCK/GICYB836/FTG5NCKGICYB836.LARGE.jpg)

Wewantedaneasywaytoruntheeffectsinafixedorderorarandomorder.
Thesolutionwastocreateaneffectlauncherfunction.

launch_effect.ccontainsthefunctionlaunch_effect(inteffect).
Insidethefunctionthereisaswitch()statementwhichcallstheappropriate
effectfunctionsbasedonthenumberlaunch_effect()wascalledwith.
Inlaunch_effect.hEFFECTS_TOTALisdefined.Wesetitonenumberhigher
thanthehighestnumberinsidetheswitch()statement.
(http://cdn.instructables.com/FK0/6M68/GICYB835/FK06M68GICYB835.LARGE.jpg)
Launchingtheeffectsonebyoneisnowasimplematterofjustloopingthrough
thenumbersandcallinglaunch_effect(),likethis:

while(1)
for(i=0i<EFFECTS_TOTALi++)
{
launch_effect(i)
}
}
Thiscodewillloopthroughalltheeffectsinincrementalorderforever.
Ifyouwantthecubetodisplayeffectsinarandomorder,justusethefollowing
code:
while(1)
{
launch_effect(rand()%EFFECTS_TOTAL)
}
The%EFFECTS_TOTALafterrand()keepstherandomvaluebetween0and
EFFECTS_TOTAL1.

Step57:Software:Effect1,rain

(http://cdn.instructables.com/FOY/1PD8/GICYB274/FOY1PD8GICYB274.LARGE.jpg)

Letsstartwithoneofthesimplesteffects.
Ineffect.cyouwillfindthefunctioneffect_rain(intiterations).
(http://cdn.instructables.com/FA0/NK40/GI0TDO2S/FA0NK40GI0TDO2S.LARGE.jpg)

Thiseffectaddsraindropstothetoplayerofthecube,thenletsthemfalldown
tothebottomlayer.
Mostoftheeffectshaveamainfor()loopthatloopsfromi=0toi<iterations.
effect_rain(intiterations)onlytakesoneargument,whichisthenumberof
iterations.
Insidetheiterationloop,thefunctiondoesthefollowing:

(http://cdn.instructables.com/FV1/C9SZ/GICYB866/FV1C9SZGICYB866.LARGE.jpg)

1)Createarandomnumberbetween0and3,letscallitnhere.
2)Loopafor()loopnnumberoftimes.
3)Foreachiterationofthisloop,placeapixelonlayer7(z=7)atrandomxand
ycoordinates.
4)Delayforawhile
5)ShiftthecontentsoftheentirecubealongtheZaxisby1positions.This
shiftseverythingdownonelevel.
Thisisaprettysimpleeffect,butitworks!

Step58:Software:Effect2,planeboing

(http://cdn.instructables.com/F6L/3GT0/GI0TMGUD/F6L3GT0GI0TMGUD.LARGE.jpg)

(http://cdn.instructables.com/FV7/BHEJ/GI0TDO33/FV7BHEJGI0TDO33.LARGE.jpg)

(http://cdn.instructables.com/FDI/B22J/GICYB87B/FDIB22JGICYB87B.LARGE.jpg)
(http://cdn.instructables.com/FF2/GNQR/GI0TK2R7/FF2GNQRGI0TK2R7.LARGE.jpg)

Anothersimpleeffect,effect_planboing(intplane,intspeed).
Thiseffectdrawsaplanealongthespecifiedaxisthenmovesitfromposition0
to7ontheaxisandbackagain.Thisisverysimple,butitreallybringsoutthe
depthofthe3dLEDcube:)
Thisfunctiondoesn'thaveaniterationloop.Insteaditiscalledtwiceforeach
axisinlaunch_effect().
(http://cdn.instructables.com/F1U/HTEK/GICYB87A/F1UHTEKGICYB87A.LARGE.jpg)
Hereiswhatitdoes:

1)For()loopifrom0to7.
2)Clearthecubewithfill(0x00)
3)Callsetplane()todrawaplanealongthedesiredaxisatpositioni.Theplane
isn'tactuallydrawnontheaxisspecified,itisdrawnontheothertwoaxis.Ifyou
specifyAXIS_Z,aplaneisdrawnonaxisXandY.It'sjusteasiertothinkofit
thatway.InsteadofhavingconstantsnamedPLANE_XY,PLANE_YZetc.
4)Delayforawhile.
5)Repeatthesameloopwithigoingfrom7to0.
Verysimple,butaverycooleffect!

Step59:Software:Effect3,sendvoxelsrandomZ

(http://cdn.instructables.com/F0H/Z98R/GICYB2DC/F0HZ98RGICYB2DC.LARGE.jpg)

(http://cdn.instructables.com/FNP/KQC3/GICYB2DI/FNPKQC3GICYB2DI.LARGE.jpg)

(http://cdn.instructables.com/F12/GW2Z/GICYB89G/F12GW2ZGICYB89G.LARGE.jpg)
(http://cdn.instructables.com/FGC/6CZ9/GICYB89F/FGC6CZ9GICYB89F.LARGE.jpg)
ThiseffectsendsvoxelsupanddowntheZaxis,astheimplies.

voidsendvoxels_rand_z()takesthreearguments.Iterationsisthenumberof
timesavoxelissentupordown.Delayisthespeedofthemovement(higher
delaymeanslowerspeed).Waitisthedelaybetweeneachvoxelthatissent.
Thisishowitworks:
1)Thecubeisclearedwithfill(0x00)
2)Loopthroughall64positionsalongX/Yandrandomlysetavoxelateither
Z=0orZ=7.
(http://cdn.instructables.com/FTU/BRCG/GICYB89E/FTUBRCGGICYB89E.LARGE.jpg)

3)Enterthemainiterationloop
4)SelectrandomcoordinatesforXandYbetween0and7.IftheXandY
coordinatesareidenticaltothepreviouscoordinates,thisiterationisskipped.
5)CheckifthevoxelatthisX/YcoordinateisatZ=0orZ=7,andsendittothe
oppositesideusingsendvoxel_z().
6)Delayforawhileandsavethecoordinatesofthisiterationsowecancheck
themagainsttherandomcoordinatesinthenextiteration.Itlookedweirdto
movethesamevoxeltwiceinarow.
Theactualmovementofthevoxelsisdonebyanotherfunction,sendvoxel_z.
Thereasonforthis,isthatacoupleofothereffectsdoesthesamethingonlyin

differentways.
Thefunctionsendvoxel_z()takesfourargument.XandYcoordinates.Z
coordinate,thisisthedestinationandcaneitherbe0or7.Delaywhichcontrols
thespeed.
Thisishowitworks:
1)For()loopifrom0to7.
2)Ifthedestinationis7,wesetiito71,thusmakingiithereverseofi.Clearthe
voxelatZ=ii+1.Whenmovingdown,ii+1isthepreviousvoxel.
3)Ifthedestinationis0,letiibeequaltoi.Clearii1.Whenmovingupwards,1
isthepreviousvoxel.
4)Setthevoxelatz=ii.
5)Waitforawhile.

Step60:Software:Effect4,boxshrinkgrowandwoopwoop

(http://cdn.instructables.com/FRK/NTEE/GI0TK2RH/FRKNTEEGI0TK2RH.LARGE.jpg)

(http://cdn.instructables.com/FWD/XKKP/GI0TMGUU/FWDXKKPGI0TMGUU.LARGE.jpg)

(http://cdn.instructables.com/FZ1/XMO5/GI0TMGUZ/FZ1XMO5GI0TMGUZ.LARGE.jpg)

ShowAll8Items

(http://cdn.instructables.com/F2F/NVPS/GI0TK2RG/F2FNVPSGI0TK2RG.LARGE.jpg)

Awireframeboxisagoodgeometricshapetoshowinamonochrome8x8x8
LEDcube.Itgivesaverynice3deffect.
(http://cdn.instructables.com/FOO/1NOL/GICYB8CT/FOO1NOLGICYB8CT.LARGE.jpg)
WemadetwoboxanimationfunctionsfortheLEDcube.
Effect_box_shrink_grow()drawsawireframeboxfillingtheentirecube,then
shrinksitdowntoonevoxelinoneof8corners.Wecallthisfunctiononetime
foreachofthe8cornerstocreateaniceeffect.Effect_box_woopwoop()draws
aboxthatstartsasa8x8x8wireframeboxfillingtheentirecube.Itthenshrinks
downtoa2x2x2boxatthecenterofthecube.Orinreverseifgrowisspecified.
(http://cdn.instructables.com/FT8/NB8N/GICYB8CU/FT8NB8NGICYB8CU.LARGE.jpg)

Hereishoweffect_box_shrink_grow()works.

Ittakesfourarguments,numberofiterations,rotation,flipanddelay.Rotation
specifiesrotationaroundtheZaxisat90degreeintervals.Flip>0flipsthecube
upsidedown.
Tomakethefunctionassimpleaspossible,itjustdrawsaboxfrom0,0,0toany
pointalongthediagonalbetween0,0,0and7,7,7thenusesaxismirrorfunctions
fromdraw.ctorotateit.
1)Entermainiterationloop.
2)Enterafor()loopgoingfrom0to15.

3)Setxyzto7i.Thismakesxyzthereverseofi.Wewanttoshrinktheboxfirst,
thengrow.xyzisthepointalongthediagonal.Wejustusedonevariablesince
x,yandzareallequalalongthisdiagonal.
4)Wheni=7,theboxhasshrunktoa1x1x1box,andwecan'tshrinkitany
more.Ifiisgreaterthan7,xyzissettoi8,whichmakesxyztravelfrom0to7
whenitravelsfrom8to15.Wedidthistricktoavoidhavingtwoforloops,whith
onegoingfrom70andonefrom07.
5)Blankthecubeanddelayalittlebittomakesuretheblankingisrenderedon
thecube.Disabletheinterruptroutine.Wedothisbecausethemirrorfunctions
takesalittletime.Withoutdisablinginterrupts,thewireframeboxwouldflash
brieflyintheoriginalrotationbeforebeingdisplayedrotated.
6)Drawthewireframeboxinitsoriginalrotation.sideoftheboxisalwaysat
0,0,0whiletheothertravelsalongthediagonal.
7)Dotherotations.Ifflipisgreatherthan0,thecubeisturnedupsidedown.rot
takesanumberfrom0to3where0is0degreesofrotationaroundZand3is
270degrees.Toget270degreeswesimplymirroraroundXandY.
8)Enableinterruptstodisplaythenowrotatedcube.
9)Delayforawhilethenclearthecube.
Theotherfunctioninvolvedinthewireframeboxeffectis
effect_box_woopwoop().Thenamewoopwoopjustsoundednaturalwhenwe
firstsawtheeffectrenderedonthecube)
Thewoopwoopfunctiononlydoesoneiterationandtakestwoarguments,delay
andgrow.Ifgrowisgreaterthan0,theboxstartsasa2x2x2boxandgrowtoa
8x8x8box.
Hereishowitworks:
1)Clearthecubebyfillingthebufferwith0x00
2)For()loopfrom0to3.

4)Setiitoi.Ifgrowisspecifiedwesetitto3itoreverseit.
5)Drawawireframeboxcenteredalongthediagonalbetween0,0,0and7,7,7.
Onecorneroftheboxusesthecoordinates4+iionallaxes,movingfrom47.
Theothercorneruses3iionallaxes,movingfrom30.
6)Delayforawhile,thenclearthecube.
Thesetwofunctionsareusedasonesingleeffectintheeffectlauncher.First
theshrinkgroweffectiscalled8times,oneforeachcorner,thenwoopwoopis
calledfourtimes,twoshrinkandgrowcycles.
Tolaunchtheshrinkgrowfunction,weusedaforloopwithsomeneatbit
manipulationtricksinsidetoavoidwriting8linesofcode.
Thesecondargumentoftheshrinkgrowfunctionsistherotation,in4steps.We
arecountingfrom0to7,sowecan'tsimplyfeediintothefunction.Weusethe
modulooperator%tokeepthenumberinsidearangeof04.Themodulo
operatordividesbythenumberspecifiesandreturnstheremainder.
Thethirdargumentistheflip.Whenflip=0,thecubeisnotflipped.>0flips.We
usethebitwiseANDoperatortoonlyreadbit3ofi.
Bitwiseoperatorsareanabsolutemusttoknowaboutwhenworkingwithmicro
controllers,butthatisoutsidethescopeofthisinstructable.Theguysoverat
AVRFreakshavepostedsomegreatinformationaboutthistopic.Youcanread
moreathttp://www.avrfreaks.net/index.php?
name=PNphpBB2&file=viewtopic&t=37871

Step61:Software:Effect5,axisupdownrandsuspend

(http://cdn.instructables.com/FR1/A1UQ/GI0TK2RR/FR1A1UQGI0TK2RR.LARGE.jpg)

(http://cdn.instructables.com/FRE/W2TX/GI0TMGV5/FREW2TXGI0TMGV5.LARGE.jpg)

(http://cdn.instructables.com/FDN/Z2O3/GICYB8IL/FDNZ2O3GICYB8IL.LARGE.jpg)

Thisisoneofourfavoriteeffects.Thevoxelsrandomlysuspendedinthecube
givesanice3ddepth,especiallyifyoumoveyourheadwhileviewingtheeffect.
(http://cdn.instructables.com/FNO/HKA1/GI0TDO6E/FNOHKA1GI0TDO6E.LARGE.jpg)

64voxelsstartoutononeofthesidewalls.Thentheyallgetassignedarandom
midwaydestinationbetweenthesidewalltheystartedatandthewallonthe
(http://cdn.instructables.com/FFM/UVDM/GICYB8IK/FFMUVDMGICYB8IK.LARGE.jpg)
oppositeside.
Thefunctionthenloops8timesmovingeachvoxelclosertoitsmidway
destination.After8iterations,thevoxelsaresuspendedatdifferentdistances
fromwheretheystarted.Thefunctionthenpausesforawhile,thusthename
axis_updown_randsuspend).Itthenloops8timesagainmovingthevoxelsone
stepclosertotheirfinaldestinationontheoppositewalleachtime.
(http://cdn.instructables.com/FET/7XGY/GICYB8IJ/FET7XGYGICYB8IJ.LARGE.jpg)

Theactualvoxeldrawingisdoneinaseparatefunction,draw_positions_axis()
soitcanbeusedindifferenteffects.Forexample,thevoxelscouldbe
suspendedmidwayinanonrandompattern.Wewillleaveituptoyoutocreate
thateffectfunction!:D
Youmayhavenoticedthatthedescriptionforthiseffectwaslessspecific.We
encourageyoutodownloadthesourcecodeandreadthroughthefunctions
yourself.Keepthetextaboveinmindwhenreadingthecode,andtrytofigure
outwhateverythingdoes.

Step62:Software:Effect6,stringfly

(http://cdn.instructables.com/FCL/Z6E7/GI0TK2TN/FCLZ6E7GI0TK2TN.LARGE.jpg)

(http://cdn.instructables.com/FPM/P8MQ/GICYB2SX/FPMP8MQGICYB2SX.LARGE.jpg)

(http://cdn.instructables.com/FGS/L22M/GICYB8K3/FGSL22MGICYB8K3.LARGE.jpg)
(http://cdn.instructables.com/F5L/KGMF/GI0TDUCU/F5LKGMFGI0TDUCU.LARGE.jpg)
8x8isaboutthesmallestsizerequiredtorenderameaningfultextfont,sowe
justhadtodojustthat!

Weloadeda8x5bitmapfontthatwehadpreviouslyusedwithagraphicalLCD
displayintoEEPROMmemory,andcreatedsomefunctionsthattookanASCII
charasanargumentandreturnedabitmapofthecharacter.
Thefunctionstringfly2takesanyASCIIstringanddisplaysitascharactersflying
throughthecube.
(http://cdn.instructables.com/FF1/JCMF/GICYB8L6/FF1JCMFGICYB8L6.LARGE.jpg)

Itstartsbyplacingthecharacteratthebackofthecube,thenusestheshift()
functiontoshiftthecubecontentstowardsyou,makingthetextfly.

Step63:Software:RS232input

(http://cdn.instructables.com/FXO/UWNG/GI0TMLBZ/FXOUWNGGI0TMLBZ.LARGE.jpg)

(http://cdn.instructables.com/FGM/6DHP/GI0TK89D/FGM6DHPGI0TK89D.LARGE.jpg)

Togeneratethemostawesomeeffects,weuseadesktopcomputer.Computers
candofloatingpointcalculationsandstufflikethatmuchquickerthanamicro
controller.Andyoudon'thavetoreprogramthemicrocontrollerforeveryeffect
youmake,oreverytimeyouwanttotestordebugsomething.

TheUSARTinterfaceintheATmegaisconfiguredtoworkat38400baudwith
onestopbitandnoparity.Eachbytethatissentdownthelinehasastartbit
andastopbit,so10bitsissenttotransmit8bits.Thisgivesusabandwidthof
3840bytespersecond.Thecubebufferis64bytes.Syncingbytesmakeup2
bytespercubeframe.At38400baudweareabletosendabout58framesper
second.Morethanenoughforsmoothanimations.
0xffisusedasanescapecharacter,andputsthers232functionintoescape
mode.Ifthenextbyteis0x00,thecoordinatesforthebufferarerestoredto0,0.
(http://cdn.instructables.com/FAO/TSER/GI0TDP9U/FAOTSERGI0TDP9U.LARGE.jpg)
Ifthenextbyteis0xff,itisaddedtothebuffer.Tosend0xff,yousimplysendit
twice.
Thers232functionjustloopsforever.Aresetisneededtoenterthecube's
autonomousmodeagain.

Step64:PCSoftware:Introduction

(http://cdn.instructables.com/FHF/3FSF/GICYB7UZ/FHF3FSFGICYB7UZ.LARGE.jpg)

ThecubejustreceivesbinarydataviaRS232.Thisdatacouldeasilybe
generatedbyanumberofdifferentprogramminglanguages,likepython,perlor
evenphp.
WechosetouseCforthePCsoftware,sincethemicrocontrollersoftwareis
writteninC.Thiswayeffectsfromthemicrocontrollercodecanjustbecopy
pastedintothePCsoftware.
Justlikeinthemicrocontrollercode,thiscodealsodoestwothings.Wherethe
microcontrollerhasaninterruptroutinethatdrawsthecontentsofcube[][]onto
theLEDcube,thePCsoftwarehasathreadthatcontinuallysendsdatatothe
LEDcube.

cube_pcv0.1.tar.gz

(/files/orig/FDJ/3BMV/GICYBAHY/FDJ3BMVGICYBAHY.tmp)82KB

Step65:PCSoftware:Cubeupdaterthread

(http://cdn.instructables.com/F7I/VR49/GICYB7X3/F7IVR49GICYB7X3.LARGE.jpg)

Incube.cwehaveafunctioncalledcube_push().Thistakesthe64bytearray
andsendsitdowntheseriallinetotheLEDcube.
Italsohandlestheformatting,sendingevery0xffbytetwicebecause0xffisour
escapecharacter.0xffand0x00issentfirsttoresettheLEDcubesinternalx
andycounters.

Inmain.cwehavethefunctioncube_updater().Thisfunctionislaunchedasa
separatethreadusingpthread_create().Themainthreadandthecubeupdater
threadsharesthememoryarears232_cube[8][8].Thecubeupdaterthreadis
justawhiletrueloopthatcallscube_push()overandover.
Thefirstattemptatanupdaterthreadturnedouttocreatesomeflickeringinthe
animations.Aftersomedebugging,wefoundoutthatframeswerebeing
transmittedbeforetheywerefullydrawnbytheeffectfunctions.Wegenerallydo
afill(0x00),thensomecodetodrawnewpixels.Ifaframeistransmittedright
afterafill(0x00),thecubewillflashanemptyframefor1/60thishofasecond.
Thiswasn'taprobleminthecoderunningontheLEDcube,sinceithasa
refreshrateofover1000FPS,butat60FPSyoucannoticeit.
Toovercomethiswecreateadoublebufferandsyncthetwobuffersatapoint
intimewheretheeffectfunctionhasfinisheddrawingtheframe.Luckilyallthe
effectfunctionsusethedelay_ms()functiontopausebetweenfinishedframes.
Wejustputamemcpy()insidetheretocopythecubebuffertothers232buffer.
Thisworksbeautifully.Nomoreflickering!

Step66:PCSoftware:Effect1,ripples

(http://cdn.instructables.com/FSC/KYL8/GI0TDO8C/FSCKYL8GI0TDO8C.LARGE.jpg)

ThisisthefirsteffectwemadeforthePCsoftware,andwethinkitturnedout
verynice.
Whilethismayseemlikeacomplicatedeffect,it'sreallynot!
Alltheeffectfunctionsrunningonthemicrocontrollermostlyuseif()statements
tocreateeffects.TheeffectsonthePCsoftwarearebuiltalittledifferent.We
usealotofsin(),cos()andothermathfunctionshere.Mostcoordinatesare
calculatedasfloatingpointcoordinatesthentypecastintointegersbeforebeing
drawnonthecube.

Theeffectyouseeinthevideoisactuallyjustasinewaveeminatingfromthe
centerofthecube,x=3.5,y=3.5.
Hereishowitworks:
1)Loopthroughtheiterationcounter.
2)Loopthroughall64xandycoordinates.
3)Calculatethedistancebetweenthecenterofthecubeandthex/ycoordinate.
4)Thezcoordinateiscalculatedwithsin()basedonthedistancefromthe
center+theiterationcounter.Theresultisthatthesinewavemovesoutfrom
thecenterastheiterationcounterincreases.
Lookhoweasythatwas!

Step67:PCSoftware:Effect2,sidewaves

(http://cdn.instructables.com/F4W/3XW4/GI0TMGZ6/F4W3XW4GI0TMGZ6.LARGE.jpg)

Thisisbasicallytheexactsamefunctionastheripplefunction.

Theonlydifferenceisthecoordinatesofthepointusedtocalculatethedistance
toeachx/ycoordinate.Wecallthispointtheorigin,sincethewaveemanates
fromthispoint.
Theorigincoordinateiscalculatedlikethis:
x=sin(iterationcounter)y=cos(iterationcounter)
Theresultisthatthesexandycoordinatesmovesaroundinacircle,resultingin
asinwavethatcomesinfromtheside.
Wejustwantedtoshowyouhoweasyitistocompletelyalteraneffectby
tweakingsomevariableswhenworkingwithmathbasedeffects!

Step68:PCSoftware:Effect3,fireworks

(http://cdn.instructables.com/FO5/CMRY/GI0TK2XC/FO5CMRYGI0TK2XC.LARGE.jpg)

(http://cdn.instructables.com/FZS/IWAP/GI0TDO8K/FZSIWAPGI0TDO8K.LARGE.jpg)

Thiseffectwasquitefuntomake.

Tomakethiseffect,wereallyhadtositdownandthinkabouthowfireworks
work,andwhichforcesinfluencethefireworkparticles.
Wecameupwithatheoreticalmodelofhowfireworkswork:
1)Arocketisshotuptoarandomposition,origin_x,origin_y,origin_z.
2)Therocketexplodesandthrowsburningparticlesoutinrandomdirectionsat
randomvelocities.
3)Theparticlesaresloweddownbyairresistanceandpulledtowardsthe
groundbygravity.
Withthismodelinmindwecreatedafireworkseffectwithaprettyconvincing
result.Hereishowitworks:
1)Arandomoriginpositionischosen.(withincertainlimits,xandybetween2
and5tokeepthefireworksmoreorlessinthecenterofthecube.zbetween5
and6.Fireworksexplodingnearthegroundcanbedangerous!:p)
2)Therocket,inthiscaseasinglevoxelismoveduptheZaxisatthexandy
coordinatesuntilitreachesorigin_z.
3)Anarrayofnparticlesiscreated.Eachparticlehasanx,yandzcoordinate
aswellasavelocityforeachaxis,dx,dyanddz.
4)Wefor()loopthrough25particleanimationsteps:
5)Aslowrateiscalculated,thisistheairresistance.Theslowrateiscalculated
usingtan()whichwillreturnanexponentiallyincreasingnumber,slowingthe
particlesfasterandfaster.
6)Agravityvariableiscalculated.Alsousingtan().Theeffectofgravityisalso
exponential.Thisprobablyisn'tthemathematicallycorrectwayofcalculating
gravity'seffectonanobject,butitlooksgood.

7)Foreachparticle,thexyandzcoordinatesareincrementedbytheirdx,dy
anddzvelocitiesdividedbytheslowrate.Thiswillmaketheparticlesmove
slowerandslower.
8)Thezcoordinateisdecreasedbythegravityvariable.
9)Theparticleisdrawnonthecube.
10)Delayforawhile,thendothenextiterationoftheexplosionanimation.
Wearequitepleasedwiththeresult.

Step69:PCSoftware:Effect4,Conway'sGameofLife3D

(http://cdn.instructables.com/FDE/IFJV/GICYBA5H/FDEIFJVGICYBA5H.LARGE.jpg)

TheGameofLife,alsoknownsimplyasLife,isacellularautomatondevisedby
theBritishmathematicianJohnHortonConway.Youcanreadmoreaboutthis
onWikipedia(http://en.wikipedia.org/wiki/Conway's_Game_of_Life),ifyou
haven'theardaboutitbefore.
Bypopulardemand,wehaveimplementedGameofLifein3DontheLEDcube.

Tomakeitworkin3dtheruleshavetobetweakedalittle:
Adeadcellbecomesaliveifithasexactly4neighbors
Alivecellwith4neighborslive
Alivecellwith3orfewerneighborsdie
Alivecellwith5ormoreneighborsdie
Theprogramstartsbyplacing10randomvoxelsinonecornerofthecube,then
thegameofliferulesareappliedandtheiterationsstarted.
Inthesecondvideo,weruntheanimationfasterandseedwith20voxels.

Step70:RunthecubeonanArduino

(http://cdn.instructables.com/F3X/EXOV/GICYB2YC/F3XEXOVGICYB2YC.LARGE.jpg)

(http://cdn.instructables.com/F9U/YXTC/GI0TDO8V/F9UYXTCGI0TDO8V.LARGE.jpg)

SincewepublishedourlastLEDCubeinstructable,wehavegottenalotof
(http://cdn.instructables.com/FQX/QGWP/GI0TK2XE/FQXQGWPGI0TK2XE.LARGE.jpg)
questionsfrompeoplewonderingiftheycoulduseanArduinotocontrolthe
cube.
Thistime,weareonestepaheadofyouonthe"Caniuseanarduino?"front:D
TheIOrequirementsforan8x8x8LEDcubeis:
Layerselect:8
Databusforlatches:8
Addressbusforlatches:3
Outputenable(OE)forlatches:1
Total:21

(http://cdn.instructables.com/FU5/T6VZ/GI0TDO8R/FU5T6VZGI0TDO8R.LARGE.jpg)

TheArduinohas13GPIOpinsand8analoginputs,whichcanalsobeusedas
GPIO.Thisgivesyouatotalof21IOlines,exactlytheamountofIOneededto
runtheLEDcube!
Butwhywriteaboutitwhenwecouldjustshowyou?
WehookedthecubeuptoanArduinoandportedsomeofthesoftware.
SincethemultiplexerarrayandAVRboardareseparatedbyaribboncable,
connectingtheIOlinestoanArduinoisasimplematterofconnectingsome
breadboardwires.Luckily,wesolderedinafemale0.1"pinheaderforthe

transistorlineswhenweweredebuggingthefirstsetoftransistors.Justremove
theATmegaandconnectwiresfromtheArduinotothesepinheaders.
Weconnectedthecubelikethis:DATAbus:Digitalpins07.Thiscorresponds
toPORTDontheATmega328ontheArduinoboard,sowecanusedirectport
accessinsteadofArduinosdigitalWrite(whichisslow).Addressbus:Digitalpins
810.ThiscorrespondstoPORTBbit02.OnthisweHAVEtousedirectport
access.ArduinosdigitalWritewouldn'tworkwiththis,becauseyoucan'tset
multiplepinssimultaneously.Iftheaddresspinsarenotsetattheexactsame
time,theoutputofthe74HC138wouldtriggerthewronglatches.OutputEnable:
Digitalpin11.Layertransistors:Analogpins05anddigitalpins12and13.
WehadtogoabitoutsidethescopeoftheArduinoplatform.Theintentionof
ArduinoistousedigitalWrite()forIOportaccess,tomakethecodeportableand
someotherreasons.Wehadtosidestepthatandaccesstheportsdirectly.In
additiontothat,wehadtouseoneofthetimersfortheinterruptroutine.
TheregistersfortheinterruptandtimersaredifferentondifferentAVRmodels,
sothecodemaynotbeportablebetweendifferentversionsoftheArduino
board.
ThecodeforourquickArduinohackisattached.

arduinocube.pde

(/files/orig/FNH/V3UU/GICYB47D/FNHV3UUGICYB47D.tmp)12KB

Step71:Hardwaredebugging:BrokenLEDs

(http://cdn.instructables.com/FJA/IRLD/GICYB6YO/FJAIRLDGICYB6YO.LARGE.jpg)

Disasterstrikes.ALEDinsidethecubeisbroken!
WehadacoupleofLEDsbreakactually.Luckilythehardestonetogettowas
onlyonelayerinsidethecube.
ToremovetheLED,justtakeasmallpairofneedlenosepliersandputsome
pressureonthelegs,thengiveitalighttouchwiththesolderingiron.Theleg
shouldpoprightout.Dothisforbothlegs,andit'sout.

InsertinganewLEDisthetrickypart.Itneedstobeassymmetricalandniceas
therestoftheLEDs.Weusedahelpinghandtoholditinplacewhilesoldering.
Itwentsurprisinglywell,andwecan'tevenseewhichLEDshavebeen
replaced.

Step72:Feedback

(http://cdn.instructables.com/F5W/33J7/GICYB3NJ/F5W33J7GICYB3NJ.LARGE.jpg)

Welovegettingfeedbackonourprojects!The4x4x4LEDcubehasreceiveda
tonoffeedback,andmanyusershavepostedpicturesandvideosoftheirLED
cubes.
IfyoufollowthisInstructableandmakeyourownLEDcube,pleasepost
picturesandvideo!
Oh,anddon'tforgettoratethisInstructableifyoulikedit:)

Asatokenofgratitudeforallthegreatfeedback,hereisacollageofsomeof
thefeedbackonour4x4x4LEDcubeinstructable:

Wehaveabenicecommentpolicy.
Pleasebepositiveandconstructive.

IMadeit!

140of
2757

AddImages

MakeComment

Next(http://www.instructables.com/id/LedCube8x8x8/?
&sort=ACTIVE&limit=40&offset=40#DISCUSS)

blair29292(/member/blair29292/)

12daysago

Reply

Awesomeinstructable!Howeveristhereatricktodownloadingthefiles?No
(/member/blair29292/)
matterwhatItryitalwaysdownloads.tmpfiles??
flag

ChristophP(/member/ChristophP/) blair29292

Вам также может понравиться