0% found this document useful (0 votes)
345 views9 pages

Arduino Christmas Lights Documented by Netman427

The document provides instructions for using an Arduino board and relay board to synchronize Christmas lights to music. It details the necessary electrical parts including wire, outlets, switches, and relay boards. It then explains how to wire the master power feed and outlets to the relay board and connect the relays to the Arduino board to control the lights through code. Safety tips are provided when working with household electricity.

Uploaded by

geoff.bernard
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
345 views9 pages

Arduino Christmas Lights Documented by Netman427

The document provides instructions for using an Arduino board and relay board to synchronize Christmas lights to music. It details the necessary electrical parts including wire, outlets, switches, and relay boards. It then explains how to wire the master power feed and outlets to the relay board and connect the relays to the Arduino board to control the lights through code. Safety tips are provided when working with household electricity.

Uploaded by

geoff.bernard
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Arduino Christmas Lights

Or How I took 2 months and 8 extensions cords to synchronize lights to music December 2013 - v1.0

Parts List
Electronics Arduinoboard(andobviouslythecables&softwareneededtomakeitwork) Relayboard Electrical outletbox outlets lightswitch wire(Romexisthenamebrandedelectricalcable) wirenuts&electricaltape Software Vixen2.1 Arduinosketch

Electronics

Chancesareifyourereadingthis,youknowwhatanArduinois.Ifyoudont,thiswholedocumentwillbeoflittle use.YoullneedyourArduinoIDEloadedandboardconnectedreadyforuploadingsketches.(Atleastyoushouldknow whereyourstuffis.Again,Ivebettingwiringtheelectricalpartswilltakeawhilesoconnectingtheboardisnotyet necessary.) Therearetwooptionsfortherelayboard.Youcanbuildyourownorbuyapremadeshield.Imusingahomebrew combinationbutIstartedwiththeSeedstudioRelay_Shield_V1.0.

Ithas4relaysandmountsdirectlyontheArduino. Theirdocumentationwasokbuttheexamplewas poor.Basicallyitslikeanyotherdigitaloutputonan Arduino.YouassignadigitalPINasoutputandset ithigh.Thisdevicehassomeextrafeatureslike wirelesscontrolusingRFBee.Thisultimately meansyourestuckbothcoveringArduinoPINS younowcannotuseANDtrappedwiththeirPIN configuration. Channelsareasfollows: PIN7Channel1 PIN6Channel2 PIN5Channel3 PIN4Channel4

YoucanworkaroundtheblockedPINSby buyingalargerboard,whichiswhatIdid. ArduinoMegawithUSBhostmode

Iaddedanadditionalrelayboardtorunchannels512.ItsaSaintek8channelIfoundcheaponAmazon.

Wiring Electrical
IfyouarenotcomfortablewithhighvoltagethenSTOPNOW!!!ImnotanelectricianalthoughIplayoneonthe weekends.EventhoughIthinkenjoyableChristmaslightsmightbeworthelectrocutingmyselffor,youmaynotfeelthe same.Ifindoubt,phoneafriend.Iftheyhanguponyou,readthroughthisonemoretimeandyoumayunderstandjust enoughtokeepyourselfsafe.oratleastnotdead. (Sincesomecountriesusedifferentwiringcolors,thisentiredocumentisbasedonUnitedStateswirecolors.If needed,searchforwirehomeoutletforyourcountrytodetermineanydifferences.ThisstuffcankillyousoIfeelthe needtobeoverspecific.)

Standardhomeoutletsare110voltsanduse3wires.Olderhomesuse2butthatsnottoosafe.Youllseewhylater. Thethreewiresarewhite,black,andgreencorrespondingtoneutral,hot,andground.Alternatingcurrent(A/C)isnot thesameasdirectcurrent(DC)andcannotbethoughtofinthetraditionalsenseofpositiveandnegative. DCshownontheleftisaconstantflowofvoltagewhiletheACvoltagerisesandfallsoveracertaintime.InNorth America,thattimeis60cycles/secondor60hz.Europeuses50hz.

Ifyouthinkofthepicturesasflowofvoltage,thehorizontalXaxisrepresentstheblackorgroundwire.Thehorizontal linelabeledVdcrepresentstheredorpositivesideofthevoltageflow.Withalternatingcurrent,thevoltageliterallyrises thenfalls.Lookingbackatthediagram,the0displacementline(orXaxis)representstheneutralorwhitewire.This correspondstoareferencepointfromwhichvoltagedifferencecanbemeasured.Blackcarriesthevoltageandwhite providesareturnpathforvoltageflow.Thegroundwirewasintroducedasasafetyfactor.Ifforanyreasonawire becomesexposed,thegroundwireprovidesapathfortheelectricitytoflowliterallyintothegroundoftheearth. Electricitytakesthepathofleastresistanceandthegroundcableprovidesthatpath.Withoutit,youllendupbecoming thatpathofleastresistanceandwhilebeinginvolvedwithcircuitryisfun,becomingpartofthatcircuitisnot!Usea voltmetertoverifyzerovoltsanddontforgettochecktheplugifunsure. IfoundeverythingIlearnedsofaraboutACtobeveryfascinatingandsuggestdoingyourownresearch. Themostimportantthingstoremember: Greenisgroundandshouldconnecttoallswitches&outlets. Greenwirewillonlyshockyouifsomethingismiswiredorinsulationismissing. Blackcarriesvoltageandiscalledhotorlive.Donottouch! Whiteisneutralandisthenormalreturnpath.Whiletheorysaysitsok,IsuggestDonottouch! Alwayshookupinthefollowingorder:GREENWHITEBLACK Alwaysdisconnectinthefollowingorder:BLACKWHITEGREEN Dontwireacircuitwhileitslive. Iuseapowerstripsincethecircuitbreakerandswitchprovidesalittleextrainsurance. Checkyourpowerstripisonbeforetearingapartacircuittofindoutwhyitsnotworking.Trustmeonthis.

Parts
510ftcordwithplugtobeusedformasterpowerfeed 2ft3conductorwiretobeusedforjumperpowerfeed 510ft3conductorwire(orothersufficientlysizedwire)forrelay&outletwiring lightswitch outletbox wirenuts

Master Power Feed


Youneedtostartwithathreewirecordthatwillbeusedtofeedpowertothestringsoflights.Iwouldsuggestusinga separatefeedcableforeachsetof10orsolights.Justfollowthesameprocessforeachfeedcableanddistributethe hotlegtotheappropriategroupingofrelays.Iusedanoldcutfromavacuumcleaner.Ithasahardrubberyplug,is long,wellinsulated,andthickenough.Whenpowerflowsthroughacable,bothAD&DCwilllosesomevoltagedueto resistance.Thatresistancewillshowupasheat.Youwantcablethickenoughtoholdthenecessarycurrent(upto 110V@15AMPs)butnotbetooresistanttoflow.Inotherwords,youshouldnotuseCAT5networkcabletocarry 110Vbutwirethethicknessofjumpercablesisalittleoverkill.

Wiring Feed
Startwithyourmasterfeed cable(withplug),lightswitch, twooutletboxes,andthe jumperfeedwire. Striptheinsulationfromthe outsideandthenforallthree innerwires.Hookthegreen wiretothegreenscrewonthe switch.Hookthewhiteneutral wiretothejumperpowerfeed andsecurewithwirenut. Screwtheblackwiretothe switchupperterminal.(Hint: Twistthewireandputasmall bendtotheright.Whenyou tightenthescrew,itwillpullthe wirearound.Alwaysmake sureyourwireissecureinthe plasticbeforetightening.)Addtheblackwirefromthejumperfeedcabletothebottomscrewoftheswitch.Thejumper feedcablewillnowrunintothesecondoutletbox.Theswitchwillallowyoutoturnoffalllightswhileallowingyour systemtorun.ItsusefulforreplacingbulbsbutmakesmefeellikeIhave*sigh*onemorelittlepieceofinsurance.I usebarecopperwireasgroundwireinsomeplacessogreen,copper,andgroundwireareallinterchangeableterms.

Wiring Outlets
Forthis,youllneedanoutletbox,outlet,6inchesofblack,white,green(orcopper),andoneotherifyouhaveit.Iused 4conductorcablesinceitprovidesallthoseandusesredasthelastcolor.Youcanuseblackforthesecondoutlet sinceIsuggestlabelingallwiresanyway. Toalloweachoutlettobeswitchedseparately,wellneedtomodifytheoutlet.Lookingfromthefront,thetabonthe right(hot)sidewillneedtobecut.Oncethetabiscut,hookthegroundwiretothegreenscrewontheoutlet.Next, hookthewhitewiretotheleftsideusingthesamewirewrappingtechnique.Hooktheblackwiretothetopscrewon therightsideandtheadditionalcolorwiretothebottomscrewontherightside. Feedallwiresthroughoutletboxandlabelasfollows: greenground whiteneutral blackhot#1 red(orblack2)hot#2 Thatbundlewillbeusedtofeedthefirsttwochannels.Repeatthesameprocessfortheremainingoutletsbutusethe numbers3&4inplaceofoneandtwo.Makesureblackisonthetopoftheoutletoryouroutletswillbebackwards!

Combining outlets
Now,youllneedsomewirenutsandsomegreenandwhitewire.Connectthegreenwiresfromthejumperfeedwire tothegreenwiresfromeachoutletbox.Dothesameforthewhitewire.Makesurethewirenutsaretightened.Add sometapeifyouwanttobesafe.

Hooking to relays
Youllneedonewireforeachchannelyouaresettingupandoneblackforajumper.My4relaysetupwillneed5total. Hookonetoeachcommon(COM)portonyourrelayboard.Twisttheotherendstogetherandaddtheblackjumper wire.Securewithwirenuts.Taketheotherendoftheblackjumperwireandhookittotheblackwireofthejumperfeed wire.Nowyouhaveahotleadintoeachrelaywhichwillbeusedtosendthehotlegtoeachoutlet.Installthewirefrom eachoutlet(hot#1,hot#2,hot#3,etc.)toeachrelaynormallyopen(NO)connection. Doublecheckyourwiring.Fromthemasterfeedwire,greenandblackshouldbehookedtotheswitch.Green,white thenhooktojumperfeedwire.Blackshouldrunoutofswitchonjumperfeedwire.Greenwirefromjumperfeedwire goesintowireboxandhookstoalloutletgreenwires.Whitefromjumperfeedwiregoesintowireboxandhookstoall outletwhitewires.Blackfromjumperfeedwirehookstowirethatconnectstohotchannelfeeds.Hotchannelfeedsgo toeachrelaycommonterminal.Eachindividualoutlethotwireconnectstotheindividualrelaynormallyopen connection.

Hardware
HereiswherewehooktherelaystotheArduino.Ifyouusearelayshield,youcanpluginandyouregoodtogo. Otherwise(orinaddition)youllneedtowireupaquickcircuittoactivatetherelay.(IusethisfortheSaintekboard.) Thiscircuitusesa10kpulldownresistorto ensurethetransistordefaultstotheoff position.Thedotontheleftsideiswillconnect toadigitalpinonyourArduino.The2.2k resistorthrottlesthecurrentfromtheArduino 5voutput.Thecoilontherelaywillconnectto 5vononepinandtotheRELAYBOARD INPUTmarkedonthegraphic. WhentheArduinopingoeshigh,itwillactivate thetransistorandgiveyouaconnectionto ground,allowingtherelaytoactivate.Although theArduinoprovides5v,useanexternalpower tosupplytherelay5v.
NewerArduinoshaveaninternalpulldownresistorsoyoucaneliminatethe10kone.Theotherpartsshouldcostlessthansixorsevendollars. 3.3voltinputshoulduse2.2k,for5v,use1k.Youcanusea2N2222or2N4401NPNtransistor.

Youllneedonerelayforeachchannel(oroutlet)youplantoswitch.EachrelayneedsanArduinopintodriveit.Im usingatotalof12channels,splitacross2setsofrelays.4areontheSeeedshieldand8areonaSaintek8portrelay board.TheSeeedshieldisprettymuchplug&play.Assignpins47andyouaredone.However,itblocksalotofpins thatIwanttouse.Toaccessthose,IendedupusingaSeeedProtoShield.Imusing8additionalpinstodriveNPN transistorstoprovidegroundusingtheabovecircuit.

Software
Therearetwopartstothesoftware.VixenlightstocreatethedisplaysandArduinocodetolistenforVixencommands.

Arduino Code
TheArduinocodelistensfordataarrivingovertheserialinterfaceandsettheoutputchannelsappropriately.BestI understand,Vixenjustsendsaseriesofbitscorrespondingtoeachchannelyouhaveconfigured.HIGHs(FF)and LOWs(00)areusedtoturnthechannelsonandoff.
/* ArduinoVixengenericserialinterface Basedoncodebysmching(ediy.com.my) Modifiedbynetman427 */ #defineCHANNELS_COUNT13 #defineCh17 #defineCh26 #defineCh36 #defineCh44 #defineCh522 #defineCh624 #defineCh726 #defineCh828 #defineCh930 #defineCh1032 #defineCh1134 #defineCh1236 #defineCh1338 //LEDfortrackbeatindicator intCh[CHANNELS_COUNT]={Ch1,Ch2,Ch3,Ch4,Ch5,Ch6,Ch7,Ch8,Ch9,Ch10,Ch11,Ch12,Ch13} intincomingByte[CHANNELS_COUNT]//arraytostorethevaluesfromserialport voidsetup() { Serial.begin(9600) //setchannelpinstooutput for(bytei=0i<CHANNELS_COUNTi++)pinMode(Ch[i],OUTPUT) } voidloop(){ if(Serial.available()>=CHANNELS_COUNT){ for(inti=0i<CHANNELS_COUNTi++){ //Serial.readprocessesonechar incomingByte[i]=Serial.read() digitalWrite(Ch[i],incomingByte[i])//WritetheDigitalOutputtotherespectivepin. } } }

OpenyourArduinoIDE,loadtheabovesketchandwritetoyourArduino. Howdoesthiswork? Createanarraytoholdthechannelpins. Loopthroughthearraytosetthepinstooutputmode. Looptocreateacounterpointingtothecurrentchannelnumber. Setthecurrentchannelnumber(fromarray)totheincomingcharacter Doitagainforeachchannelthenstartoverforthefirstchannel.

HereisasampleofthedatasentbyVixen.Notethereisonecolumnforeachchannel.
1217201302:45:49.353[10]0000000000 1217201302:45:52.119[10]FFFFFFFFFF 1217201302:45:53.462[10]0000000000 1217201302:45:54.822[10]FF00000000 1217201302:45:55.275[10]0000000000 1217201302:45:56.181[10]00FF000000 1217201302:45:56.431[10]0000000000 1217201302:45:57.431[10]0000FF0000 1217201302:45:57.681[10]0000000000 1217201302:45:58.900[10]000000FF00 1217201302:45:59.134[10]0000000000 AllOff AllOn AllOff Ch1On Alloff Ch2On AllOff Ch3On AllOff Ch4On AllOff

Inthisexample,Iturnedallchannelsonthenalloff.Next,eachchannelisturnedonandoffindividually. WhentheArduinoseesFF,itsetsthepinassignedtothechanneltoHIGH.Doublezeros(00)willsetthepin LOW.ToenableChannel1,4and5,itwouldlooklikethis:FF0000FF00.

Vixen
Nowthatyouknowallthat,itstimetosetupVixen.Therearetwoversions,stickwithversion2.1.Ithinkitssimpler. http://www.vixenlights.com/downloads/vixen2downloads/.Onceyoudownloadtheprogram,unziptoadirectory. Youcanusethewizard,butIrecommendagainstit.Ithinkitsbettertohavethetrickexplainedbeforewatchingthe magiciandoit.Therefore,herearethestepsnecessarytosetupyourhardwareandcreateasequencemanually.

Create a Profile
Profilesdefinesyourchannelsandwhathardwareyouareusing. ClickProfilesManage. Click+tocreateaprofileandgiveitaname.IsuggestArduinoSerial.TheEditaprofilewindowwillopen. ClickAddonechanneluntilallyourchannelsareadded.(1foreachrelay)

Onceallchannelsareadded,clickOutputpluginsatthebottom.

SelectGenericSerialfromtheAvailablePluginssection,clickUsethenselectGenericserialUnderPluginsinUse. Addyourchannelsontherightside,thenclickPluginSetupunderthechannelnumbers.

Fortroubleshooting,youcanincludeEventdatalogger.Togetbackhere,clickProfiles/ManagethendoubleclickyourprofilethenclickOutputplugins.

SelecttheSerialPortyourArduinoisonandchoose9600fortheBaudrate.ClickOKtoclose.

ClickDonetoclosethroughallwindowstoreturntothemainscreen.

Sequences
Ok,soitsallsetup.HowdoImakethelightswork?Onceyouhaveconfiguredtheplugin,youcantesteachchannel butnotuntilyoustarttocreateatrack.SelectNewStandardsequence.Clickcreateit.Nowlookinthetopleftand youshouldseeacheckboxnexttothechannelcount.

Testeachchanneltoverifyyoursetup.

Throughalotoftrial&error(andsuggestions),Ifoundtheeasiestwaytocreateasequenceisusingatrackbeat indicator.Youlluseitasareferencepointwhencreatingsequences.IusearesistorsoldereddirectlytoanLEDand oneadditionaloutputpin.TheotherendgoestogroundontheArduino.Ifyouareusing12relays,thiswillbecomeyour 13thchannel.Itsassumedyoursequencewillbesettomusic,somakesureyouhaveanMP3fileavailable. Associatetheaudiofilewiththesequence.ClickSequencethenAudio.ClickAssignaudiotoaddanmp3audiotrack. VerifyResizethesequencetotheaudiolengthischecked. Younowneedtosequencethetrackbeatwiththeaudio.VixencanplaytheaudioandyouusetheCTRLkeyonthe keyboardtoselectwhentoactivatethechannel.Fornow,justdothebeattrack.Clickonthechannelyouwishtouse thenclickplay.Hopefullyyoucancountmusicandfindthedownbeatofthesong.RememberFirstgradeandplaying MaryHadaLittleLambontherecorder?Youcount12341234.HitCTRLforeachcountof1.Dontbeconfusedwith songslikeJingleBells.Its123123.Justhitonwhatfeelslikethedownbeat.Youcanpause,rewind,orstartoverifyou needto.Onceyouvedonethewholesong,clickok.Youshouldnowhaveasequencewithasteadypatternofboxes onChannel13.. Youcannowcreateasimplepatternusingthefollowingmethod: OnChannel1,highlightinbetweenthebeattrack.Hitentertoactivate.(Shouldcover4squares) Repeatforentiresong. CopyChannel1toChannel2andinvert.Toinvert,leftclickandholdtoselectasection.Pressttoinvert. CopyChannel2toChannel3thenremovethesecond&thirdboxes. CopyChannel3toChannel4theninvert. Copyasyouseefit.Removeandaddcyclestochangethepatternup. Removeandaddmarkswhereyouwanttocyclethelightsandplayaroundwithdifferentsequences. Youcannowtestit.ClicktheCheckmarktostartplaying,sitbackallyoureffort.

You might also like