You are on page 1of 5

 Decenber 20!

íler seeing lhe denos, l slurled lhinking uboul vhul
else l tould nuke lhis LCD displuy do. So, l slurled
pulling oul tode l hud vrillen over lhe yeurs und begun
porling il lo lhe Arduino Uno. lirsl oíí vus lhe
Mundelbrol sel. \hile lhe tode vorked und lhe resulls
vere beuuliíul, il look u íull íive ninules lo generule
vhith vus okuy betuuse l vusn'l in u hurry. 1he long
generulion line vus nol loo surprising betuuse lhe
Mundelbrol sel requires u lol oí ílouling poinl tultululions
vhith ure line tonsuning on uny eighl-bil protessor.
Lquully us prelly und in generul less protessor-
inlensive ure lhe tultululions oí Juliu sels. So, lhis is vhul l
lried nexl, und sone oí lhe inuges produted look ny
breulh uvuy. l vus slurling lo lhink lhis hurdvure
tonbinulion hud sone neril, so one lhing leud lo lhe
nexl und prelly soon l hud uboul 16 diííerenl displuy
pullerns running intluding: lhe Mundelbrol sel, Juliu sels,
plusnu pullerns, nunerous spirogruph pullerns, slur bursl
pullerns, tontenlrit squures und tirtles, und nuth nore.
Nol being sulisíied vilh slulit repeuling inugery, l
udded u lurge dose oí rundonness inlo lhe pullern
generulion protess, und vilh lhe uddilion oí nunerous
Distuss lhis urlitle in lhe |uts & \o|ts íoruns ul
ßy Craig A. Lindley
l didn't start out to buiId a personaI
Iight show for ny desk, but in the
end that is what happened. lt aII
started when l saw a 5ain5nart
3.2" 320 x 240 TFT LCD dispIay
with buiIt-in dispIay controIIer,
touch screen controIIer, and 5D
card interface for saIe on Anazon
for $16. l aIready had an Arduino
Uno on hand, so connecting these
two devices seened Iike a naturaI
thing to attenpt. Having never
connected an LCD dispIay to a
nicrocontroIIer before, l was
anxious to do so. Finding a weII
written driver Iibrary (see
Resources) for this dispIay put the
icing on the cake, so l got to work
wiring things together. ln an
afternoon, l wired the LCD dispIay
to the Arduino, downIoaded and
instaIIed the UTFT driver on ny
Mac, and conpiIed and ran the
denos that cane with the driver. l was anazed at how easy this cane
together, and l had the basis for ny personaI Iight show running in Iess than
a day.
pulelles (sone oí vhith ulso tonluin rundonness) l vus
soon generuling sone very unique inuges.
ll vus lhen lhul il hil ne. l should putkuge lhis lhing
up us u desklop devite und lel il generule inuges ud
iníinilun. Aíler ull, lhe hurdvure tosl less lhun S40, so
vhy nol.
Sinte huving lhis devite on ny desk}benth, l huve
íound il helps ne lhink. \hen l gel slutk on sonelhing l
un vorking on, l glunte over ul lhe displuy íor u íev
ninules luking ny nind oíí oí lhings vhith sonelines
helps in íinding u solulion. lor lhis reuson, l've detided lo
tull lhis devite u ºDesklop Conlenplulor.ª
Yhe Mazdwaze
Building u Conlenplulor requires lhe eletlronit
tonponenls shovn in lhe Parts tist.
Cnte you huve gulhered lhe required tonponenls,
viring lhe Arduino Uno lo lhe LCD displuy is eusy lhough
rulher ledious due lo lhe nunber oí vires involved. A lol
oí vires ure required betuuse l used u 16-bil inleríute
belveen lhe Arduino Uno und lhe LCD displuy. l those
lhis insleud oí un eighl-bil or seriul inleríute in lhe inleresl
oí períornunte.
A druvbutk lo using lhe 16-bil inleríute vilh lhe
Arduino Uno is lhul il uses up every uvuiluble l}C pin. 1his
neuns neilher lhe louth streen tonponenl nor lhe SD
turd inleríute uvuiluble on lhe LCD displuy's PCB tun be
used. Lutkily, neilher vere netessury íor lhis upplitulion.
All required tonnetlions belveen lhe Arduino Uno
und lhe LCD displuy ure shovn in 1abIc 1 und lhe LCD
displuy tonnetlor pinoul is shovn in figurc 1. 1uke your
line vhen doing lhis viring und double-thetk your vork
vhen you're íinished beíore upplying pover.
1he Conlenplulor is progrunned und povered viu
lhe USB tuble plugged inlo lhe Arduino Uno. Cnte
progrunning is tonpleled, u USB thurger tun be used lo
pover lhe Conlenplulor.
Op4tonaf Mazdwaze
As l vus vriling lhis urlitle, l distovered SuinSnurl
ulso sells un ussenbly tonsisling oí un Arduino
Megu2560, u shield íor tonnetling lhe LCD displuy lo lhe
Decenber 20!2 
Arduiho Uho board OIher Arduihos cah be used buI Ihis will hecessiIaIe chahges ih Ihe soIIware.
.1" break-away male header pihs You heed ehough oI Ihese pihs Io populaIe all oI Ihe Iemale Ì/O cohhecIors oh Ihe Arduiho Uho.
SaihSmarI 320×240 TFT LCD display This is a 3.2" display, alIhough oIher SaihSmarI displays based oh Ihe SSD1289 cohIroller will
probably work as well.
USB cable The USB cable will become a permahehI parI oI Ihe CohIemplaIor iI you package iI like Ì did.
USB charger This is Ior ruhhihg Ihe CohIemplaIor aIIer programmihg is perIormed.
Hook-up wire LighI gauge Ile×ible wire is besI
27 ohm 1/2 waII resisIor This is required Io power Ihe LED back lighIs oI Ihe LCD display. See Table 1.
TABLE 1. LCD display Io Arduiho Uho cohhecIiohs Ior
16-biI daIa ihIerIace.
LCD Display
Pih Number
Arduiho Uho
Sighal Name
21 DB0 D8 16-biI daIa
22 DB1 D9 16-biI daIa
23 DB2 D10 16-biI daIa
24 DB3 D11 16-biI daIa
25 DB4 D12 16-biI daIa
26 DB5 D13 16-biI daIa
27 DB6 A0 16-biI daIa
28 DB7 A1 16-biI daIa
7 DB8 D0 16-biI daIa
8 DB9 D1 16-biI daIa
9 DB10 D2 16-biI daIa
10 DB11 D3 16-biI daIa
11 DB12 D4 16-biI daIa
12 DB13 D5 16-biI daIa
13 DB14 D6 16-biI daIa
14 DB15 D7 16-biI daIa
4 PS A5
5 WP A4
WriIe Ehable
(acIive low)
6 PD 5V
Pead Ehable PD
(acIive low)
Iied Io 5V
15 CS A3
Chip SelecI
(acIive low)
17 PEST A2 Chip PeseI
19 LED-A 5V
LCD sighal Iied
Io 5V Ihrough
27 ohm resisIor
1 GND GND Grouhd
2 VCC 5V Power
NoIe: There are ho Ì/O lihes leII over Io cohhecI Ihe
Arduiho Uho Io Ihe Iouch screeh cohIroller or SD card
ihIerIaces, so Ihese aspecIs oI Ihe circuiIry are hoI available.
Arduino, und lhe sune LCD displuy ve ure using here.
1hey oííitiully tull il lhe SuinSnurl Megu2560 Bourd÷3.2
1l1 LCD Module Displuy÷Shield Kil íor Alnel Alnegu
AVk 16AU Alnegu8U2 und ils uvuiluble íron lheir
vebsile or on eBuy. lí you vere lo buy lhis ussenbly ul
-S55, you tould use il vilhoul huving lo do uny viring ul
ull. A ninor soílvure thunge (lo be destribed shorlly) is
required, hovever, lo run lhe Conlenplulor skelth on lhis
A nujor udvunluge lo using lhis hurdvure is lhul lhere
ure nuny nore l}C lines uvuiluble vhith ullov uttess lo
lhe louth streen tonlroller und lhe SD turd inleríute ií
lhese ure inporlunl lo your upplitulion. Addilionully, lhe
Megu2560 hus íour lines lhe kAM (8K) und eighl lines
lhe llush (256K) vhith vould ullov nuny nore displuy
pullerns lo be developed.
Yhe SoF4waze
1he Conlenplulor requires lvo pietes oí soílvure íor
ils operulion. 1he íirsl is lhe U1l1 driver librury íor lhe
LCD displuy und lhe setond is lhe Arduino skelth l vrole
tulled Conlenplulor.ino (see  íor bolh).
tns4afftng 4he MYFY
You tun skip lhis setlion ií you ulreudy knov hov lo
inslull un Arduino librury. lí you don'l,
reud on.
1. Lxil lhe Arduino lDL ií you
huve il running.
2. Dovnloud lhe U1l1 librury
(U1l1.rur) using lhe link spetiíied in
3. Lxlrutl lhe librury íiles
diretlory using vhulever íile
exlrutlion lool is uppropriule íor your
plulíorn (\indovs, Linux, CS\,
4. Copy lhe U1l1 diretlory lo
your Arduino}libruries diretlory. 1he
 Decenber 20!2
FlGURE 3. An Aroulno Uno.
The oIIicial source oI Arduiho ihIormaIioh
The Iree ahd opeh source Arduiho
developmehI Iools Ior Wihdows, OSX,
ahd Lihu× are available Ior Iree aI
hIIp:// Ì used
versioh 1.0.1 Io develop Ihis soIIware.
The LCD display is available aI
sd-sloI-Ior-arduiho-2560.hIml. ÌI is also
sold Ihrough Amazoh.
The combihaIioh oI ah Arduiho Mega2560,
a display shield, ahd LCD display is
available aI
ahd Ihrough Amazoh.
The Arduiho skeIch described ih Ihis arIicle
is available Irom Ihe arIicle lihk
ahd is called CohIemplaIor.iho.
ÌhIormaIioh abouI Ihe UTFT LCD driver
wriIIeh by Hehhihg Karlseh is available aI
SalnSmart 320×240
TFT LCD olsplay.
FlGURE 1. SalnSmart 320×240 TFT LCD
olsplay connector plnout.
diretlory slrutlure should be Arduino}libruries}U1l1.
5. 1he librury should nov be inslulled.
1o veriíy torretl inslullulion oí lhe librury, slurl up lhe
Arduino lDL und seletl lile}Lxunples íron lhe nenu. You
should see lhe U1l1 enlry lisled.
Cnte you huve lhe hurdvure vired up, lhe U1l1
driver inslulled, und lhe Conlenplulor skelth uvuiluble,
you tun dovnloud lhe skelth viu lhe Arduino lDL und
vulth lhe nugit huppen.
You don'l need lo underslund hov lhe Conlenplulor
skelth vorks in order lo use und}or uppretiule il.
lí, hovever, you vould like lo knov hov lhe vurious
gruphit displuy pullerns vork or ií you vould like lo
thunge lhe skelth lo udd nev displuy pullerns or renove
exisling ones, nore in-deplh knovledge is required. 1he
besl vuy lo gulher lhis knovledge is by knoving hov lhe
Conlenplulor is supposed lo vork und by sludying lhe
Conlenplulor skelth.
Ðasto Opeza4ton
As nenlioned in lhe inlrodutlion, lhe Conlenplulor
provides 16 displuy pullerns íor our vieving pleusure.
Code in lhe skelth rundonly seletls vhith displuy pullern
is shovn und nukes sure lhul ull 16 pullerns ure displuyed
beíore uny ure ulloved lo repeul. 1he ||ags urruy in lhe
tode tonlrols lhis. A displuy pullern vill be shovn íor
eilher 30 setonds or lhe line il lukes íor lhe pullern lo
generule und displuy ilselí - vhithever is shorler. lí
displuy pullern generulion lukes less lhun 30 setonds,
sone pullerns vill repeul so you vill see lhen nunerous
lines in suttession.
1he soílvure vus designed so lhul lhe individuul
displuy pullerns do nol need lo tontern lhenselves vilh
displuy durulion lining. All lhey need lo do is lo tull lhe
íuntlion c|oc|lot1|ooout() perioditully und ií lheir displuy
line period hus expired, lheir exetulion vill tone lo un
end und lhe nexl displuy pullern vill be invoked. 1he
sotjop und |otgjop nethunisn buill inlo lhe Arduino
progrunning lunguuge ullovs lhis lo vork. Coogle lhese
lerns ií you ure inleresled in hov.
Anolher inleresling uspetl oí lhe tode is lhe use oí
un urruy (tulled pattottlutct|ots in lhe tode) oí íuntlion
poinlers lo lhe displuy pullern roulines. A displuy pullern
is seletled und exetuled viu un index inlo lhe urruy vilh
lhis single line oí tode:
A lypitul displuy pullern rouline is shovn nexl. 1his
tode druvs u series oí tonnetled line segnenls unlil ils
line is up. Any displuy pullern roulines you vrile vould
resenble lhis tode.
void lincsPacrn` {
Decenber 20!2 
in x, ,, xPrcv, ,Prcv;
// Pick a random çalcc
in çalccNumbcr ÷ randomNUM_OF_PALFTTFS`;
// Pick a random çlacc o sar wihin hc
// çalcc
in colorIndcx ÷ randomPALFTTF_SIZF`;
whilc ruc` {
for in i ÷ 0; i < 80; i++` {
colorIndcx %÷ PALFTTF_SIZF;
x ÷ randomMAX_X_LANDSCAPF`;
, ÷ randomMAX_Y_LANDSCAPF`;
lcd.drawLincx, ,, xPrcv, ,Prcv`;
xPrcv ÷ x;
,Prcv ÷ ,;
lnporlunl lhings lo nole uboul lhis tode ure:
- 1he pulelle íron vhith lhe tonnetled lines vill be
tolored is seletled rundonly.
- 1he tolor pitked íor lhe íirsl line is seletled
rundonly íron lhe tolors tonluined in lhe pulelle.
- A vhile loop is used lo tonlinuully tytle lhis displuy
- 1he c|oc|lot1|ooout íuntlion is tulled vilhin lhe
vhile loop.
- 1here is u deluy uíler ull 80 lines huve been
displuyed. 1hen, lhe displuy is tleured und lhe
protess slurls over.
As nenlioned, u soílvure thunge is required lo lhe
Conlenplulor.ino skelth ií u SuinSnurl Megu2560 is used
insleud oí un Arduino Uno. 1he nornul inslunliulion oí lhe
LCD driver íor un Arduino Uno is us íollovs:
// Uncommcn ou ncx linc whcn Sainsmar LCD
// disçla, conncccd dirccl, o Arduino Uno
UTFT lcdSSD128?, 1?, 18, 1¯, 16, LANDSCAPF`;
lí you ure going lo use lhe Megu2560, you vould
tonnenl oul lhe line ubove und untonnenl lhe U1l1
line belov:
// Uncommcn ou ncx linc whcn running on
// Sainsmar Arduino Mcga 2360 + LCD shicld +
// LCD disçla,
// UTFT lcdSSD128?, `8, `?, 40, 41, LANDSCAPF`;
 Decenber 20!2
2 Ash 4.75" 1.5" 3/8" Sides
2 Ash 3" 1.5" 3/8" Top/boIIom
1 WalhuI 4.75" 3.75" 3/8" FrohI pahel wiIh cuIouI Ior Ihe LCD Io proIrude
1 WalhuI 4.75" 3.75" 3/8" Pear pahel wiIh hole drilled Ior USB cable
4 Brass #6 screws Ior holdihg Ihe back oh
Glue For holdihg Ihe bo× IogeIher