Sunteți pe pagina 1din 32

ArduinoControlledLightDimmer

(/) let's make


by
Explore(/tag/typeid/) Login(/account/login/) | SignUp(/account/gopro)
Contests(/contest/) Classes(/classes/)
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
Publish(/about/create.jsp)
Featured:Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps Arduino(/tag/typeid/categorytechnology/channelarduino/)
3DPrintingClass(https://www.instructables.com/class/3DPrintingClass/) .

Collection IMadeit! Favorite Share


Sewing(https://www.instructables.com/tag/typeid/categorycraft/channelsewing/)

pricedrop

3,59$ 54,99$

Banggood

49,99$ 40,99$

49,14$ 49,14$

Banggood.com

(/file/F3QO7VAH8W1VGLR/)

(/file/FQZNYV7H8CVG9TK/) (/file/FZE7EGVH8CVGA5W/)

WARNING:Somepeopletrytobuildthiswithanoptocouplerwith
zerocrossingcoz'thatisbetter'right?Someareeventoldinelectronics
shopsitisbettertousesuchanoptocoupler.WRONG.Thiswillonlywork
AboutThisInstructable
witharandomfireoptocoupler:NOTignitingatzerocrossingisthe
principleofthisdimmer. License:
8 570.952 views
SwitchinganACloadwithanArduinoisrathersimpel:eitheramechanicalrelay
462 favorites
orasolidstaterelaywithanopticallyisolatedTriac.(IsayArduino,butifyou
usean8051orPIC16F877Amicrocontroller,thereisstuffforyoutoohere.)
diy_bloke
ItbecomesabitmoretrickyifonewantstodimamainsAClampwithan (/member/diy_bloke/)
arduino:justlimitingthecurrentthroughe.g.atransistorisnotreallypossible Follow 404
duetothelargepowerthetransistorthenwillneedtodissipate,resultingin
(/member/diy_bloke/)
muchheatanditisalsonotefficientfromanenergyusepointofview. Bio:Iamaphysicianbytrade.Aftera
careerinthepharmeceuticalworldI
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Phasecutting
OnewayofdoingitisthroughphasecontrolwithaTriac:theTriacthenisfully decidedtotakeitabitsloweranddo
ArduinoControlledLightDimmer by
opened,butonlyduringapartofthesinusACwave.Thisiscalledleadingedge thingsI...More(/member/diy_bloke/)
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
cutting.
OnecouldletanArduinojustopentheTriacforanumberofmicroseconds,but Morebydiy_bloke:
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
thathastheproblemthatitisunpredictableduringwhatpartofthesinuswave
Collection
thetriacopensandthereforethedimminglevelisunpredictable.Oneneedsa IMadeit! Favorite Share
referencepointinthesinuswave. (/id/Addingan
Forthatazerocrossingdetectorisnecessary.Thisisacircuitthattellsthe
Arduino(oranothermicrocontroller)whenthesinuswavegoesthroughzero
andthereforegivesadefinedpointonthatsinuswave. MCP23017IOExtendertoArduinoor
OpeningtheTriacafteranumberofmicrosecondsdelaystartingfromthezero
crossingthereforegivesapredictablelevelofdimming.
3,59$ 54,99$
ESP82/)
PulseSkipModulation
AnotherwayofdoingthisisbyPulseSkipModulation.WithPSM,oneormore
fullcycles(sinuswaves)aretransferredtotheloadandthenoneormorecycles
(/id/CalculatingSunsetandSunrisefora
arenot.Thougheffective,itisnotagoodwaytodimlightsasthereisachance
forflickering.Thoughitmightbetempting,inPSMoneshouldalwaysallowafull
sinuswavetobepassedtotheload,notahalfsinusasinthatcasetheloadwill
Microcontroll/) (/id/A
befedfactuallyfromDCwhichisnotagoodthingformostACloads.The
49,99$ 40,99$
differencebetweenleadingedgecuttingandPSMismainlyinthesoftware:in
bothcasesonewillneedacircuitthatdetectsthezerocrossingandthatcan
controlatriac. SimpleMQTTPubSubNodeWith
ArduinoUNOandENC/)

Acircuitthatcandothisiseasytobuild:Thezerocrossingisdirectlyderived
fromtherectifiedmainsAClinesviaanoptocouplerofcourseandgivesa
signaleverytimethewavegoesthroughzero.Becausethesinewavefirstgoes
throughdoublephasedrectification,thezerocrossingsignalisgivenregardless
49,14$ 49,14$
whetherthesinuswavegoesupthroughzeroordownthroughzero.Thissignal
thencanbeusedtotriggeraninterruptintheArduino. Banggood.com
PWMdimming
PWMdimming,asinLEDsisnotdonefrequentlywithACloadsforanumberof
reasons.Itispossiblethough.Checkthisinstructabletoseehow
(https://www.instructables.com/id/ACPWMDimmerforArduino/).

Itgoeswithoutsayingthatthereneedstobeagalvanicseparationbetweenthe
Arduinosideofthingsandanythingconnectedtothemains.Forthosewhodo
notunderstand'galvanicseparation'itmeans'nometalconnections'thus>
optocouplers.BUT,ifyoudonotunderstand'galvanicseparation',maybeyou
shouldnotbuildthis.

Thecircuitpicturedheredoesjustthat.Themains220Voltvoltageisledthrough
two30kresistorstoabridgerectifierthatgivesadoublephasedrectifiedsignal
toa4N25optocoupler.TheLEDinthisoptocouplerthusgoeslowwitha
frequencyof100Hzandthesignalonthecollectorisgoinghighwitha
frequencyof100Hz,inlinewiththesinusoidwaveonthemainsnet.Thesignal
ofthe4N25isfedtoaninterruptpinintheArduino(orothermicroprocessor).
TheinterruptroutinefeedsasignalofaspecificlengthtooneoftheI/Opins.
TheI/OpinsignalgoesbacktoourcircuitandopenstheLEDandaMOC3021,
thattriggerstheOptoThyristorbriefly.TheLEDinserieswiththeMOC3021
indicatesifthereisanycurrentgoingthroughtheMOC3021.Mindyouthough
thatindimmingoperationthatlightwillnotbeveryvisiblebecauseitisvery
shortlasting.Shouldyouchosetousethetriacswitchforcontinuoususe,the
LEDwilllightupclearly.

Mindyouthatonlyregularincandescentlampsaretrulysuitablefordimming.It
willworkwithahalogenlampaswell,butitwillshortenthelifespanofthe
halogenlamp.Itwillnotworkwithanycfllamps,unlesstheyarespecifically
statedtobesuitedforadimmer.ThesamegoesforLEDlamps

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
IfyouareinterestedinanACdimmersuchasthisbutyoudonotwanttotry
buildingityourself,thereisasomewhatsimilardimmeravailableat
ArduinoControlledLightDimmer by
www.inmojo.com(http://www.inmojo.com),however,thatisa110Volt60Hz
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
version(butadaptablefor22050Hz),thathasbeenoutofstockforawhile.You
willalsofindaschedulehere
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
(http://fleck.rullz.lv/acdimmer/ac_dimmer_220V_circuit.png).
Collection IMadeit! Favorite Share
NOTE!ItispossiblethatdependingontheLEDthatisused,thesteeringsignal
justdoesnotcutitandyoumayendupwithalampthatjustflickersratherthan
beingsmoothlyregulated.ReplacingtheLEDwithawirebridgewillcurethat.
TheLEDisnotreallynecessary.increasethe220ohmresistorto470then

STOP:Thiscircuitisattachedtoa110220Voltage.Donotbuildthisifyou 3,59$ 54,99$

arenotconfidentaboutwhatyouaredoing.Unplugitbeforecomingeven
closetothePCB.ThecoolingplateoftheTriacisattachedtothemains.
Donottouchitwhileinoperation.Putitinaproperenclosure/container.

WAIT:Letmejustaddastrongerwarninghere:Thiscircuitissafeifitis
builtandimplementedonlybypeoplewhoknowwhattheyaredoing.If
youhavenoclueorifyouaredoubtingaboutwhatyoudo,chancesare
49,99$ 40,99$
youaregoingtobeDEAD!DONOTTOUCHWHENITISCONNECTEDTO
THEGRID

Materials
Zerocrossing
4N25(http://www.dickbest.nl/index.php?_a=viewProd&productId=5009)0.25or
H11AA1orIL250,IL251,IL252,LTV814(seetextinthenextstep)
Resistor10k(http://www.dickbest.nl/index.php?_a=viewProd&productId=4784)
49,14$ 49,14$
0.10
bridgerectifier400Volt(http://www.dickbest.nl/index.php? Banggood.com
_a=viewProd&productId=2828)0.30
2x30kresistor1/2Watt((http://www.dickbest.nl/index.php?
_a=viewProd&productId=8846)resistorswillprobablydissipate400mWmax
each0.30
1connector(http://www.dickbest.nl/index.php?
_a=viewProd&productId=593)0.20
5.1Voltzenerdiode(optional)

Lampdriver
LED(http://www.dickbest.nl/index.php?_a=viewCat&catId=326)(Note:youcan
replacetheLEDwithawirebridgeastheLEDmaysometimescausethelamp
toflickerratherthantoregulatesmoothly)
MOC3021(http://www.dickbest.nl/index.php?_a=viewProd&productId=1416)If
youchoseanothertype,makesureithasNOzerocrossingdetection,Ican't
stressthisenoughDONOTusee.g.aMOC3042
Resistor220Ohm(http://www.dickbest.nl/index.php?
_a=viewProd&productId=4503)0.10(Iactuallyuseda330Ohmandthat
workedfine)
Resistor470Ohm1k(http://www.dickbest.nl/index.php?_a=viewCat&catId=313)
(Iendedupusinga560Ohmandthatworkedwell)
TRIACTIC206(http://www.dickbest.nl/index.php?_a=viewProd&productId=673)
1.20orBR136(http://www.dickbest.nl/index.php?
_a=viewProd&productId=1601)0.50
1connector(http://www.eoobv.nl/index.php?_a=viewProd&productId=13612)
0.20

Other
PieceofPCB6x3cm
electricwiring

Thatisabout3inparts Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Ad
ArduinoControlledLightDimmer
OrlandooF150OH35P01KIT
by
Parts...
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
$3.59LatestFashion,FreeShipping
Download Banggood.com
h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

3,59$ 54,99$

Step1:ArduinoControlledLightDimmer:thePCB

49,99$ 40,99$

(/file/FZE7EGVH8CVGA5W/)
49,14$ 49,14$

Banggood.com

(/file/F17BJ7OHO7XKD6O/) (/file/FR5YJV8H8CVGALM/)

YouwillfindtwopicturesforthePCB:myfirstone,thatIleaveherefor
documentationpurposesandaslightlyalterednewone.ThedifferenceisthatI
leftoutthezenerdiodeasitisnotreallynecessaryandIgavetheLEDitown
(1k)resistor:itisnolongerinserieswiththeOptocoupler,thatnowhasa470
Ohmresistor.ImadethePCBviadirecttonertransferandthenetcheditina
hydrochloricacid/Hydrogenperoxidebath.Thereareplentyofinstructables
tellinghowtodothat.Youcanusetheattachedprintdesigntodothesame.
Populatingtheprintisquitestraightforward.IusedICfeetfortheoptocouplers
andthebridgerectifier.
Downloadtheprinthere
(https://dl.dropboxusercontent.com/u/52513692/acDimmer_new.fzz).
Note:YouneedFritzingforthis.Forthedirecttonertransfer,theprintedsideof
theprintedpdffile,goesdirectlyagainstthecopperlayerfortransfer.Onceitis
transferred,youwillbelookingattheinkfromtheothersideandthusseethe
textnormalagain.ImadeslightalterationsinthePCB:Iremovedthezenerdiode
andtheLEDisnolongerinserieswiththeoptocoupler.

IusedaTIC206.Thatcandeliver4amperes.Keepinmindthoughthatthe
coppertracksofthePCBwillnotbeabletowithstand4Amperes.Forany
seriousload,solderapieceofcopperinstallationwireonthetracksleadingfrom
theTRIACtotheconnectorsandonthetrackbetweenthetwoconnectors.

Incaseitisnotclearwhattheinputsare:fromtoptobottomonthesecond
picture:
+5Volts Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Interruptsignal(goingtoD2onarduino)
ArduinoControlledLightDimmer
Triacsignal(comingfromD3onArduino) by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
Ground
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
NOTE:
Collection
IfyouhaveanH11AA1orIL250,251or252optocouplerthenyoudonotneed IMadeit! Favorite Share
thebridgerectifier.ThesehavetwoantiparelleldiodesandthuscanhandleAC.
Itispincompatiblewiththe4N25,justpopitinandsolder2wirebridges
betweenR5and+andR7and.TheLTV814isnotpincompatible

OrlandooF150
OH35P01KITParts... 3,59$ 54,99$

$3.59
FastDelivery
Banggood

49,99$ 40,99$

Step2:AWordonInductiveLoads:Theory

49,14$ 49,14$

Banggood.com

(/file/FNEK1HIHLA110VM/)

Thepresentedcircuitissuitedforpureresistiveloadssuchasincandescent
lamps.
Shouldyouwanttouseitforinductiveloads,thenasnubbercircuitis
necessary.ThefigureshowsthemodificationsforusewithInductiveloads.Mind
you,thisisnotsomethingItriedasIjustwantedtodimlamps,butitisbasedon
examplesandtheoryavailableontheinternet.Youwouldhavetoadaptthe
providedPCB
Thetopfigureshowsthecircuitasis,fordimmingalamp.Itisinallitssimplicity
justaresistortotriggerthegateviathediacintheoptocoupler.Thevalueof1k
maybechangedasdiscussedinthetextbefore.
Thebottomfiguregivesanomnipresentcircuitforuseininductiveloads.
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Itconsistsofanadditionalresistorandcapacitor.Thegatecurrentisbelow
ArduinoControlledLightDimmer by
15mA.Ifyouareusingalesssensitivetriactocontroltheinductiveload,reduce
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
theresistorfrom2.4kto1.2k,providingmorecurrenttodrivethetriacand
increasethecapacitorto200nF.Thissnubbercircuitistheretoprotectthetriac
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
fromthehighvoltagegeneratedfromaninductiveload.Thefeedbackmay
causesomeproblemfornoninductiveload.Thesmallleakagecanbe Collection IMadeit! Favorite Share
significantenoughtoturnonsmallload(forexamplealamp).

Thereareothersnubbercircuits,e.g.aresistorandcapacitorinseriesdirectly
overtheload

3,59$ 54,99$

Step3:TheSoftware,aBitofTheory

49,99$ 40,99$

49,14$ 49,14$

Banggood.com

(/file/FTSFJSZHRGNRMCH/)

Ifyoucouldcarelessaboutthetheory,butjustwantthesoftware,gotothenext
step

ThewaytouseanACdimmer/faderisquitesimpleonceyouunderstandthe
basics:

InACthepowerfedtothelampisdirectlyrelatedtothetotalsurfaceofthe
sinuswave,thelampcanberegulatedbyonlyallowingapredictablepartofthat
sinuswavetoflowthroughthelamp.

Assuchweneedareferencepointonthatsinusfromwherewecalculatewhen
thelamphastobeswitchedon.

Theeasiestreferencepointtouseisthesocalled'zerocrossing':themoment
thatthelightgoesthroughzero.
Aftereachzerocrossingthereisonefullhalfofthesinuswaveavailabletosend
throughthelamp.

Sowhatthesoftwareneedstodoistodetectthezerocrossing,andthenwaitfor
asetamountoftimeonthatsinuswavetoswitchontheTRIAC.

Thereare2majorgridfrequencies(http://www.schoolfor
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
champions.com/science/ac_world_volt_freq_list.htm)
intheworld:50HzinEuropeandmostofAsiaandAfricaand60Hzinthe
ArduinoControlledLightDimmer by
America's(andpartsoftheCaribean).Thereare2majorvoltagesintheworld:
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
110120Vand220240Vbuttheyarenotimportantforthemathematicshere
ForeaseofuseIwilltakethe50Hzfrequencyasanexample:
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
50Hzis50wavespersecond.
Collection IMadeit! Favorite Share
Eachsinuswavethustakes1000ms/50=20ms(miliseconds)
Asthereare2sinuspeaksinawavethatmeansthataftereveryzerodetection
thereisa10msperiodthatwecanregulate.
Shouldweignitethelampdirectlyatthebeginningofthatperiod,thelampwill
receivefullpower,shouldwedoitattheendofthat10msperiodthelampwill
receivenoowerandshouldwedoithalfway,thelampwillreceivehalfpower.
AsweareusingTRIACs,whatthesoftwareneedstodoistowaitforthezero
3,59$ 54,99$
pointatthesinuscurve,takenoteofthatandthenwaitaspecifiedamountof
timewithinthat10msperiodtosendapulsetotheTRIAC.
Ifitsendsthatpulseat5ms,thelampwillonlyburnathalfpower.

IntheCircuit,thezerodetectionisdonebythebiphaseoptocouplerandis
availableastheXsignalontheboard.
Therearebasically2waysforamicrocontrollertodetectthatsignal:
1acontinuous'polling'oftheZeroCrossingpin 49,99$ 40,99$
2usinganinterrupttotelltheprogramthattherewasazerocrossing
Themaindifferencebetweenthetwoisthatin'polling'everytimethecomputer
goesthroughit'smainloopitneedstocheckthepin.Ifyourprogramisbusy
doingalotofotherthings,itmightbetoolateincheckingthezerocrossingpin,
whilewhenusinganinterrupt,itdoesnotmatterwhattheprogramisbusywith.
Theinterruptissortof'tappingitontheshoulder'saying"Heylook,something
cameupthatyouneedtoattendtoNOW".
49,14$ 49,14$

Afterthezerocrossingisdetectedtheprogramneedstowaitforaspecified
amountoftimeandthenswitchontheTRIAC. Banggood.com
Alsohere,thatwaitingcanbedoneintwodifferentways
1byissuinga'wait'command
2byusingatimerinterrupt

Again,boththesemethodshavetheirpro'sandcon's.The'wait'command
('delay'inArduinolanguage)literallylet'sthecomputerwaitfortherequiredtime
anditcantdoanythingelseinthemeantime.ifthelampisburningatlowpower
bylettingthecomputerwaitsay9ms,thatmeansthatevery10msthecomputer
istoldtowait9ms:ergoitwillbeidle90%ofthetime.Thatisfineifyour
controllerisonlyusedtocontrolthelamp,butifitneedstodootherstuffthen
littletimeisleft.
Usingatimerinterruptsolvesthat.Basicallywhatthatdoesisthattheprogram
tellsthetimer:Hey,Ijustheardwehaveazerocrossing,Igottodosomething
else,butyoujustwait4.5msandthenswitchontheTriac"Sotheprogramgoes
onit'smerrywayand4.5ms(asanexample)afteritwasgivennoticetherewas
a0crossing,thetimerswitchesontheTRIAC.

Polling:(notethisisaroughexampleforillustrationofpolling,obviouslyit
needssomeenhancement)

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
intAC_LOAD=3;//Weusepin3toignitetheTRIAC
ArduinoControlledLightDimmer by
intstate;//integertostorethestatusofthezerocrossing
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

voidsetup()
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
{
pinMode(AC_LOAD,OUTPUT);//SetACLoadpinasoutput
Collection IMadeit! Favorite Share
}

voidloop()
{
state=digitalRead(AC_LOAD);
if(state=1){
delayMicroseconds(5000);//=5ms=halfpower
digitalWrite(AC_LOAD,HIGH);//triacfiring
} 3,59$ 54,99$

Interruptdriven:
Touseaninterrupt,firstweneedtosetthatup.OntheArduinothatisas
follows:
voidsetup()
{
pinMode(AC_LOAD,OUTPUT);//SetACLoadpinasoutput
attachInterrupt(0,zero_crosss_int,RISING);//Choosethezerocrossinterrup 49,99$ 40,99$
t#fromthetableabove
}

Whatthissaysisthattheinterruptisattachedtointerrupt0,itgoestoafunction
called"zero_crosss_int"anditreactstoarisingflankonthepin.

IntheZero_cross_intfunctionthattheprogramjumpstoaftertheinterruptwe 49,14$ 49,14$


determinethetimeweneedtowaitbeforefiringtheTRIAC.Wewillalsoadda
bitoffunctionality.Wedon'tjustwantonelevelsetthatthelampburnson,we Banggood.com
aregoingtoaddsomefunctionalitytoregulatethelightlevelinsteps.
ForthatIhavechosenthefullyarbitraryamountof128steps.Thatmeansthat
everystepis10ms/128=10000us/128=75us(infactitis78,butIgettothat
later).Thetotaldimtimetheniscalculatedfrom75x(1to128).Thenumber
between1128,whichdeterminesourlevelofdimming,weassigntothe
variableinteger'dimming'

voidzero_crosss_int()//functiontobefiredatthezerocrossingtodimthel
ight
{
intdimtime=(75*dimming);//For60Hz=>65
delayMicroseconds(dimtime);//Offcycle
digitalWrite(AC_LOAD,HIGH);//triacfiring
delayMicroseconds(10);//triacOnpropagationdelay(for60Hzuse8.3
3)
digitalWrite(AC_LOAD,LOW);//triacOff
}

Whathappenshereisthattheprogramfirstcalculatesthedimtime(=timeto
waitbeforethetriacisfired)
Itthenwaitsthatamountoftime,subsequentlywaitsthatamountoftimeand
firestheTriac.TheTriacwillswitchoffagainatthefollowingzerocrossing,but
wearegoingtoalreadywritealowontheTRIACpintoavoidaccidentalignition
inthenextcycle.WeneedtowaitabithowevertoknowforsuretheTRIACis
on,sowewait10us.Now(1000010)/128isstill78butifound75toworkwell.
Feelfreetouse78though.
Theonlythingthenlefttodointhemainprogramistosetthelevelatwhichwe
wantthelamptoburn:

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
voidloop(){
ArduinoControlledLightDimmer
for(inti=5;i<=128;i++){
by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
dimming=i;
delay(10);
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
}

Collection IMadeit! Favorite Share


Whathappenshereisasimpleloopthatregulatesthelampupina128steps.I
havechosennottostartat1butat5becauseatthatleveltherecouldbesome
timingissuesthatcouldcausethelamptoflicker.

Theaboveprogramisonlyanexampleofhowtocontrolthelamp,obviouslyyou
wanttoaddsomeotherfunctionalityratherthanjusthavealampgoupand
downinbrightness. 3,59$ 54,99$

Usingatimer:
Ifyouwantyourprogramtobetimeefficientyouwillneedtouseaninterruptfor
thezerocrossingdetectionandatimertodeterminetheamountoftimetowait.
Roughlyaprogramwouldlookasfollows:

Initialize
Setupthevariousconstantsandvariablesyouneedandincludethelibraries 49,99$ 40,99$
used(suchastheTimerOneLibrary)

Setup
Setpthepinsandthe2interrupts
Thezerocrosssinginterruptpointstoafunctionandsodoesthetimerinterrupt

Zerocrossfunctie
Setabooleanindicatingifazerocrosshasoccurred 49,14$ 49,14$

Banggood.com
Timerfunction
Ifweregulatethebrightnessagainin128steps,thenthetimerfunctionissetup
tobecalledwheneverthetimeofastephaspassed(e.g.75us)andthen
checksifthenumberofstepspassedisequaltothenumberofstepsset.Ifthat
isthecase,theTriacisswitchedon

Step4:ArduinoControlledLightDimmer:theSoftware

(/file/FO3YFFAH91A2LMG/)

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Asdiscussedintheprevioustheoreticalpage,thesoftwareisfairlyeasy.
ArduinoControlledLightDimmer by
Ifyouwanttodevelopyourownsoftwareallyouneedtodois:
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
Waitforthezerocrossing
Waitaspecifictimebetween0and9090microseconds(9090=10.00010)
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
switchonyrTRIAC
Collection
Waitforabout10us(thatisthetimeyouneedtomakesuretheTRIACison) IMadeit! Favorite Share
switchoffyrTRIAC(infact,youonlyremovethetriggersignaltotheTRIAC,the
TRIACwillstayontillthenextzerocrossing)

IjustbrieflysketchtheflowoftheprogramthatIused:
(makesureyoureadthe'NOTE'below)
ThezeroXingsignalgeneratesaninterrupt. 3,59$ 54,99$

At50Hzthatinterruptisevery10msor10.000uS
At60Hzthatinterruptisevery8.333msor8333uS
TheinterruptroutinethenswitchesontheTriacafteraspecifictime.Thattimeis
setinthemainprogramloop.
AstheprogramvariesthedimmingfromFulltoOffin128steps(thatisjusta
choicethatwasmade,couldbe100stepsaswell),at50Hzweneedthesteps
tobe75uSandat60Hztheyneedtobe65uS
49,99$ 40,99$

Itworksasfollows:
Theinterruptfunction"zero_crosss_int"getscalledeverytimeazerocrossingis
detected,whichis100times/second.It'sonlyfunctionistosetthetimethatthe
Triacisswitchedontothevalueofthevariable'dimming'
Inthemainloopoftheprogramtheactualvalueofthatvariableisset

/* 49,14$ 49,14$

ACVoltagedimmerwithZerocrossdetection
Banggood.com
Author:CharithFernanado<ahref="http://www.inmojo.com">http://www.inmojo.c
om
(http://www.inmojo.com)
</a>
AdaptedbyDIY_bloke
License:CreativeCommonsAttributionShareAlike3.0License.
AttachtheZerocrosspinofthemoduletoArduinoExternalInterruptpin
SelectthecorrectInterrupt#fromthebelowtable
(thePinnumbersaredigitalpins,NOTphysicalpins:
digitalpin2[INT0]=physicalpin4anddigitalpin3[INT1]=physicalpin5)
check:<ahref="http://arduino.cc/en/Reference/attachInterrupt">http://www.in
mojo.com
(http://www.inmojo.com)
</a>

Pin|Interrrupt#|ArduinoPlatform

2|0|AllButitisINT1ontheLeonardo
3|1|AllButitisINT0ontheLeonardo
18|5|ArduinoMegaOnly
19|4|ArduinoMegaOnly
20|3|ArduinoMegaOnly
21|2|ArduinoMegaOnly
Aboutthesoftware:theoreticallyintheloopyoucouldletvariable'i'startfrom
'0'.However,sincethetimingintheinterruptisabitofanapproximationusing
'0'(fullyon)couldscrewupthetimingabit.thesamegoesfor128(Fulloff)
thoughthatseemstobelesscritical.Wether'5'orperhaps'1'isthelimitforyour
setupisamatteroftrying,yourrangemaygofrome.g.2to126insteadof0
128.IfanybodyhasamoreprecisewaytosetupthetimingintheinterruptI'd
behappytohearit.
Ofcourseitisnotnecessarytoworkwithinterrupts.Itisalsopossibletokeep
pollingthezerocrossingpinforgoingto0.

Thoughthesoftwareworkswithaninterrupttodeterminethemomentofzero
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
crosssing,itisstillnotsoefficientbecausethetime(dimtime)weneedtowait
ArduinoControlledLightDimmer by
afterthezerocrossingbeforethetriacisfiredisliterallyspent'waiting'inthe
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
zerocrossinterruptfunction.
Itwouldbemoreefficienttosetatimerinterrupttofireattherightmomentsoin
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
themeantimethearduinocandosomethingelse.Suchaprogramcanbefound
Collection IMadeit! Favorite Share
instep

NOTE

Letmejustreiteratetheabovestatement:Thisprogramisademoofhow
youcancontrolthedimmer.ItisNOTandefficientprogramasitspends
mostofitstimewaiting.ItisthereforeNOTthemostsuitabletocombine
withothertasksoftheprocessor.Ifyouneedamoreefficientprogramuse
3,59$ 54,99$
atimerinsteadofdelay

Step5:ArduinoControlledLightdimmer:theSoftwareII
IfoundanotherpieceofSoftwarethatallowscontrollingthelampviatheserial
port.Ittriggersonthefallingedgeofthezerocrossingsignal,sothetimingisa 49,99$ 40,99$
bitdifferent.

Ihavenottesteditmyselfyet,butIseereasonswhyitshouldnotwork:asfar
asicanseeitdoesntreceivethenumbertypedintheserialportbutitreceives
theasciivalueofeachdigitthatistyped,soa'0'willbeseenas48

intAC_pin=3;//PintoOptoTriac
bytedim=0;//Initialbrightnesslevelfrom0to255,changeasyoulike!
49,14$ 49,14$
voidsetup(){
Serial.begin(9600);
Banggood.com
pinMode(AC_pin,OUTPUT);
attachInterrupt(0,light,FALLING);//WhenarduinoPin2isFALLINGfromHIGH
toLOW,runlightprocedure!
}

voidlight(){
if(Serial.available()){
dim=Serial.read();
if(dim<1){
//TurnTRIACcompletelyOFFifdimis0
digitalWrite(AC_pin,LOW);
}

if(dim>254){//TurnTRIACcompletelyONifdimis255
digitalWrite(AC_pin,HIGH);
}
}

if(dim>0&&dim<255){
//Dimmingpart,ifdimisnot0andnot255
delayMicroseconds(34*(255dim));
Justanote:Theabovesoftwareisnotmine.Ithinkitisbettertokeepthecheck
oftheserialportoutoftheinterrupt.Alsothe500uSdelaybeforetheTRIACis
switchedOFFismaybeabitlong.

Evenmoresoftwarehere
(http://wiki.dxarts.washington.edu/groups/general/wiki/4dd69/AC_Dimmer_Circui
t.html)

Step6:ArduinoControlledLightDimmer:theSoftwareIII

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

3,59$ 54,99$
(/file/FULU93IHJKC68FM/)

Thecodebelowusesthetimerfunctionratherthanadelayandhasbeen
confirmedtoworkontheLeonardoaswell

ACDimmerTimerDriven(https://codebender.cc/sketch:171819?referrer=Ed1960)by
Edit Clone&Edit Download
Ed1960(https://codebender.cc/user/Ed1960?referrer=Ed1960)
1 /*ACLightControl
2 (/? (https://codebender.cc/utilities/download/171819?
3 UpdatedbyRobertTwomey 49,99$ 40,99$
4 referrer=Ed1960) referrer=Ed1960)
5 ChangedzerocrossingdetectiontolookforRISINGedgerather
6 thanfalling.(originallyitwasonlychoppingthenegativehalf
7 oftheACwaveform).
8
9 Alsochangedthedim_check()toturnontheTriac,leavingiton
10 untilthezero_cross_detect()turn'sitoff.
11
12 AdaptedfromsketchbyRyanMcLaughlin
13 http://www.arduino.cc/cgibin/yabb2/YaBB.pl?num=1230333861/30
14
15 */
16 49,14$ 49,14$
17 #include<TimerOne.h>//Avaiablefromhttp://www.arduino.cc/playground/Code/Timer1
18 volatileinti=0;//Variabletouseasacountervolatileasitisinaninterrupt
19 volatilebooleanzero_cross=0;//Booleantostorea"switch"totellusifwehavecrossedzero Banggood.com
20 intAC_pin=11;//OutputtoOptoTriac
21 intdim=0;//Dimminglevel(0128)0=on,128=0ff
22 intinc=1;//countingupordown,1=up,1=down
23
24 intfreqStep=75;//Thisisthedelayperbrightnessstepinmicroseconds.
25 //For60Hzitshouldbe65
26 //Itiscalculatedbasedonthefrequencyofyourvoltagesupply(50Hzor60Hz)
27 //andthenumberofbrightnessstepsyouwant.
28 ToprogramyourArduinofromyourbrowser,installthecodebenderpluginorapp.
//
29 //Realizethatthereare2zerocrossingpercycle.Thismeans
30 Learnmore(https://codebender.cc/static/plugin).
//zerocrossinghappensat120Hzfora60Hzsupplyor100Hzfora50Hzsupply.
31
ArduinoBTw/ATmega168 RunonArduino

Step7:SoftwaretoSetLevelUsingUpandDownButtons
Belowacodetosetthelightlevelwithupanddownbuttons.Itusesatimerthat
checksforthetimenecessarytotriggertheTRIAC,ratherthanwaitinadelay
loop

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
/*
ArduinoControlledLightDimmer
ACLightControl
by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
Usesupanddownbuttonstosetlevels
makesuseofatimerinterrupttosetthelevelofdimming
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
*/
#include<TimerOne.h>//Avaiablefromhttp://www.arduino.cc/playgrou
Collection IMadeit! Favorite Share
nd/Code/Timer1

volatileinti=0;//Variabletouseasacounterofdimmingstep
s.Itisvolatilesinceitispassedbetweeninterrupts
volatilebooleanzero_cross=0;//Flagtoindicatewehavecrossedzero
intAC_pin=3;//OutputtoOptoTriac
intbuton1=4;//firstbuttonatpin4
intbuton2=5;//secondbuttonatpin5
intdim2=0;//ledcontrol 3,59$ 54,99$

intdim=128;//Dimminglevel(0128)0=on,128=0ff
intpas=8;//stepforcount;
intfreqStep=75;//Thisisthedelayperbrightnessstepinmic
roseconds.Itallowsfor128steps
//Ifusing60Hzgridfrequencysetthisto65


voidsetup(){//Beginsetup
Serial.begin(9600); 49,99$ 40,99$
pinMode(buton1,INPUT);//setbuton1pinasinput
pinMode(buton2,INPUT);//setbuton1pinasinput

Step8:MoreInterruptDrivenSoftware

ac_dimmer(https://codebender.cc/sketch:237008?referrer=Ed1960)byEd1960
Edit Clone&Edit Download 49,14$ 49,14$
(https://codebender.cc/user/Ed1960?referrer=Ed1960)
1 //ACdimmer
2 //Thehardwaretimerrunsat16MHz.Usinga (/? (https://codebender.cc/utilities/download/237008?
Banggood.com
3 //divideby256onthecountereachcountis
4 //16microseconds.1/2waveofa60HzACsignal
referrer=Ed1960) referrer=Ed1960)
5 //isabout520counts(8,333miliseconds).
6 //1/2waveofa50Hzsignalis625counts
7 /*
8 Pin|Interrrupt#|ArduinoPlatform
9
10 2|0|AllButitisINT1ontheLeonardo
11 3|1|AllButitisINT0ontheLeonardo
12 18|5|ArduinoMegaOnly
13 19|4|ArduinoMegaOnly
14 20|3|ArduinoMegaOnly
15 21|2|ArduinoMegaOnly
16 0|0|Leonardo
17 1|3|Leonardo
18 7|4|Leonardo
19 TheArduinoDuehasnostandardinterruptpinsasaniterruptcanbeattachedtoalmostyanypin.
20
21 Intheprogrampin2ischosen
22 */
23
24
25 #include<avr/io.h>
26 #include<avr/interrupt.h>
27
28 ToprogramyourArduinofromyourbrowser,installthecodebenderpluginorapp.
#defineZEROCROSS2//zerocrossdetect
29 #defineTRIAC3//triacgate
30 Learnmore(https://codebender.cc/static/plugin).
#definePULSE4//triggerpulsewidth(counts)
31
ArduinoBTw/ATmega168 RunonArduino

Step9:ArduinoControlledLightdimmer:Result&Expansion

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Justaquickcellphonerecordedvideoofit'sworkings
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
Arduino controlled ac dimmer
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

3,59$ 54,99$

3channels
ThiscircuitcanalsobeusedforanRGBmixer,albeityouneedtwoadditional
49,99$ 40,99$
TRIACcircuits.Youcouldusethiscircuit+PCB
(https://www.instructables.com/id/SmallTriacSwitch/)induploforthat,butmake
sureyouusearandomcycleoptocouplersuahastheMOC3021.Donotusea
zerocrossingOptocouplersuchastheMOC3041.
Inowmadea3channelIbble(https://www.instructables.com/id/3channel
DimmerfaderforArduinoorothermicroco/)

Thezerocrossingcircuitisofcourseonlyneededonce.
49,14$ 49,14$
Perhapsthisisstillsomethingfortradition(callitOldfashioned):xmastree
lightsthatworkdirectlyon220(or110)Volts.Hang3differentcolorlampstrings Banggood.com
inthetreeandregulatethemwiththiscircuitexpandedwithtwoTRIACcircuits

Frequency
Dependingonthegridfrequency(either50or60)differentstepvaluesneedto
besetmanually.However,itispossibletoletthesoftwaredeterminethe
frequencyinasetuproutine,e.g.bymeauringthetimebetweentwozero
crossingsorcountthenumberofzerocriossingswithinasettime.

Step10:8051ControlledLightdimmer:Software

(/file/FFOK2ZCHUQATIDA/)

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

(/file/FYH21BXHMMFC5FI/)

Obviously,onecanusethe8051microcontrollerseriesaswelltocontrolthe
dimmer.
AsIdonthavean8051developmentsystemanymore,Icannottestanycode, 3,59$ 54,99$

butshouldyouwanttodevelopthisforan8051,thefollowingexamplemaybe
ofhelp:

//
//ControllingACwitha8051
//UntestedCode
//CompileswithMicroCProfor8051
intdimming;
intx; 49,99$ 40,99$

inti;


voidex0_isr(void)ivIVT_ADDR_EX0ilevel0icsICS_AUTO{
/*===================================================*/
intdimtime=(75*dimming);
//delay_us(dimtime);
P0=0xFF;//setsentirePORT0high,canalsousee.g.P0_1=1;
delay_us(10);//propagationdelay 49,14$ 49,14$
P0=0x00;
} Banggood.com

voiddelay(intmaal){
for(x=1;x<maal;x++){
delay_us(75);//65for60Hz
}
}

/*===================================================*/
voidmain()
IcannotgaranteethiscodetoworkasIhavenowayoftestingit.Should
anybodytryitandhaveresultsIwouldbegladtohearit.
Anapplicationnotedescribingafancontrolaccordingtothesameprinciple,can
befoundhere
(http://www.8051projects.net/files/public/1294751952_20897_FT43643_a.c_fan
_speed_control.pdf).

Step11:PICControlledLightdimmer:theSoftware

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

3,59$ 54,99$

(/file/FG44MFWHUQATGYI/) 49,99$ 40,99$

IfyouwanttousethiscircuitwithaPICmicrocontroller,thesoftwareinthislink
mayhelpyougetfurther:
http://www.edaboard.com/thread265546.html
(http://www.edaboard.com/thread265546.html)
AgoodarticleonzerocrossingdetectionwithaPICcanbefoundhere:
49,14$ 49,14$
http://tahmidmc.blogspot.nl/2012/10/zerocrossing...
(http://tahmidmc.blogspot.nl/2012/10/zerocrossingdetectionwith Banggood.com
pic16f877a.html)

ThewriterSyedTahmidMahbubgivesabasicprogramthatdetectsthezero
crossingandthentriggerstheLEDwithadelayof20ms.
AlthoughIneverworkedwithPIC'sbeforeandamnocrackonCprogramming.
Idecidedtoseeificouldbuildonhisprogramandmakeitpossibletovarythe
lightintensity,ratherthanjustgiveitonevalue(the20msdelay).
Isoonfoundoutthatthedelay_msanddelay_usfunctionsinC,areabittricky,
namelythattheydontacceptavariable.Thedelaytimeneedstobeknownat
thetimeofcompilationasitishardcoded.Isawsomecomplicatedwork
arounds,butIthoughtasimplersolutionwouldbetomakeafunctionthatgives
a75uSdelay(makethat65for60Hz)andcallthatwithaparameter
determininghowoftenthatdelayislooped.
Themaximumnumberoftimesthedelayisloopedis128.ThatisbecauseI
haverandomlychosenthatthelightshouldbedimmedin128steps(with0
beingfullonand128beingoff).
Awarningthough:IhavenoPICprogrammerandIamnotplanning(yet)togo
intopics,happyasIamwiththeAtmegaandAttinyseries.ThereforeIcannot
testtheprogram.Icanonlysaythatitcompileswithoutproblems,andifyou
wanttousethecircuitonaPIC,itwillhelpyougetstarted.Youcanalsofindfull
projects,includingaprogram,here
(http://www.datelec.fr/secteur/Lamp%20dimmer%20PIC12C508%20DS40171A.
pdf)andhere,includinganIRremote(http://www.module.ro/ir.html)andhere
(http://pcbheaven.com/circuitpages/PIC_DCV_Controlled_AC_Dimmer/)
//
//Programmer:DIY_Bloke
//Stronglybasedona0XprogramfromSyedTahmidMahbub
//Compiler:mikroCPROforPICv4.60
//TargetPIC:PIC16F877A
//Programforphaseanglecontrol
//zerocrossingsignalonpin33RB0/INT
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
//gatingsignaltoMOC3021via220470Rfrompin19RD0/PSP0
//Xtal4MHz
ArduinoControlledLightDimmer by
//
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
unsignedcharFlagReg
intx
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
intmaal
intdimming=20//'20'isjustanexample.Dimmingshouldcontaina Collection IMadeit! Favorite Share
//valuebetween0and128andcanbetakenfrome.g.a
//variableresistororLDRoravaluecomingoutofaprogram
sbitZCatFlagReg.B0

voidinterrupt(){
if(INTCON.INTF){//INTFflagraised,soexternalinterruptoccured
ZC=1
3,59$ 54,99$
INTCON.INTF=0
}
}

voiddelay(intmaal){
for(x=1x<maalx++){
delay_us(75)//65for60Hz
}
49,99$ 40,99$
}

voidmain(){
PORTB=0
TRISB=0x01//RB0inputforinterrupt
PORTA=0
ADCON1=7//DisableADC
TRISA=0xFF//MakeallPORTAinputs
PORTD=0 49,14$ 49,14$
TRISD=0//PORTDalloutput
OPTION_REG.INTEDG=0//interruptonfallingedge Banggood.com
INTCON.INTF=0//clearinterruptflag
INTCON.INTE=1//enableexternalinterrupt
INTCON.GIE=1//enableglobalinterrupt
while(1){
if(ZC){//zerocrossingoccurred
delay(dimming)//'20'isanexample
PORTD.B0=1//Sendapulse
delay_us(250)
PORTD.B0=0
ZC=0
}
}
}

Step12:Problems

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

3,59$ 54,99$

49,99$ 40,99$

(/file/FTYJEK5HMLB4ESE/)

Ifforwhateverreasonthecircuityoubuiltisnotworking,otherthanitstartingto
smoke. 49,14$ 49,14$
BeforeyoudoanyworkonthecircuitUNPLUGITFROMTHEMAINS!!
Banggood.com
Therearemainly3thingsthatcanhappen:

1Thelampisflickering
Thisisprobablythemostcommonproblemyoucanencounterandtheremaybe
severalreasonsforite.g.
a'dirty'powersupply.
Ifyourpowersupplygivesoffalotofextraspikes,thesecanbepresentonthe
0XsignalpinandmessupthecleanZerocrossingsignals.Tryanother
powersupply.
'timing'problems
usinganoptocouplergivesaprecisezerocrossingsignal,butitisnotextremely
narrow.Thepulsewidthofthiscircuit(at50Hz)istypicallyaround600us
(0.6ms)whichsoundsfastenough.Theproblemisthatat50Hzeachhalfcycle
takesonly10ms(8.33msat60Hz),sothepulsewidthisover5%ofthetotal
period.Thisiswhymostdimmerscanonlyclaimarangeof10%90%thezero
crossingpulselaststoolongtoallowmorerange.Thesolutionistoavoid
regulatingallthewaydownorallthewayup.Alsoincreasingorsometimes
decreasingthestepvalue(thenumber75for50Hzand65for60Hz)maycure
that.

2Thelampisconstantlyon
Thismightbeasoftwareorahardwareproblemandtheeasiestwaytosortthat
outistomakesurethemicrocontrollerisnotconnectedtothecircuit.Ifthelamp
isstillontherearegrossly4possibilities:
Yousomehowfuckedupthecircuit,checkifitisindeedOKandthateverything
isconnectedtowhereitshoudlbeconnected.
TheMOC3021issomehowreceivingapositiveinput,makesurethereareno
straydropsofsoldershortingthingsthatshouldntbeshorted.Shorttheinput
andgroundwireandseeifthelampstaysoff.
TheMOC3021isshortcircuitedatthehighvoltageend.RemovetheMOC3021
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
fromitssocketandseewhathappens:ifyrlampstaysoffthereislikely
somethingwrongwithyrMOC3021.Ifyourlampstayson,youprobablyhavea
ArduinoControlledLightDimmer
faultyTRIAC by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
YouhaveafaultyTRIAC.Asdescribedabove.Yet,checkthegateresistorifit
reallyhasthecorrectvalue,justtomakesure
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

3Thelampisconstantlyoff Collection IMadeit! Favorite Share


Asthismayalsobeasoftwareorhardwareproblem,firstseewhathapenswith
thearduinodisconnected.
Connecttheinputtoaplus5Voltsupplyandmeasurethevoltageontheprimary
sideoftheoptocoupler(YOURCIRCUITSHOULDNOTBECONNECTEDTO
THEMAINS).Ifthatisacoupleofvolts,connectyourcircuittothemainsand
seewhathappens.Ifthelampswitchesonthereisaproblemwiththeinput
signal.Ifitstaysoff,youmayhaveafaultyoptocoupler,afaultyTRIACoryour 3,59$ 54,99$

circuitsomehowisnotconnectedtothemains.Anotherpossibilityisthatthe
voltagedropovertheLEDispreventingtheoptocouplertoopen,especially
whenyouareusingsay3.3Vasadrivingvoltage.MakesureyouhaveanLED
withalowvoltagedroporreplaceitbyawirebridge.

ApieceofcodethatcanhelpyoutesttheTriaccircuitistoaddthefollowinginto
thesetup
49,99$ 40,99$
voidsetup()
{
pinMode(AC_LOAD,OUTPUT)//SettheACLoadasoutput
for(inti=0i<10i++){
digitalWrite(AC_LOAD,HIGH)//triacfiring
delay(1000)
digitalWrite(AC_LOAD,LOW)//triacOff
delay(1000) 49,14$ 49,14$

}
} Banggood.com
ThiswillfirstfiretheTRIACafewtimessoyoucanseeitisworking

Mostcommonfaulttillnow

Fromallthepeoplethatcontactedmeaboutproblemsofthecircuitnotworking,
themostcommonfaultwas:faultywiring:achipputupsidedown,asolderjoint
notgood,awirenotconnectedright.

Step13:TheGateResistor:aBitofTheory
WhencruyisingtheinternetforTriacswitches,youmayhavecomeacrossa
largediversioninthevalueofthegateresistorvalue.Mychoiceusuallyisto
takethelowestvaluethatwillstillprotectthegateandtheoptocoupler.
ReaderMaliLagunasdidsomeresearchinthetheorybehindthecriteriato
choosethevalueofthegateresistor.Whichiwillcopybelow:

Theresistorwhenplacedinthiscircuit,willhavetwomaineffects:
a)Itwilllimit/providethecurrentgoingintothegateofthetriac(I_{GT})
b)Itwillcausethevoltagetodropwhenthetriacison(V_R)

Thelowestvaluethisresistormayhave(for220VAC)is
R=220*sqrt(2)/I_{TMS},whereI_{TMS}isthemaximumpeakcurrentallowedin
thephotocouplersphototriac.Thesearesurgevalues,thustheyaretransient
andaccountforalimitbeforebreakdown.ThereforeinyourcircuitRwouldbe
R=220*sqrt(2)/1=311.12or330ohms,sincetheMOC3021sI_{TMS}=1A.This
isconsistentwithI_{GM}whichisthepeakgatecurrentoftheTIC206.Inyour
schematicyouuse1Kwhichwouldlimitthecurrentto311mA.

Thissurgecasemaytakeplaceonlywhenapulseisreceivedbythe
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
phototriacanditisabletoconductI_{GT},andofcourseforalinevalueof
220*sqrt(2).ChargewillthenaccumulateinthetriacsgateuntilV_{GT}gets
ArduinoControlledLightDimmer
buildupandthethetriacgetsactivated. by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

InquadrantI,(V_{GT}andA1aremorepositivethanA2)inorderforsufficient
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
chargetobuildupandV_{GT}inthemaintriactobeereached,thevoltage
acrossthetriacmustequalV_R+V_{TM}+V_{GT} Collection IMadeit! Favorite Share
OfcourseV_R=I_{GT}*R.Commonly,V_{TM}+V_{GT}willbothaccountfor
approximately3V(datasheet).Atthesametime,theresistormustprovide
sufficientcurrenttotheTriacsgate,letssayaminimumof25mA(sensitivityof
theTriac),thus

V_{triac}=330ohms*25mA+1.3V+1.1V=10.65Vand
V_{triac}=1kohms*25mA+1.3V+1.1V=27.4V(thevalueinyourcircuit) 3,59$ 54,99$

Whichisthevoltageneededtoactivatethetriac.Therefore,thesmallerthe
resistorthelessvoltageisrequiredtoswitchonthemaintriac.Whatgoeson
afterwardsismainlythatthereisavoltagedropacrossA1andA2andtherefore
thephototriacvoltageandcurrentwilldropcausingturnoffstate(ofthe
phototriac).ThemaintriacwillbekeptswitchedoniftheholdingcurrentI_His
respected.WhentheloadcurrentisbelowI_H,themaintriacisswitchedoff
49,99$ 40,99$
untilapulsefromthephotodiodeisemittedagaininordertopolarizeV_{GT}
andbuildtherequiredchargeinthenextcycle.Q1andQ3arethequadrantsfor
thissetup.

Step14:Dimming:aBitofTheory
49,14$ 49,14$
Justasabackgroundtothisinstructable:Therearevarioustypesofdimmers.
Whatispresentedhereisaphasecontrolled(aka'phasecut')leadingedge Banggood.com
(aka"forwardphase")TRIACdimmer.
LeadingEdgeDimmers
Inthistypethedimmeractuallycutspartsoffthebeginningofthesinewave.
ThisisthemostwidelyusedtypeofdimmerasitisversuitableforTRIACs.
Afterall,ATriaciseasytoswitchonanditwillswitchoffbyitselfoncethereisa
zerocrossingbecausethecurrentdropsbelowthegateholdcurrent
TrailingEdgeDimmers
Alsoknownas'reversephasecontrol'dimmers.Atrailingedgedimmerisa
considerablymorecomplexcircuit.Thesimplecircuitrythatiscommonwith
leadingedgetypescannolongerbeused,becausemostTRIACscannotbe
turnedoff.Gateturnoff(GTO)TRIACsexist,butarefarmoreexpensiveand
lesscommonintherelativelysmallsizesneededforlighting.Tobeableto
implementatrailingedgedimmer,theswitchingdevicemustturnonastheAC
waveformpassesthroughzero,usingacircuitcalledazerocrossingdetector.
Afterapredeterminedtimesetbythecontrol,theswitchingdeviceisturnedoff,
andtheremainingpartofthewaveformisnotusedbytheload.
TrailingedgedimmerscommonlyuseaMOSFET,astheserequirealmostno
controlcurrentandareruggedandreliable.Theyarealsorelativelycheapand
readilyavailableatvoltageratingssuitableformainsoperation.Anotheroption
istouseanIGBT(insulatedgatebipolartransistor),whichcombinesthe
advantagesofbothMOSFETandbipolartransistor.Thesearegenerallymore
expensivethanMOSFETs.Again,thewaveformisideal,anditisobviousfrom
theactualwaveformshowninFigure9thatthereisasignificantdeviation
especiallyatfullpower.Thisiscausedbecausesomeoftheappliedvoltagewill
alwaysbelostbecausethecomplexelectronicsrequiresomevoltageto
operate.
Mosttrailingedgedimmershaveanotherusefulfunctionatleastwhenused
withincandescentlamps.Thecircuitryisdesignedtoprovidea'softstart',
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
increasingthevoltagetothelamprelativelyslowly.Withincandescentlamps,
thisalmosteliminates'thermalshock'thatbriefperiodatswitchonwherethe
ArduinoControlledLightDimmer by
lampdrawsaround10timesthenormaloperatingcurrent.Thermalshockis
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
responsibleformostearlylampfailuresitisrareindeedforanyincandescent
lamptofailwhileit'son.Failureisalmostalwaysatthemomenttheswitchis
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
turnedon.Byincludingthesoftstartfeaturelamplifeisincreased.
Collection IMadeit! Favorite Share

Step15:ZeroCrossing:aBitofTheory

3,59$ 54,99$

49,99$ 40,99$

49,14$ 49,14$

Banggood.com

(/file/FYCDGYCHWLD35XL/)

ShowAllItems

ThoughIdescribedthezerocrossingalready,Iwillspendsomemorewordson
it.
Withthe'bridgeandoptocoupler'circuitthatIusedinthisproject,theprinciple
isveryclear:AmainsACvoltagepassesthrough2resistorsof33kandis
rectifiedbythediodebridge.
ThisrectificationresultsinapulsatingDCvoltagethatkeepstheoptocoupler
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
open,keepingthezerocrossingsignalLOWtillthevoltagedropsto'zero'at
whatpointtheoptocouplerwillnotbeinconductionanymoreandthe
ArduinoControlledLightDimmer by
zerocrossingsignalispulledhigh,untillthevoltagerisesagainenoughtosend
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
theoptocouplerintoconductionagain,resultinginthezerocrossingpingoing
LOW.
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
The'quality'ofthatzerocrossingpulseisofcoursedependingonanumberof
Collection
factorsbutmainlyonthespeedoftheoptocoupler,thevalueofthecollector IMadeit! Favorite Share
resistor,butnotintheleastonthevalueofthetworesistorsinthemainsline.
Ifthatvalueistoolow,youroptocouplerwillburnout,butifitistoohigh,the
voltageatwhichtherestillisenoughcurrentgoingthroughtheoptocouplerto
keepitconductingbecomeshigherandhigher.Thatmeansthatiftheresistor
valueistoohigh,theswitchingoftheoptocouplerwillhappenhigheronthe
risinganddescendingflankofthesinwave,resultinginawidezerocrossing
3,59$ 54,99$
signal,thatstartswaybeforetheactualzerocrossinguntilwayafterthe
zerocrossing.
Ergo:Theresistorvalueshouldbeaslowaspossible.InpracticehoweverI
foundthe2x33ktobeagoodvalue,leadingtoapulsestartingabt200uS
beforetheactualzerocrossing.Thatisveryacceptable.Thecurrentthroughthe
4N25isapproximately3.33mA.Surelywecouldtakethatupanotch,butitisn't
necessary.Withthesevaluestheidleuseofthiscircuitisanestimated0.7Watts
ThesameactuallygoesforthecircuitwiththeH11AA1.Theadvantageofthe 49,99$ 40,99$

H11AA1isthatonedoesn'tneedadiodebridgeasithastwoantiparalleldiodes.
ThesamegoesfortheIL250seriesortheLTV814
Onecanreachthesameeffectwithtworegularoptocouplerssuchasthe4N25,
asthefigureshowsorwithadualoptocoupler.

Ialsoprovidedacircuitinwhichthewidthofthezerocrossingpulsecanbe
regulated.
49,14$ 49,14$
Assaidbefore,thewidthoftheZerocrossingsignaldetermineshowfarbefore
theactualzerocrossingtheinterruptisgenerated.Ideally,ifyouknowhowwide Banggood.com
yourzerocrossingsignalis,youcouldtakethatintoaccountinthesoftware.
Supposeyoursignalis600uSwideandsupposethatisaevenlydividedtiming.
Thenyouknowthatyourinterruptisgeneratedsome300uSbeforetheactual
Zerocrossing.Youcouldwaitthatperiodaftereachinterrupttogetamore
precisehandlingofthezerocrossing

Ad
OrlandooF150OH35P01KIT
Parts...
$3.59LatestFashion,FreeShipping
Banggood.com

Wehaveabenicecommentpolicy.
Pleasebepositiveandconstructive. wIMadeit! AddImages PostComment


zacarias747(/member/zacarias747)
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
hellosir...imastudentandiwanttomakethisasaproject... 3daysago Reply

ArduinoControlledLightDimmer
canyoupleasesendtheprogramandalsothePCBprintto
by
myemail?thankyousir!
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
zacarias.christian@ymail.com
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share


X diy_bloke(/member/diy_bloke)(author) . zacarias747(/member/zacarias747)
|
8 2daysago Reply
Zacarias.Salamat.ThePCByoufindhere.

https://drive.google.com/open?id=0B6c8mGbetkOUQlpy...
(https://drive.google.com/open?
id=0B6c8mGbetkOUQlpyM0swRmowZEE)

Aprogramtouseisinstep4,butthatisjustademoprogramtoget 3,59$ 54,99$

youstarted.Youwillhavetodecideyourselfwhatyouwantthehardware
todoandmakesuchaprogram.Ifyouhavemorequestiondonot
hesitatetoask.
Pagamping/Ingatka

genhitsuu(/member/genhitsuu) 8daysago Reply


49,99$ 40,99$
HelloBloke,
Excelentpost,thanksalotforshareyourknowledge.

IwanttodownloadthePCBprintfilebutthefileseemsnolongerexist.
Pls.kindlycheckthedownwloadlinkorcouldyousendittomyemail
genhitsuu@yahoo.com
Thankyouverymuch
49,14$ 49,14$

Banggood.com
X diy_bloke(/member/diy_bloke)(author) . genhitsuu(/member/genhitsuu)
|
8 8daysago Reply
Igettheimpressionmyentiredropboxisgone.Try
here

https://drive.google.com/open?id=0B6c8mGbetkOUQlpy...
(https://drive.google.com/open?
id=0B6c8mGbetkOUQlpyM0swRmowZEE)

genhitsuu(/member/genhitsuu) . diy_bloke(/member/diy_bloke) Reply

8daysago
Igotit.ThankyouBloke!

X diy_bloke(/member/diy_bloke)(author) . genhitsuu(/member/genhitsuu)
|
8 3daysago Reply
mypleasure

Rutviks(/member/Rutviks) 19daysago Reply

HeyBloke

Thankuforallthisinformationisreallyhelpfull.
BUTiwanttocontrolthefanspeed.Iusedthiscircuit&program&itsmaking
hummingsound.Soisthereanyoptiontoreducethatoranyothercircuitfor
that?
Ialreadytriedsnubbercircuitbutnouseofthat.Sopleasehelpmewiththis.

ThankYou

X diy_bloke(/member/diy_bloke)(author) . Rutviks(/member/Rutviks) Reply


|
8
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
19daysago
regulatingafanisoneofthemostfrequentquestionsIgetaskedhere.
ArduinoControlledLightDimmer
ATRIACisnotthebesttoregulateaninductiveloadbutasyouhave
by
experienceditdoeswork.
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
Anyway,hummingcanbeaproblemwithTRIACdimmers.Isitcoming
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps
fromthedimmeritselforisitcomingfromyourfan?isitsurelyan
.
electricalhumm/buzzorperhapsamechanicalone. Collection IMadeit! Favorite Share
Youcouldconsiderachokefilter...thoughthesesometimesgiveabitof
mechanicalhum.
DoyouhaveitonabreadboardoronaPCB?

Rutviks(/member/Rutviks) . diy_bloke(/member/diy_bloke) 18daysago Reply

Asiamstilltestingsoitisonbreadboard.Thehummingsoundiscoming 3,59$ 54,99$

fromfan(it'satablefan).Thecircuitisworkingquitebetterascompared
tojustPWMbutsomewhathummingisstilltherefromfan.
Alsothe30k1/2Wresistorsareheatingwhenfanisturnedon.Soshouldi
usehigherwattageresistorsoranyotheroption.

X diy_bloke(/member/diy_bloke)(author) . Rutviks(/member/Rutviks) Reply


49,99$ 40,99$
|
8 18daysago
Thereareseveralquestions(andanswers)onthe30k
resistorsgettingwarm.
Itisoddthoughthattheygetwarmwhenthefanisonastheironlytaskis
tosupplythezerocrosspulse,sopleasecheckyourwiringforanyfaults.
The1/2WattshouldbeOK,itishardtosayhowwarmorhot'heating'is
butifyourwiringisokandyoufindthemtoohot,yesahigherwattage
shouldbeOK
49,14$ 49,14$

Rutviks(/member/Rutviks) . diy_bloke(/member/diy_bloke) 15daysago Reply


Banggood.com

Hellobloke

Thankyouforthehelp.Yourreplyisveryhelpfull.
Justonemorequestion,Imjusttryingtouseremotetocontrolthefan,i
usedtheIRremotelibrary.Thefancontrol&IRcommunicationisworking
wellseperately.ButwhenimergedtheprogramIRsensortookgarbage
values.ItslooklikearduinogottoomuchbusywithZerocrossing
detectionloop.

X diy_bloke(/member/diy_bloke)(author) . Rutviks(/member/Rutviks) Reply


|
8 15daysago
ThefirstprogramintheinstructableisasIindicatedinthe
tekst,aquickdemototestthecircuit.Andindeedmostofitstimeisspent
waitingandthereforeitisnotthemostsuitableprogramtodootherthings
with.Whatyouneedisaprogramthatdoesntwait,butchecksatimerto
knowwhentoswiththeTRIACon.SuchaTimerdrivenprogramyouwill
findabitfurtherinmyinstructable.
IamnotsurewhichinterruptyouusefortheIRreceiver,butmakesureit
isnotonethatisusedbytheTimeryouareboundtouseorbythe
zerocrossroutine

Rutviks(/member/Rutviks) . diy_bloke(/member/diy_bloke) 14daysago Reply

Thankyoublokeiwillworkonit.Thanksagainforallyourhelp.

X diy_bloke(/member/diy_bloke)(author) . Rutviks(/member/Rutviks) Reply


|
8 14daysago
Mypleasure.Goodluck

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Rutviks(/member/Rutviks) . Rutviks(/member/Rutviks) 15daysago Reply
ArduinoControlledLightDimmer by
Iusedthefixeddimmingvaluesfor0,1,2,3buttonsofremoteinprogram.
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
Forexamplefor3iuseddimming=15whichisthehighestspeedoffan.
Download h(/id/ArduinocontrolledlightdimmerThecircuit/)
For2its80.Igotthatvaluesfromtrial&error. 15Steps .

Collection IMadeit! Favorite Share

X diy_bloke(/member/diy_bloke)(author) . Rutviks(/member/Rutviks) Reply


|
8 18daysago
Thehummingcomingfromyourfanisabitofahardnutto
crack,itcomesabitwiththeuseofaTRIAC.Sometimesachokefilter
canhelp

3,59$ 54,99$

X diy_bloke(/member/diy_bloke)(author) amonthago Reply


|
8 TheonlyreasonIcanthinkoffwhythemocdiedisiftheTRIACburnedanda
full220Vcameoverthemoc.thatiswhyiaskedtotestthecircuitwithoutthe
moc.

peter_bjorge(/member/peter_bjorge) . diy_bloke(/member/diy_bloke) Reply 49,99$ 40,99$


amonthago
HelloBloke,

Youwereright.Ichangedthetriacandnowitisworking.Doyouknow
whatarethereasonstoburnatriacandsomepreventiveactions?Iwould
liketoavoidtoburnitagaininthefuture.Thanksinadvance!

Peter
49,14$ 49,14$

Banggood.com
X diy_bloke(/member/diy_bloke)(author) . peter_bjorge(/member/peter_bjorge)
|
8 amonthago Reply
Iamgladyougotitworkingagain.
Iam99.9%sureitdiedbecauseofyourlaptop.Iamnotentirelysure
whatlaptopyouhavebutmosthaveaswitchedPSUandthatisreallynot
agoodloadforaTRIAC,soIguessitwasaspikeorsomething.
Iguessthebestwaytoavoiditisnottopluginyrlaptopanymore:)
Nowofcoursethatcouldhavebeenacoincidenceandtherewasanother
reason,butthatwouldbefarfetched

peter_bjorge(/member/peter_bjorge) . diy_bloke(/member/diy_bloke) Reply

amonthago
HiBloke,

Thanksforthecomment.Mytriacshouldsupportatleast600vrmsand4
amps.Soitshouldbeabletosupportthepossiblepeakinthelaptop,
doesn'tit?

Ormaybetryingtodimalaptopcausesahigherpeakincurrentand/or
voltage?

Thanksinadvanceforyourtime,
Peter

X diy_bloke(/member/diy_bloke)(author) . peter_bjorge(/member/peter_bjorge)
|
8 amonthago Reply
Ipresumeitisavoltagepeak.Mostswitchingpsu's
startwithaninductioninbothlinesandjustasarelayinthecollectorline
ofatransistorcankillthattransistor,inthiscasethatmighthave
happenedtotheTRIAC.ThoughIwouldexpectalaptoppsuhaveaMOV

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
orsomethingasovervoltageprotection,maybethatwasntfastenoughfor
ArduinoControlledLightDimmer
thespikes.Mindyouthatwithaninductionthecurrentandvoltageareout
by
ofphaseandthatissomethingTRIACsdonthandleverywell
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

peter_bjorge(/member/peter_bjorge) . Collection
diy_bloke(/member/diy_bloke) IMadeit!
Reply Favorite Share
amonthago
HiBloke,

Iunderstandyourpoint.Isitanypreventivecircuittoadd?Imeanlike
snubbingorsomething?

Peter
3,59$ 54,99$

peter_bjorge(/member/peter_bjorge) . diy_bloke(/member/diy_bloke) Reply

amonthago
IwilltryassoonasIarriveathomeonTuesday.Bytheway,I
changedbothcomponentsduetoavailabilityandusingLiteon'smoc3023
andSTM'sZ0405MF0AA2.Lookingatthespecs,bothshouldbealsoOK,
whatdoyouthink?
49,99$ 40,99$

peter_bjorge(/member/peter_bjorge) . peter_bjorge(/member/peter_bjorge)
amonthago Reply
JusttobesureIwasclearenoughbefore,iamusing
bothcomponentssincethebeginningandnotyours.ButIthinkit
shouldn'tbetheissuesincethewholecircuitwasworkingoveramonth

49,14$ 49,14$
X diy_bloke(/member/diy_bloke)(author) . peter_bjorge(/member/peter_bjorge)
|
8 amonthago Reply Banggood.com
yeswasclear:)

amonthago Reply
tkele(/member/tkele)madeit!

Ibuildaprototypecircuitonperfboardtocheckhowthecircuitperforms.4N25,
MOC3021&BTE137used.Loadis230V70Whalogenlampwitha6Acircuit
breakerforbasicsafety.Arduinoprominiandcircuitsrunsflawlesslyon3.3Vor
5V.

Arduino Controlled AC Dimmer

I'mgoingtoetchaPCBassoonaspossible.


(https://cdn.instructables.com/FVF/5XP4/IZ6C6FOR/FVF5XP4IZ6C6FOR.LARGE.jpg)
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

(https://cdn.instructables.com/FKO/W5JC/IZ6C6FPU/FKOW5JCIZ6C6FPU.LARGE.jpg)

X diy_bloke(/member/diy_bloke)(author) . tkele(/member/tkele) Reply


|
8 amonthago
looksgreat.Thanksforsharing
3,59$ 54,99$

peter_bjorge(/member/peter_bjorge) amonthago Reply

Goodevening,

Firstofall,congratsforthegreatInstructable.Itwasrunningfordaysperfectly
butsuddenlyledisnowalwaysON.TheonlythingImadedifferentwasto
connectanondimmableload(aoldlaptop)intheoutputwhichconsumpts 49,99$ 40,99$
about300mAtoseewhat'sgoingon.Now,Icheckedthecircuitandinthemoc
inputIhave0butintheoutput(triacgate),Ihavea1,soit'sclearMOCisnow
damaged.Doyouthinkitwascasualtyortryingtodimanondimmableload
candamagetheMOC?

Thanksinadvance,
Peter

49,14$ 49,14$

X diy_bloke(/member/diy_bloke)(author) . peter_bjorge(/member/peter_bjorge) Banggood.com


|
8 amonthago Reply
Peter,Itisabittoomuchofacoincidence,nottebe
relatedtoplugginginyrlaptop.

Ijusthopeitwasjustyourmocthatgotkilled.Canisuggesttoremove
themoc,attachalamp,thenplugthedeviceintothemainsagainandsee
ifthelamplightsornot?
justtocheckifyrTRIACisok

peter_bjorge(/member/peter_bjorge) . diy_bloke(/member/diy_bloke) Reply

amonthago
Ok,Iwilldothat.Ifitwasacoincidence,isthereanypossibility
toreducechancestokilltheMOC?Imean,apreventivecircuitor
somethingsimilar?Ididn'tuseitsomuchtokillit.

mathisPhys(/member/mathisPhys) amonthago Reply

iamnot100%confident,wherecouldibuyone?ireallyneadit

X diy_bloke(/member/diy_bloke)(author) . mathisPhys(/member/mathisPhys)
|
8 amonthago Reply
checjinmojo.com
http://www.inmojo.com/search/?type=products&s=dimm...
(http://www.inmojo.com/search/?type=products&s=dimmer)

TJMehta(/member/TJMehta) 2monthsago Reply

Hello,FirstofallIamverythankfultoyou...


ExcellentDocumentandeachconceptisexplainedverywell...
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Istillwanttomakethiscompactinsize.SoinsteadofusingArduino,canIuse
ArduinoControlledLightDimmer
directlyatTiny85Controller?WillyoujustprovidetheAVRcodeforthesame
by
whichisnormallydoneinAVRStudio..
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Hopeforpositiveresponse....
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

X diy_bloke(/member/diy_bloke)(author) . TJMehta(/member/TJMehta) Reply


|
8 2monthsago
Astheattiny85hasanexternalinterrupt,anoutputpinanda
correcttimer,Iseenoreasonwhythatshouldnotbepossible,or,inother
words,yesithinkyoucanuseanattiny85

3,59$ 54,99$

TJMehta(/member/TJMehta) . diy_bloke(/member/diy_bloke) Reply

2monthsago
Thanksalot....

Ahmedabdelwahab(/member/Ahmedabdelwahab) 2monthsago Reply

Hi
CanweconvertACcurrenttoDCcurrentandusefadingsketchlikeled 49,99$ 40,99$

Andremovezerocrossingpart??
Thanksforyoureffort

X diy_bloke(/member/diy_bloke)(author) . Ahmedabdelwahab
|
8 (/member/Ahmedabdelwahab) 2monthsago Reply

somethinglikethis? 49,14$ 49,14$

https://www.instructables.com/id/ACPWMDimmerfor...
(https://www.instructables.com/id/ACPWMDimmerforArduino/) Banggood.com

2monthsago Reply
TomaszK8(/member/TomaszK8)madeit!

Thanksalot!
WithyourtutorialIwasabletodothisdragonballlamp:)

Dragon Ball Son Goku handmade ickering lamp with sou...

(https://cdn.instructables.com/F1B/6GQT/IYLZSU2Z/F1B6GQTIYLZSU2Z.LARGE.jpg)

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)

Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .

Collection IMadeit! Favorite Share

(https://cdn.instructables.com/F14/CRBL/IYLZSV2L/F14CRBLIYLZSV2L.LARGE.jpg)

3,59$ 54,99$

(https://cdn.instructables.com/FSJ/WLIG/IYLZSVPO/FSJWLIGIYLZSVPO.LARGE.jpg)

49,99$ 40,99$

(https://cdn.instructables.com/FY7/MQGA/IYLZSW35/FY7MQGAIYLZSW35.LARGE.jpg)

49,14$ 49,14$

(https://cdn.instructables.com/FXZ/3QFP/IYLZSW7Q/FXZ3QFPIYLZSW7Q.LARGE.jpg) Banggood.com

(https://cdn.instructables.com/F1U/KAI5/IYLZSW9C/F1UKAI5IYLZSW9C.LARGE.jpg)

X diy_bloke(/member/diy_bloke)(author) . TomaszK8(/member/TomaszK8)
|
8 2monthsago Reply
Iamhappyithelpedyou.Thanksforsharingyour
picsandvideo

X SugarDevice(/member/SugarDevice) 2monthsago Reply


8
ThisisbetterandmoresafewaytocontrolAClightdimmer
https://www.instructables.com/id/ControlACDimmer...
(https://www.instructables.com/id/ControlACDimmerLampUsingArduino/)

gsmhack(/member/gsmhack) . SugarDevice(/member/SugarDevice) Reply

2monthsago
Thisinstructibleisbyfarthemostcomprehensivepieceof
workIhaveeverread!ANDitdoesnotusethisplatformasafree
advertisingopportunity...

X diy_bloke(/member/diy_bloke)(author) . gsmhack(/member/gsmhack) Reply


|
2monthsago
8 Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Thankyougsmhack:)Iappreciateit.
ArduinoControlledLightDimmer by
diy_bloke(/member/diy_bloke)(author) . SugarDevice(/member/SugarDevice)
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
X
|
8 2monthsago Reply
Download
Well,"better"isupfordebateand'safer'isofcourse
h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps .
nonsense,butidounderstandyouaretryingtopromoteaproductthatis
Collection
soldbyyoufor49USD,whereasminewillbeafewdollars. IMadeit! Favorite Share
Seemsyouhaveamonthlefttogeneratetheremaining99%ofyour
target.Iwishyouawellmeantsuccess

X SugarDevice(/member/SugarDevice) . diy_bloke(/member/diy_bloke) Reply


8
2monthsago
asamakeritriedmanywaytocontrolACvoltagedevices
3,59$ 54,99$
andididthesamecircuitbefore,firstbetterwhenyouwanttointegrateit
withmoreadvanceapplicationandaddmoresensorsormotorsorcontrol
itfromwifiorBTorevenfromcomputerusingserialcommunication,with
yourwayit'sonlygoodforthisapplicationandwithinterruptroutine
occupiedbyzerocrossandtriacdrivertriggeractionyoucan'tbuilda
manyfunctionsproject.
alliwanttodoistoletthepeopleseethattherearedifferentwaytodo
thisandalsocontrolitwithdifferentplatform"notjustarduino"andit'snot
forthecampaign,evenifthecampaignfailwewillcontinuesupportand 49,99$ 40,99$
launchthisproductagainbecausewebelieveitwillbeusefulormany
people.

thankyousomuchandIapologizeforanyinconveniencecausedby
thesetwocomments

AndrsV55(/member/AndrsV55) 3monthsago Reply


49,14$ 49,14$
Hello,excelentPost,maybeyoucansolveonedoubtthatIhave.Toturnon
thelampforexample(inthecommonway),youhavetoconnectonesideofthe Banggood.com
lamptothepowersupply(Neutral)either(220Vor110V)andtheothersidethe
lamptothephase,butthewireconnectedtothePhaseyouhavetocutirand
connecttoaswitch.Everythingokuntilhere.

Myquestionis:Ijustboughtacommercialdimmer(Lutron)andiseasyto
connectyouonlydisconnectandremovethenormalswitchandconnectthe
dimmer.butinsidethewallyouhaveonlyonewirecutandthiswireisthe
Phase,howthecommercialdimmerworksonlywithonewire(Phase)ifinthis
posttodimerizethelampweusedthePhaseandtheneutralconnectedinone
terminalblock,andontheotherteminalblockthelamp.
Ispossibletousethecircuitboardofthispostinthewayofacommercial
dimmer,onlywiththephase?
Ireallyappreciateyouranswers.

X diy_bloke(/member/diy_bloke)(author) . AndrsV55(/member/AndrsV55)
|
8 3monthsago Reply
Iapologizethatioverlookedyourquestionforafew
days.
Wellthedimmeryoudescribeworksinserieswiththelamp,butinreality
ofcourseitisstillusingtwowires...thatyougetbycuttingtheonewirethat
goestothelamp,justasaswitchneedstwowires,butyes,itisstillone
phase.Sothatdimmerisatypicalseriescircuit:theneutralwiregoesto
thelamp,areturnwiregoesfromlamptilldimmerandthenthephase
goesfromdimmertothegridagain,soyes,byinterruptingtheonewireto
alampandputtingthedimmerinbetween,itdimsinserieswiththelamp.
Thedimmerhereworksexactlythesame:itisinserieswiththelampand
thustheTRIAjustinterruptsonewire.Salsoherewehaveawirefrom
thegridgoingtothelampandareturnwiregoingtothetriacandfromthe
triacbacktothegrid.
Sofarsogood.BUT!!!!thedimmerneedstomeasurethezerocrossingof
Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
thegridandforthtitneedsbothphases
So,toansweryourquestion......no,youneedtwophases.
ArduinoControlledLightDimmer by
Ipresumeyouwantthissoyoucanreplaceaswitchwiththisdimmer?but
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
eventhenyouwouldstillneedtohave3wirescomingfromthatswitchto
Download h(/id/ArduinocontrolledlightdimmerThecircuit/) 15Steps
yourmicroprocessor:thezerocrosssignal,thetriggersignalanda.
ground. Collection IMadeit! Favorite Share
Ithinkthatinmostcountriesitisagainstcodetoputacircuitthathasalow
voltagesideinsidearegularwallsocketandorhavewirescomingoutof
itsothiscircuitismoresuitableasaseparatedimmedsocket

AndrsV55(/member/AndrsV55) . diy_bloke(/member/diy_bloke) Reply 3,59$ 54,99$

3monthsago
Thanksforyourreallygoodexplanation,infactIwasthinking
inreplacemycommonswitchwiththisdimmerbecauseworkgreat.
Maybecanhelpmewithotherquestioninthesketchofstep7(Software
tosetlevelusingupandownbuttons)Icanseeavariablecalleddim2
andinthecomment(ledcontrol)isnecessarytochangesomecodeto
dimtoLEDbulb?,becausewiththecodeshowedabovetheLEDbulb
hastwostatesON/OFFanddoesn'tdims.
49,99$ 40,99$
Thanksagain.

X diy_bloke(/member/diy_bloke)(author) . AndrsV55(/member/AndrsV55)
|
8 3monthsago Reply
WhenIwrotetheinstructable,Ithoughtitwasagood
ideatogathersomeexamplecodesfrominternetthatithoughtwould
benefitpeople.Iwasinthepresumptionthatthesecodesweretriedand 49,14$ 49,14$
tested,butapparentlytheyhavenotbeen.Soifthatparticularcodedoes
notworkitisprobablybesttotakemydemocodeasabasisandjustad Banggood.com
orsubtractfromthedimvaluewhentheuoordownbuttonispressed

AndrsV55(/member/AndrsV55) 3monthsago Reply

Excelentpost,thanksalotforshareyourknowledgewithUs.Peoplelikeyou
helpmakeknowledgeavailableforall.

iqbaaal(/member/iqbaaal) 3monthsago Reply

heythanksforsharing.itrytopwmtheaclampwithoptotriaccircuit.inmy
countrythevoltageis220v50Hz.whenipwmthelamp,thelampisblinking.
thehigherpwmigavethefasterlampblink.whenthepwmis255thelampis
fullyon.isthathowitworks?orihavetousespesificcodenotonlyjust
analogWrite?thankyou

I MoreComments

FEATURED CHANNELS

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)
Newsletter AboutUs
ArduinoControlledLightDimmer
Woodworking Join2million+toreceiveinstant
Paper KitchenHacks
by
Puzzles LaserCutting
WhoWeAre(/about/) Space Homesteading 3DPrinting Sewing
diy_bloke(/member/diy_bloke/)inmicrocontrollers(/tag/typeid/categorytechnology/channelmicrocontrollers/)
(/tag/type DIYinspirationinyourinbox.
(/tag/type (/tag/type (/tag/type (/tag/type
Advertise(/advertise/) (/tag/type (/tag/type (/tag/type (/tag/type
id/category id/category id/keyword id/category id/category
Contact(/about/contact.jsp)id/keyword id/category id/category id/category
Download enteremail
h(/id/ArduinocontrolledlightdimmerThecircuit/)
I'min! 15Steps .
workshop/channelcraft/channel kitchen%20hacks/? play/channel workshop/channel astronomy/? home/channel technology/channel
craft/channel
Jobs(/community/PositionsavailableatInstructables/)
woodworking/) paper/) sort=FAVORITES) puzzles/) lasercutting/) sort=FAVORITES)
Collection homesteading/)
IMadeit! 3DPrinting/)
Favorite Sharesewing/)
Help(/id/howtowriteagreatinstructable/)
FindUs Resources
Facebook(http://www.facebook.com/instructables) ForTeachers(/teachers/)
Youtube(http://www.youtube.com/user/instructablestv) ArtistsinResidence(/air)

Twitter(http://www.twitter.com/instructables) GiftPremiumAccount(/account/give?sourcea=footer)
Forums(/community/)
Pinterest(http://www.pinterest.com/instructables)
Answers(/tag/typequestion/?sort=RECENT)
Google+(https://plus.google.com/+instructables) 3,59$ 54,99$
Sitemap(/sitemap/)

TermsofService(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21959721) |
PrivacyStatement(http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=21292079) |
LegalNotices&Trademarks(http://usa.autodesk.com/legalnoticestrademarks/) | MobileSite(https://www.instructables.com)
(http://usa.autodesk.com/adsk/servlet/pc/index?id=20781545&siteID=123112)
2016Autodesk,Inc.

49,99$ 40,99$

49,14$ 49,14$

Banggood.com

Checkoutournewclasses!>>(/classes/?utm_medium=cta&utm_source=banner)

S-ar putea să vă placă și