Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

BeginningEmbeddedElectronics1
byNate|June19,2008|101comments

SkillLevel:Beginner

Lecture1BackgroundandPowerSupply
Thisisaseriesoflectureswrittenforthosewithmildelectronicsbackground(akaSophomorein
ElectricalandComputerEngineering)tolearnaboutthewildworldofEmbeddedElectronics.Iassume
onlythatyouknowwhatelectricityisandthatyou'vetouchedanelectricalcomponent.Everythingelseis
spelledoutasmuchaspossible.Thereisquitealotheresotakeyourtime!Itisalsomyintentiontoget
bookhardenedEE'sstudentstoputdownthecalculatorandtopluginanLED.Remember,ifitsmokes,
atleastyoulearnedwhatnottodonexttime!
Youcangetallthepartsforthislecturehere.
Sorryfortheconfusion.Whenthesetutorialswerewrittenandphotographed,weusedtheATmega8.
WenowcarrythenewerATmega328.YouwillfindallATmega328informationinthefollowingpages,but
thepictureswillshowanATmega8.
What'saMicrocontroller?
YoumayknowwhatanORgateis.AnORgateisalogicgatethattakestwoinputsandcontrolsan
output.Youmayhaveplayedwiththesetypesofgates,evenpossiblyaDIPpackagedORgatewith4
ORgatesbuiltintoit.ThisDIPpackagerequiredapowerpinandagroundpin.Electricityflowedthrough
theICandallowedittooperate.YoumaynotbesurehowtheICwasbuilt,butyouunderstandthatif
youchangetheinputs,theoutputchanges.Youcandothisbytyingtheinputstoeitherpower(also
knownasVCC)orground(GND).YouprobablyplayedwithoneoftheDIPICsinabreadboard.Ifany
ofthisiscompletelyalientoyou,don'tfret!We'lltrytoeaseyouintoit.
AmicrocontrolleristhesameasanORgate.Youhavesomeinputs,youhaveoutputs.Thecrazything
isthatamicrorunscode.Machinecodetobespecific.Forinstance,withalittlebitofwork,youcan
monitortheinputoftwopinsAandB.Andbasedonthoseinputs,youcancontrolanoutputpinC.Soto
replicateanORgate:
if(A==1||B==1)
{
C=1
}
else
{
C=0
https://www.sparkfun.com/tutorials/57

1/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

It'sCcode!Youcancodeupallsortsofdifferentapplications,compilecode,loaditontoamicro,power
themicro,andthecoderuns.Verysimple!Microcontrollersareusedinalltheelectronicsyoutakefor
grantedsuchasyourmicrowave,TVremote,cellphone,mouse,printer,there'sover150
microcontrollersembeddedintonewcars!There'sonewaitingforyoutodepressthebrakes(BRAKES
==1)andforthetirestolockup(LOCK_UP==1).Whenthishappens,themicroreleasesthebrakes,
andyouhaveABS(antilockbrakesystem).
Intheolddays,microcontrollerswereOTPoronetimeprogrammablemeaningyoucouldonlyprogram
themicroonce,testthecode,andifyourcodedidn'twork,youthrewitoutandtriedagain.Nowmicros
are'flash'basedmeaningtheyhaveflashmemorybuiltinsidethatallowstheircodetobewrittenand
rewrittenthousandsoftimes.I'vebeenprogrammingmicrosforyearsandalwaysburnoutthe
microcontrollerfarbeforeIhitthelimitofflashprogrammingcycles.
FlashmicrosaredifferentthancomputersandRAM.Computersrequiretonsofpowerandcomponents
togetupandrunning.ComputersrunHOT.Computerstakeforeverandadaytoboot.Microsareon
andrunningcodewithinmillisecondsandifthey'rewarmenoughyoucanfeelheatcomingoffofthem,
somethingisverywrongandyou'veprobablyblownthemicro.Ohandmicroscostabout$2.
NowbacktothatORgateIC.Ithadabunchofpins,alldedicatedtobeingeitherinputsoroutputsofthe
variousbuiltinORgates(4gatesinonepackage=8inputs,4outputs,2power/gndpins).14pinsof
fun.Nowwithamicro,themostbasicpinfunctionisGPIOgeneralpurposeinput/output.TheseGPIO
pinscanbeconfiguredasaninputoranoutput.Verycool.Eachinputpincanbemonitoredandacted
upon.Example:
if(PORTC.2==1)
thendosomething

Eachoutputpincanbepushedhighorlow.Example:
while(1)
{

RB3=1
delay_ms(1000)
RB3=0
delay_ms(1000)

https://www.sparkfun.com/tutorials/57

2/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Guesswhatthatcodedoes?Ittogglesapinhigh/lowevery2seconds.Fancyright?Thisisthe'Hello
World'ofthemicrocontrollerworld.Itseemstrivial,butbygodwhenyou'vebeentryingtogetamicroup
andrunningafter5hoursoftearingyourhairoutandyouseethatLEDblinkingforthefirsttime,it'sjust
glorious!
WhattypesofmicrocontrollersarethereandhowdoIgetoneblinking?
Here'saveryshallowbreakdownofthemicrosinmyworld:
PICThisistheclassicmicrofromMicrochip.Verysimple,veryproven,butitlacksmanyofthe
featuresthatothermfg'sarebuildingintotheirchips.Thisisabigdealforme.Iwasadiehard
PICpersonforyearsandI'vestartedtoseethelimitsofPICsandthebenefitsofothermicros!
AVRThisisbasicallyadirectcompetitorofPICs.TheydoeverythingaPICdoes,butinmynew
opinion,better,faster,cheaper,andsimpler.
MSPTheseareverygoodmicrosbyTexasInstruments(TI),notasbeefyasAVRorPICs.
Howevertheytrulyexcelatlowpowerapplications.Moreonthislater,butimaginerunninga
completesystemononeAAbatteryfor5years.Thisisintherealmofnanoampcurrent
consumption.Crazy!
ARMWhyareallthesethreeletters?Idon'tknowactuallyARMsarethenewkidsontheblock
andtheyarehuge.Verypowerful,verylowcost,theyaretakingovertheworldbutcanbereally
intimidatingifyou'veneverplayedwithamicrobefore.
8051The'8051core'wasthedefactostandardin8bit(and4bit!)microcontrollers.Developed
byIntelinthe1980s,itstillseemstobetheinstructionsettheylovetoteachyouincollege.They
arebasedonarchaic,butfieldproveninstructionsets.Veryoldtechinmyhumbleopinion,but
theseICshavebeensignificantlyimprovedovertheyears(nowFlashbased,ADC,SPI,etc.).
68HC08/11AnotherverycommoninstructionsetdevelopedbyMotorola.Extremelypopular,and
amicrocommonlytaughtatuniversity,it'sthemicrocontrollerIlovetohate.Theseoriginalmicros
oftenlackonboardRAMandflashbasedmemory.
Googleanyoftheseformoreinfo.IhavechosentheATmega168asthelearningICofchoice.Why?
20MIPs(millioninstructionspersecond!)ispowerfulenoughtodosomereallycoolprojects
It'scheap!$2.13currently
It'sgotallthegoodiesunderthehood(UART,SPI,I2C,ADC,internalosc,PWM,kitchensink,etc)
16Kofprogrammemoryisenoughforalmostanybeginnerproject
Thetoolsarefree!(Ccompilersformanyoftheothermicroscostalotofmoney)
Theprogramminganddebuggingtoolsarelowcost($20willgetyoustarted)
Withalittleworkandprobably$40worthofparts,youtoocangetanLEDblinking.Aswithanynew
hobby(alsoknownasadrugaddiction),theextracostof'goodies'cangrowveryquickly.
Youwanttoplaymicrocontrollerstoday?
WithanyIC,youneedtopowerthething.Therearetwopowerconnectionsonbasicmicros:VCCand
GND.WhattheheckisVCC?Thisisthelabelforthepositivevoltage.Don'tworry,afterafewdaysof
this,seeing'VCC'willbecomeverynormal.GNDisshortforground.Allelectricalcurrentneedsawayto
flowbacktoground.Thiscanbecalled'common'butisoftenjustlabeledGND.
https://www.sparkfun.com/tutorials/57

3/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Therearethousandsofdifferentmicrosoutthere,but5V(fivevolts)isthetypicalVCC.3.3Visalso
typicalbutyou'llalsosee2.8Vand1.8VVCCsonmoreexoticmicros.Fornow,justworryabout5Vand
GND.
WheredoIfindthis5V?
Youcangetallthepartsforthislecturehere.
Youneedtohookup5VandGNDtoyourmicro.Yourhouseoutletrunsat110VAC(or220Vformany
countries).AC=alternatingcurrentandisverybadfor5VDC(directcurrent)micros.Soyou'llneedto
convertthe110VACfromyouroutlettoauseable5VDC.
Quicknote:Ifyoureversetheconnectiononyourmicrobadthingshappen.Alwaysmakesureyour
5VpowersupplyisconnectedtotheVCCpinsandGNDtoGND.Ifyoureversethisandconnect5Vto
GNDonthemicroandGNDtoVCConthemicro,thingswon'texplode,probablynosmoke,thingswill
probablyheatuplikecrazy,andyou'llprobablydamageyour$2micro.Youprobablywill.Idid.Many
times.Trynottodoit.
Ok!Youneed5V.Timetobuildasimplevoltageregulatorcircuit!
Youcanbuysomethingcalleda'wallwart'.Don'taskmewhytheycallitthat,askgoogle.Awallwart
takesahighervoltageandconvertsittoalowervoltage.DONOTassumeawallwartlabeled'5V'will
output5V.ThisisamajormisconceptionIknow,Iknow,faultyadvertising.Justhookupyour
multimetertothebarrelplugandseewhatvoltageyouread.Probablymorelike8or9V.Thiswillkill
yourmicrosokeepreading!ForamoredetailedexplanationcheckouttheUnregulatedPowerSupply
Tutorial.
Let'sassumeyouareusingawallwartwithanoutputofsomethingnicelike9V.Dandy.Unfortunately
this9Voutputisrathernoisymeaningthereisalotofripple.Okwhatdoesripplemean?Youwanta
DCvoltagemeaningyouwantasolidvoltage(theoppositeofalternating).Awallwartusessomecheap
trickstoget110VACdownto9VDC.SotheDCsignalcomingoutofthewallwarttendstoalternate
100500mV.Insteadofasolid9VDC,youseeasignalthatrisesandfallsbetween8.5and9.5volts.This
'ripple'cancausehavocwithyoursystem,and9Vistoohigh(weneed5V!)soweneedtopass110V
throughthiswallwart,andsendthe9Vthrougharegulatortogetdowntoaclean5VDCsignal.Ifthisall
soundsscarydon'tworry.Afteryougetyour5Vpowersystembuilt,you'llwonderwhyyouwerescared
inthefirstplace(it'ssimple,Iswear).
ThemostcommonregulatoriscalledtheLM7805.Why?Idunno.I'veneveractuallytoucheda
componentwithLM7805stampedontheoutside.There'salwaysotherlettersstampedontheoutside
like'LM7805'or'LV78X05'orsomesuchcrazyiness.Justknowthattherearemanymany
manufacturersoutthereandtheyareallproducingthesamebasicpart,withsmalltweakstoeachone.
Whatyouneedisoneofthesegenericpartsthatisdesignatedasa'5Vlinearregulator'.Ifyou'replaying
inabreadboard,you'llalsowantitintheTO92orTO220package.Moreaboutpackagesinalater
lecture,justgowithitforthemoment.
You'vegotyourregulatorinhand,you'vegotthewallwart.Timetoconnectthemup.

https://www.sparkfun.com/tutorials/57

4/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Hereyoucanseethe'pinout'oftheLM7805.Say'IGO'inyourheadandcommitthistomemory(input,
ground,output).You'llprobablyhookupalotofthese.Whenindoubt,alwayscheckthedatasheet
beforehookingupanewpartorelsebeclosetotheon/offswitch!Inputistheinputvoltageofanything
greaterthanabout7V.GNDisground.Outputisthe5Voutputpin.Yourwallwartshouldhavetwowires.
Oneis9V,theotherisGND.Allgroundsneedtobeconnectedtogetherforcurrenttoflowacrossthe
system.Onemoretimeconnectallgrounds.Thisisthe#2reasonwhynoviican'tgetasystemtowork.
Forourbreadboard,wewillbeinputting9V(orwhatevertransformeryou'vegotuptoabout15V)and
outputting0V(GND)and5Vtoourbreadboardrails.

Wearegoingtogothroughabunchofiterationsofthepowersupply,addingpartsaswego.Shown
above,wehaveabasicregulatorconfiguration.9Vin,weshouldseearough5Vontheoutput.
Schematicnote:Thetwogroundpinsarenotshownconnected.Weassumethatnets(thegreenwires)
ofthesamenameareconnectedtogether.Schematicscangetbigandcomplex,soyouwon'tseeallthe
wirestogether,butinyourbreadboardyouneedtoconnectalltheGNDpinstogether.Inthiscaseit's
theGNDwirefromyourwallwartconnectedtotheGNDpinontheregulator.
Cool.Butwhydoesn'tthemultimeterread5.000V?Electronicsarenotthatgood.Thecheapo
regulatorsare+/5%tolerantmeaningyou'llseebetween5.25and4.75V.Inpractice,youshouldsee
between5.1and4.9Vwithmostrunofthemillregulators.Youcanofcoursespendmany$$andget
tightertolerancesbut5.14.9Vwillworkfineforourpurposes.
https://www.sparkfun.com/tutorials/57

5/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Nowweshouldbeworriedaboutripple.Thereisnoisecomingintheinputpin,theregulatortrieshard,
butsomeofthatnoisegetsontotheoutputpin.Yourmultimetersays5.08V,butthat'sbecauseit's
averagingmanyreadingstogetherandshowingyouonlytheaverage.Doyouknowsomeonewitha
oscilloscope?Ifso,showthemthistutorialandaskthemtoshowyouthenoiseonyour5Vrail.Withno
filteringcaps,youcouldseeasmuchas200mVofnoise.
Whoawhat'safilteringcap?Filteringcapacitorsarelargebulkycapacitorsthathelpsmoothoutripple.
There'vebeenlotsofanalogiesaboutcapacitorssohere'sanotheroneforya:
Capacitorsactlikewatertanks.Whenyourcircuitpullsabunchofwateroutofthesystem,thecapacitor
helpsholdthevoltageuptemporarilyuntilthepowersystemcancatchup.Forexample:youmaylivein
acitywithwaterandwaterpressure.Ifyoutakeashoweryouaffectthepressureinthemunicipalwater
systemeversoslightly.Ifeveryoneturnedontheirshowerandflushedeverytoiletinthecity,oddsare
thewaterpressurewouldfluctuatequiteabit!Abigwatertankhelpsminimizethesepressure
fluctuations.Abigcaphelpsminimizethevoltagefluctuationsonyourbreadboard.
Isthissomethingyoucanseehappen?Unfortunatelynotreally.Youcanprobablyrunyoursystem
withoutfilteringcaps,butit'snotgoodengineeringpractice.Giveitawhirlwithoutcaps!Butwhenthings
don'twork,you'llwonderifit'sthecaps,oryourcode,oryourtiming,ormaybeyoublewoutthesensor.
Toomanyunknownswillmakeyoucrazy.Myrecommendation:justuseacouplebasiccaps

100uF(onehundredmicrofarad)ontheinputand10uFontheoutput.Youwillusealotof100uFand
10uFaroundpowersystemsandyouwilleat0.1uF(pointonemicrofarad)capslikecandyaround
micros.Thesetwocapsshouldsmooththeinputintotheregulatorandwillsmooththeoutputnicely.
Capacitorscannotdelivertheirstoredenergyinstantaneously.Largercaps(1ouFand100uF)store
moreenergy,buttheyreactmoreslowly.Thesmallerthecapacitor,thefasteritcandeliveritsstored
energy.Ifyouhavealargepoweroutage(powerdipsfor10100ms),abigcap(100uFto1000uF)will
help'holdup'thefallingvoltage.Asmallercap(0.1uF)willhelpsuppresshigherfrequencynoiseand
shorterpowerdips(noiseinthe1usto100usrange).Therefore,0.1uFcapsarelocatednearthe
microcontrollertohelpwithshortbursts,where100uFand10uFcapsareusedonthepowerrails.
Nowyouseetheschematicsymbollooksabitodd.What'swith+andcurvedlines?Thisschematic
componentisindicatingthatthe100uFand10uFcaparepolarized.Ohjeebus,what'sthat?Timefora
capacitorbreakdown:

https://www.sparkfun.com/tutorials/57

6/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Electrolyticcaps:Thesearelargercapscapableofstoring10uFto1,000,000soffarads.Theyare
cheapandgreatforbulkcapacitance.Theyarepolarizedmeaningthereisapositivepinanda
negativepin.

Thecaphasaminus''signonthecoverindicatingthatpinneedstogotoGND.
Ceramiccaps:Thesearethecheapestandmostcommoncapyou'llplaywithonabreadboard.
TheyareNOTpolarizedsoyoucanstickeminthebreadboardanywayyouwant.Ceramiccaps
cannothandleaslargeofcapacitanceaselectrolyticssoyou'llneedbothonyourbreadboard
system.
Therearemanymoredifferentkindsofcapacitorsbutforthesakeofyourheadexploding,we
won'tcoverthemhere.
Okaynowyouneedtoworkthroughsomelogichere.Youknowthepositivepartofthe100uFcap
needstobeconnectedtotheinputpin,butonlythenegativepinismarked.Yesit'sconfusingbutyou'll
getusedtoit.Negativemarkedpingoestoground,theothergoestotheinputpin.
Whathappensifyougetthemswitched?Wellhere'swherethingsmaygopoof.

https://www.sparkfun.com/tutorials/57

7/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Fromtheleft:Bad,good,ugly
Thisiswhathappenswhenyouovervoltageorreversevoltageapolarizedcapacitor.Themiddlecapis
normal.Thecapontheleft,youcanseethetopisslightlyraisedup.Thisiswhathappenswhenthe
electrolyteinsideexpands.Andthecapontherightshowsuswhathappenswhenthispressureisso
great,itbuststhroughthemetaltop.Noticethe'+'imprintedintothetopsofthesecaps?Thatimprintis
theresothatifthepressuredoesbuildup,thecapwillfailliketheunitontherightratherthanblowing
thetophalfofthecapacrosstheroom.
ThispicturewastakenfromtheinsideofanoldGatewaycomputer(circa1999).Gatewayhadused
some'marginal'1000uF/16Vcapacitors.The/16Vmeanstheyareratedto16V.A16Vratingmeans
theycanwithstandvoltagesupto16Vbutnomore.Thesecapsweresittingonthe12Vrailtosmooth
outtheripplebutobviouslytheywherefailing.Gatewaywastryingtosave$0.50byusingacapacitor
thatwastooclosetothemaximum.Manufacturingisnotperfect!Withanyproductionrun,thepopulation
ofcapacitorsandtheirtolerancelookslikeabellcurve.Themajorityofthe16Vratedcapscanwithstand
16V.Somecan18V,even22V!Butthetolerancebellcurvegoesbothwaysasmallnumberofthe
capacitorsratedat16Vwillfailat10V,someat8V.Yougetabigenoughrippleonthe12Vlineandyou
couldpopthe16Vratedcap.Thisiswhymostengineerstalkof'derating'capacitors.Ifyouhavea5V
rail,youdonotsticka5Vratedcapontherail!Agoodruleofthumbistoderateanycapacitorby50%.
Soa12Vcapisgoodtobeusedon6Vrail,24Vcapona12Vrail,etc.
Guesswhathappenswhenanelectrolyticcapfailsliketheonesabove?Theyquitworking.Inmost
cases,they'failsafe'meaningtheywon'tworkasacapacitoranymorebuttheywon'tshorttoground.
Therealfunbeginswhenthefailureissobadthattheinternalsfusetogetherandyougetashortto
groundthenyoucanhavesomefunmeltdowns!Inthecaseofthiscomputer,themotherboardhadall
sortsofbadsoftwarefailuresbecausethepowersupplyhadtoomuchripple!Thebigfilteringcapson
thepowersupplyhadfailedsothe12Vwasallovertheplace.
https://www.sparkfun.com/tutorials/57

8/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Similarfailurescanhappenifyoureversethepolarizationofthecap.Ifthevoltageislow(lessthan
around25V)thecapwillprobablyjustbedamagedabit.Ifyou'vegotavacuumbellsittingaroundand
youwanttoreallycausesomedamage,askatrainedprofessionaltohookup10Vcapbackwardsto
10,000V.Itshouldinstantaneouslyblowuplikeapopcornkernel.
Foryourpowersupplyfilteringcaps,Irecommendusinga25Vrated100uFcap(100uF/25V)onthe
inputanda10uF/10Vcapontheoutput.Engineerswilltellyouto'derate'thecapby50%meaningifthe
labelsays100Vdon'ttrustitpast50V.Thisisgenerallygoodpractice.Followingthisidea,our
100uF/25Visgoodforinputsuptoabout12.5Vbeforeweshouldworrythatwemaypopthe
electrolytes.Again,notmandatory,justdon'texpecta5Vratedcaptowithstanda9Vinput.
Backtoourpowersupply!Don'tworryaboutblowingthingsupjustyet,youshouldbeatlowenough
voltagesyouwon'tdoanyharm.Again,ifthingsheatup/smoke/spark,justunplugorturnoffthesystem.
Speakingofturningthingsoffweneedapowerswitch!

Thiswillallowyoutoturnon/offthesystem.Handy.Itcangetreallyannoyingpullingandinsertingthe
powerwirestopower/killyoursystem.
Insidethesmallblackenclosure,isaswitch.Theswitchhasthreepins.Itlookslikeaseesawinside.
Thecenterpinisalwaysconnectedtothemiddleoftheseesawandasyouslidetheswitchbackand
forth,theseesawrocksupanddown.Slidetheswitchforwardandtheseesawshortsfromthecenter
pintotheforwardpin.Slidetheswitchbackandtheseesawdisconnectsfromtheforwardpinand
shortstotherearpin.Werecommendyouconnectpowertothecenterpinoftheswitch.Whenyouslide
theswitchforward,powerwillshorttoanunconnectedpinanddonothing(nopowertoyoursystem).
Slidetheswitchbackandthecenterpowerpinwillshorttothewirerunningintoyourregulator,
deliveringpowertoyoursystem(poweron!).
RememberallthewarningaboutreversingVCCandGNDandhowthatisbad?Wellifyouconnectyour
powersupplybackwards,that'sbad.Solet'sprotectourselves!

https://www.sparkfun.com/tutorials/57

9/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

That'sadiode(markedD1).Adiodeletscurrentflowinonedirection(inthedirectionofthearrow)andit
blockscurrentfromflowingintheoppositedirection.Thiswillallow9Vtoflowintherightdirection,andif
youaccidentallyhookyourpowersupplyupthewrongway,itwillblockcurrentfromflowingbackwards
anddamagingyoursystem.Isitoverkill?Prettyclose.Butwealwaysdesignthemintoourdevelopment
boardsbecausewedon'tknowwhattypeofpowersupplyyouknuckleheads(alsoknownasourpaying
customers)willplugontoourboards.Ifyouplugthewrongtypeofwallwartontoaboard,wewantto
protectyoufromyourself.
Therearesomedownsidestoaprotectiondiode:
Alldiodeshaveavoltagedrop,meaning9Vononesidewilldroptoabout8.5Vontheother.So
your9Vwallwartjustbecame8.5V.
Diodeshaveacurrentrating.Ifyoutrytosuck1A(1amp)througha0.1A(onehundredmiliamp)
rateddiode,thediodewillquicklyheatupandfail.Forreverseprotection,werecommenda1A
1N4001diode.Thesearedirtcheapandverycommon.
Notethatdiodesarepolarized.Theyhaveadirectionthatyouneedtopayattentionto.Manydiodes
haveabandindicatingthecathode.What'sacathode?Gogoogle.Allyoureallyneedtoknowisthatthe
lineontheschematicpartisthesameasthelineonthediode.Ifyoucan'trememberwhichiswhich,
remember'arrowisforanode'.Cheesy,yes.
Soifyouwanttoinstallthis'reverseprotectiondiode',the9Vfromyourwallwartgoesintotheendofthe
diodewithouttheband(theanode).Thebandedend(cathode)goesintoyourswitch.Yourswitchthen
goesintotheinput.Throwtheswitchandyoushouldsee5Vontheoutputusingyourmultimeter.Nifty.
ButIamtiredofusingmymultimetereachtimetocheckthe5Voutput.Theremustbeabetterway!
TimetowireinthepowerLED.
Lightemittingdiodes(LEDs)arebitsofsiliconthatlightupwhencurrentflowsthroughthem.Gogoogle
forthescience.Asageneralruleofthumb,LEDscanhave20mAmaxcurrentflowingthroughthem
beforetheybegintofail.

https://www.sparkfun.com/tutorials/57

10/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

SoifyouhookedupyourLEDlikeintheaboveschematic,itwouldlightupverybrightforasplitsecond
andthenburnout.That'scausetheLEDisadiodeandthecurrentwillflowfromtheanode(arrow)to
thecathode(line)togrounduncontrolled!Thesiliconwillflowcurrentatsomethinglike1ampforasplit
secondandburnup.Tolimitthiscurrentflowto20mA,weneedOhm'slaw.Yea,thebookwormsinthe
roomsuddenlyperkedup:
V=IR(thisisOhm'slaw)
Ifwehave5V,andweonlywant20mAflowingthroughtheLED:
5V=0.02*R
R=250Ohm
NowthisisnotcompletelytruebecausetheLEDhasaforwardvoltagedrop,butdon'tworrytoomuch
aboutthat.HookingupLEDsisverycommonwithmicros.Allyouneedtorememberisthatyou'regoing
toneedtolimitthecurrent.Themostbasicwaytodothisiswitharesistor.220Ohmswillwork(LEDwill
bebrighter),330Ohmisalsogood(LEDabitdimmer),1K(1000)willworkaswell.220,330,and1Kare
morecommonresistorvalues.
Ihighlyrecommendyougetyourhandsdirty.HookupanLEDtoa1kresistor,thena330,thena220,
100,50,thenfinallyblowthethingupbyhookingitwithnoresistor.Thatwasfunright?Good.Youhada
backupright?OncethebitofsiliconinsidetheLEDisburnedout,itisnogoodandtheLEDcanbe
thrownaway.

https://www.sparkfun.com/tutorials/57

11/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Eagleschematic/PDF
Ourfinalpowersupplycircuit.Itseemslikealotofwork,butonceyousetthisuponyourbreadboard,
youmightnevertakeitoff.Thisisthebasisforallthingsmicro.Theinputvoltagemaychange,the
outputvoltagemaychange(to3.3Vforexample),butthebasicsareallthere.Fliptheswitchandyou
shouldhaveanice5VrailandanLEDlettingyouknowthateverythingisaok.IftheLEDdoesnotlight
up,thatmeansthatsomethingelseonthe5VrailissuckingsomuchcurrentthattheLEDcannotlight
up.Thisisaverystrongindicatorsomethingiswrong.IfyouturnonyoursystemandthePowerLED
doesnotturnon,immediatelyturnoffthesystemandcheckyourwiring.
Youmaybewonderingiftheresistor/LEDordermatters.Itdoesnot.Theresistorcancomefirstand
thentheLEDorasshown.EitherconfigurationwillcorrectlylimitcurrentthroughtheLED.
IfyouthinkyoumayhaveblownupyourLEDthenyourLEDwillneverturnon.Youmaywanttocheck
yourpowersystemwithamultimeterinstead.
Good,you'vemadeitthisfar.Nowforsometechnicalinfoaboutripple/noiseandwhyit'sbad.
Ifyou'vegotmajorrippleonyourpowerrail,say500mVormore,thiscancauseyourmicrotolatchup.
Thismeansthatitwasrunningfineat4.8V,butat4.3Vit'snothappyandwillgointoanunknownstate.
Whentherailreturnsto4.8V(becausetherippleisbouncingtherailupanddown),themicrogoesfrom
unknowntopossiblylatchinguporfreezingup.Thisisprettyrarethesedaysbecausethechip
manufacturershavedoneagoodjobofinternallyprotectingagainstthis,butingeneral,rippleisbad.
Sayyou'vegot500mVofrippleonyoursystemandyou'redoinganalogtodigitalconversionsoffofa
temperaturesensor.Thetempsensorhasanoutputpinthatwilloutputananalogvoltagethatwillvary
100mVforevery1degreeC.Soat25degreesC(roomtemperature)thesensorwilloutput2500mVor
2.5V.Ifyourmicroisdoinganalogtodigitalconversionsonthissignal,ithastocomparewhatit'thinks'
isasolidpowerrailof5Vagainstthischanginganalogsignalfromthetemperaturesensor.Wellifyour
5V'solid'railhas500mVofripple,themicrodoesn'tknowthis,andwillreportaregular2.5Vreadingas
varyingbetween~3.0V(3000mV=30C)and~2.0V(2000mV=20C).Thisiswildlybad.Youneeda
good'clean'powerrailifyouaredoinganythingwithanalogsignals.

Nowsomenotesandphotosonbreadboards:
GoreadTomIgoe'sbreakdownofthebreadboard.Inshort,thepowerrails(thered/bluerows)are
connectedinternally.Thecolumnswithinthemainareaoftheboardareinterconnected.Soyoucan
insertawireintooneholeanditwillbeelectricallyconnectedtoaneighboringhole(verticalconnections
forthenumberedcolumns,andhorizontalconnectionsfortheblue/redpowerrails).
Historically,thebluerailorthehorizontalrowofholesnexttothebluelineis'GND'orground.Youcan
connectallthegroundpinsofallyourcomponentstothisrail.Similarly,theredrailisforVCC.Inour
case,thisis5volts.

https://www.sparkfun.com/tutorials/57

12/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Powerjack,switch,LM7805,powerLED
Hereyoucanseepowerfromthebarreljackbeingdeliveredtotheslideswitch,andthentotheinputpin
ofthevreg.Whentheswitchisthrowntotheonposition,theyellowLEDturnson.
Icheatedabit.
Doyouseethatoddthingintheupperrightcornerofthepicture?ThatismywallwartpluggedintoaDC
barreljack.Mostwallwartsareterminatedwitharoundconnectorcalleda'barrel'.Theoutsidemetal
sheathisground,andtheinsidemetalis9V.Thetwometalcontactsareisolated.TheDCbarreljack
acceptsthiswallwartbarrel(wallwartbarrelslidesintothejackwithsomefrictiontoholditinplace).I
don'tlikehackingtheendsoffpowersuppliesandinsertingthebarewiresintoabreadboard.Having
energizedbarewiresbothersme.Ifthewiresgetpulledoutofthebreadboardbecauseyoukickedout
thepowercord,you'llhavesometensemomentsuntilyougetthepowerbrickunplugged.SoIsoldered
someshortleadstothebarreljacksothatIcanplug/unplugmypowercablefromthebreadboard.
Easiertotransport.
Seetheorangewireattheendofthebarreljack?ThatpininsidetheDCbarreljackconnectstothe
centerofthewallwartbarrel.Thecenterofourwallwartbarrelconnectorsare'+'or'hot'or'9V',
whateveryouwanttocallit.SotheendoftheDCbarreljackissolderedtoanorangewiringmeaningit
is'+'.Thisorangewireisthenconnectedtothecenterpinofthepowerswitch.
Allgroundconnectionsareconnectedtogether.YouwillseeasmallblackwireunderneaththeDCbarrel
jack.Thisisthepinthatconnectstotheoutsidesheathofthewallwartbarrel.Thisistheground
connectiononthewallwart.Thissmallblackwireconnectsthegroundofthewallwarttothegroundon
thebreadboard.
Ididnotinstallareverseprotectiondiode.IonlyusecenterpositivepowersuppliessoIknowI'msafe.If
youdoanythingsimilar,checkyourwallwartcarefullywithamultimeterbeforedoinganytesting.

https://www.sparkfun.com/tutorials/57

13/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Note:Ourbreadboardwillhave5Vand0Vrails.ThebluerailisGND(considered0V).RedisVCC(or
called5V).
NoteonLEDs:LEDsareapolardevicemeaningyou'vegottohookthemupinthecorrectdirection.
Lightemittingdiodes(LED)haveacathodeandananode.Howdoyoutellthedifference?Imaginethe
schematicelement:

AnLED
Doyouseethearrow?Doyouseetheflatline?Aisforarrow.Aisforanode.ThephysicalLEDwillhave
aflatsidecorrespondingtotheflatline(thecathode)intheschematicpicture.Andthereyougo!When
connectinganLED,youknowthatdiodesonlypasscurrentinonedirection(fromanodetocathodein
thedirectionofthearrow!)sotheflatsideoftheLEDneedstobeconnectedtogroundsomehow
(usuallythrougharesistorfirst)andtheotherside(rememberarrow)istheanodeandneedstobe
connectedtopowerforcurrenttoflow.Ifyouhookitupbackwards,itwon'tturnon,andyoumight
damagetheLEDbutprobablynot.Justverifythatyou'vegot5Vonthecorrectrailandthenflipyour
LEDaroundifneedbe.
<imgalt=Theimage

Comments101comments
Loginorregistertopostcomments.

Verygoodwriteup,Idohaveaquestionthoughregardingtheuseofcapacitorsforthepowersupply.
Hedgehog / about3yearsago / 3

Youarerecommending100uFontheinputlineand10mFontheoutputline.Specsheetforthe
LM7805recommends0.33uFontheinputlineand0.1uFontheoutputline,substantiallydifferent
values.Why?
Also,thespecsheetforthevoltageregulatorthatIactuallyhaveathandLM2940CT5.0recommends
0.47uFontheinputlineand22uForlargerontheoutputline.Iamnotconcernedwiththeexactvalue
herebuttheyrecommendlargercapontheoutputlinecontrarytowhatyouareexplaining.Any
suggestionwhy?

tr0nk / about6yearsago / 3

https://www.sparkfun.com/tutorials/57

14/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

ifyoujustneedtogetsomeprettylightsblinking(foranartprojectorsomething),andyoufindthese
tutorialsoverwhelming(eventhoughtheyreawesome(!!)),youmaywanttostartwithanarduino
programmerinstead:
ArduinoUSBBoard
http://www.sparkfun.com/commerce/product_info.php?products_id=666
http://www.arduino.cc/
itisstillrecommendedthatyoureadthroughthetutorials(^_^)/

reallynicetutorial,iactuallyreadthewholething,andineverknewicouldgetsoexcitedabouta
wuziq / about7yearsago / 3

regulatedpowersupply..:D

Thanksalot,thistutorialisgreat,ithaseverythinganelectronicshouldknow,eventheobviousbuttricky
xxxlepexxx / about7yearsago / 3

things.Isaveditcompletely.

YouhaveaspellingerrorinyourORmicrocontrollercode.
Andros1200 / about6yearsago / 2

if(A==1||B==1)
{
C=1
}
else
{
C=0
{
Ifyouwouldnoticetheverylastbracketisanopeningbracketnotaclosingbracket.
Verynicetutorial!

besttutorialsofar.twodownsidesthough:

SIGTERMer / about6yearsago / 2

grayisntthebestcolorforthiskindofreading.
aprintableversionshouldbemadeavailabe,ifithasntbeenalready.
nevertheless,goodjob:)

Well,thiskindof5VsourceisntthetypeIduse.Itwastesalmost50%ofthepower.Thismeansthat
Manuel2 / about6yearsago / 2

your9Vbatterywilllastalmostthehalfitshouldwithawellmade5vsource.TherearesomeICsfrom
maximthatachievehighefficiencies.Ivelearnedthatinbatterypoweredprojectsoneshouldbeas
efficientaspossible.Anyway,Ithinkitsawellmadetutorialanditsagoodstartingsourceforonesfirst
projects.Bytheway,youaresorightaboutthePTCs.IveseenseveralofmymostsensitiveICssmoke

https://www.sparkfun.com/tutorials/57

15/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

todeathinaninstantandnotbecauseofshortcircuits.Whenusingbatteriesonehastotakeinto
accounttheshortcircuitcurrentitgives.Itmaybetoosmall(CR2032forexample)ortoohighandmay
givetroublebecausetheresnolimit.PTCsarelifesavers.

Greattutorials!Ireallyliketoprintouttutorialsandfollowalong,esp.whentheyarelonglikethis.Is
ncsuece / about6yearsago / 2

thereabetterwaytoprintthesetutorials?Thelightgraytextandgraycolumnsonthesidemakeitareal
paintoprintandread.IsthereaPDForprintformattedversionavailable?
Thanksandkeepupthegreattutorials!

Thanksforagreattutorial.Ivebeenwonderingabouttheselittleswitchesusedinbreadboardpower
Bogatyr / about6yearsago / 2

circuitstheyreallprettywimpyinthecurrentdepartment,e.g.,theonelistedinthepartskitforthis
tutorialisratedat200mA.Doesntthatmeanthattheentirecurrentusageofthedesignhookedupto
thesupplycircuitislimitedto200mAbeforetheswitchwillweldopenorotherwisedestruct?
Allthebeefierswitches(1A+)thatIveseenarehugeanddonthavepinssuitablefordirect/convenient
useonabreadboard.AretherehigherratedbutBBfriendly(nosolderingrequired)switchesavailable?
(Where?)
thanks!

Idsuggestsemiconductorswitchingusingatransistorratedforadequatecurrent.Usethewimpy
Larius / about5yearsago / 1

switchtoturnonthebaseorgateofyourtransistor,andthetransistorhandlesallcurrent.

Thanksforveryveryhelpful,easytounderstandtutorial.
nedium / about7yearsago / 2

But,ihaveaquestion.HowshouldweusePTC?
Serialconnectionasaresistororlikeacap?
ItwouldbeverygoodifyoucanintegratePTCtoschematic.
Nate / about7yearsago / 1
Goodquestionitiswiredinline.Iveaddedanupdatedschematicuponyourrequest.Checkout
theendofthispagenearthePTCimage.

Thanksforwritingthatarticle,IvelearnedmorefromreadingthisthanIhaveinalongtime!Verywell
Penguinator / about7yearsago / 2

writtenandeasytounderstand,whichisdifferentfrommanyotherbooksandarticlesIvetriedtoread
onelectronics.

Thatwasreallynicetutorial.Ihaveabachelorsinengineeringandhavenotusedelectroniccircuitsina
tj / about7yearsago / 2

while,soitreallyhelpedrefreshalotofthings.Thanksfordoingthat.
https://www.sparkfun.com/tutorials/57

16/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Niceintrotomicrocontrollers.Butthetutorialisbroken.IcannotseeanythingbeyondtheNoteon
bluefog / aboutayearago / 1

LEDs.Thisisanawesomewriteup.PleasefixASAP.
Toni_K / aboutayearago / 1
Welltrytogetthisonefixedup.Fornow,Idrecommendcheckingoutournew,uptodatetutorials
onbeginningelectronicshere.

Thisisagreattutorial!Thankyourforpostingit.AndihaveaquestionabouttheADCwithrippleonthe
zhebie / aboutayearago / 1

system.Ifthe5Vrailhas500mVofripple(10%ofthereferencevoltage),Ithinkthemicrowillreporta
regular2.5Vreadingasvaringbetween2.5V/110%and2.5V/90%,i.e.~2.27Vand~2.78V.Amiright?

wouldthiscircuitpoweranxbeeokwitha3.3Vvoltageregulatorinstead?
Member#435752 / aboutayearago / 1

Iknowthisisaseveralyearoldarticle,butIreallyhopeyourestillrespondingtoquestionsonit:Would
Member#510040 / aboutayearago / 1

thiscircuitbeappropriatefortakinganautomotive12VDCpowersourceandsteppingitdownto5VDC
foranATMEGA328?Iknowautomotivepowerisverynoisy,buttheprojectImabouttobeginwillbe
dashboardmountedandwilluseoneofthecarstereopowersourcewiresforjuice.
Nate / aboutayearago / 3
Thankstoaneatfeatureonourwebsite,wecanseewhenpeoplepostcommentstoanything
weveauthored.Imaynotbeabletorespondtoeverything,buthappytohelpoutwherepossible:
Thispowersupplyconfigurationshouldworkwellinanautomotiveapplication.Thefilteringcaps
andlinearregulatorshouldremovemostofthenoisearoundthe12Vrail.Onthe12Vinputtothe
regulatorbesuretousecapsthatareproperlyvoltagerated(25Vorhigher).Note:thelinear
regulatorwillhavetodissipatealotofheattoget12Vdownto5V.Ifyourepulling<100mAyou
shouldbeokaywithoutaheatsinkbutconsideraddingonejustincase.

Thisisagreattutorial!OnequestionthoughIboughtthepowersupplykit(KIT08373)thathasallthe
Member#503498 / aboutayearago / 1

partsusedinthistutorial,buttheresapartleftover,theresettablefuse(a500maPTC).Justforkicks,I
putthisinlinewiththediode,beforetheswitch,andeverythingworksfine.Ihaventtriedthisyet,butI
assumethatifijustshortfrom5vtoground,thatwilltripthefuse,sothatnoneoftheotherpartsget
blown.Isthisacorrectassumption?IsupposeIcouldjusttryitandseewhatsmokes,butIllwaitabitto
seeifanyoneresponds)

HeliHarp / about2yearsago / 1

https://www.sparkfun.com/tutorials/57

17/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Typoifyouarecorrectingthem:Page5(lecture1):::Thecheaporegulatorsare+/5%tolerant
[TOLERANCE].Excellenttutorial
Nate / about2yearsago / 1
Thanksforthefeedback!Fixed.

Nateyouareawesome.Thanksforwritingthis.

VancouverMike / about2yearsago / 1

gideon / about2yearsago / 1
Hi.Thanksverymuchforyourtutorial.
AnychanceIcouldusea9Vbatteryinsteadofa9Vwallchargerinyourtutorial?

Excellenttutorial.Ihaveneverpickedupabreadboardorputeventhemostbasicofcircuitstogether.
Member#445445 / about2yearsago / 1

FollowingyourinstructionsIwasabletodoitrightthefirsttime.Ivepluggedinallkindsofledsincluding
someRGBones..toomuchblowingthemup)
Goingbackandrereadingthis,Ididntquiteunderstandthisline.Youmaybewonderingifthe
resistor/LEDordermatters.Itdoesnot.TheresistorcancomefirstandthentheLEDorasshown.Either
configurationwillcorrectlylimitcurrentthroughtheLED
Theresistorcancomefirsthow?

Thistutorialisreallygreatandreallywetmywhistleforelectronics.AsIcontinuedtoreadother
Rohar / about2yearsago / 1

beginningelectronicsbooks(whileIwaitformyBeginingEmbeddedElectronicsKittoarrive,Ifound
otherinformationthatconfusedmeregardingOhmsLawbecauseyoudidntincludeitherein(soI
doubtedthenewinformationwascorrectsincethistutorialissogood!).However(asImsureanyone
butacompletenooblikemeisaware)youcansubtractthevoltagedrop(forwardvoltage)oftheLEDin
theOhmsLawequation,inordertodeterminetheidealbrightnessoftheLED.PertheLEDDatasheet
theforwarddropoftheLEDis2.02.4vat20mA.Usingthelowestvoltagethecorrectformulawouldbe
R=(VinVforward)/IorR=(5v2.0v)/20mA=3v/2ma=150ohms.Dontforgetifyouaregoingto
usearesistorwith+/20%accuracythenyoushouldusea190ohmresistortobesafe.

Hi,reallygreattutorial,justonequestion:ifIwanttopoweranarduinomicrothatmustbepoweredover
wedontplay / about2yearsago / 1

7voltsbutiwanttousetheregulated5voltslineforpoweringloadsbypassingarduino5voutputijust
connectarduinoVIafterthe100uFcapacitorbutbeforethevoltagedividerisitright?Doyouthinkthis
willleadtoproblemsduetothedifferentnoiseonmyarduinoandthemainpowersourceline?Ineedto
readlowanalogvaluesfrom5IRproximitysensor.TxGabriele

https://www.sparkfun.com/tutorials/57

18/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Hello!!

Member#429501 / about2yearsago / 1

Reallyniceguidancegivenbyyou.Imadethiscircuit3daysbeforeanditwasworkingfineandwas
showing5.2V.Suddenlyfromtodayithasstartedrespondingerratically.Todaywhenimeasuredthe
voltageitisshowing10V.Kindlyhelpmeout.
Chandhooguy / about3yearsago / 1
Wow!Greattutorial!Ijustraisedmycartprice$100)No,Imnotkidding!

Umm,isntthefirstbitofcodemostlyequivalenttoC=A||B?Imnotsurethiskindofverbositymakes
hyperspaceotter / about3yearsago / 1

agreatexampleofcoding.

IsthislevelofvoltageregulationnecessaryforaDCbasedpowersupply(e.g.,batteries),orcanIomit
cstansbury / about3yearsago / 1

the2capacitorsandjustgowiththevoltageregularanddiodeforabatterybasedpowersource?

Thankyouthankyouthankyou

bash / about3yearsago / 1

THANKYOUTHANKYOU!!!
Greattutorial!

Iamnotabletoseeanypicturesonthistutorial.Lookslikethelinksarebroken.Sparkfun:Canyou
stamhaney / about3yearsago / 1

pleasefixthepictures
Toni_K / about3yearsago / 1
Theyshouldbeworkingforyounow.Ifyouarestillrunningintoissues,pleaseletusknow.

IwishyoursectiononmicrocontrollerswasntsobiasedagainstPICs.Imnotsayingthatanyoneshould
DMLP / about3yearsago / 1

switchtothemthelackofanopensourcecompileriswhatreallykillsthembutPICsareoften
cheaperthanAVRs,havemoreperipherals,andaremorestable.8bitPICshavehadUSBforalong
timenow,Atmegahasonlyjustgottenaroundtothat.Itshouldalsobenotedthatyoucantaccidentally
brickaPICifthevoltagedropswhileprogramming.
ARMsthatarecomparabletoPICs,AVRsandMSPsarelowcost,butARMsingeneralarehigher
processingpowercontrollers,andcostmoretomakeupforit.

TychoVhargon / about3yearsago / 1

https://www.sparkfun.com/tutorials/57

19/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Themajormisconceptionlinkisnowbroken.

highlyrecommendyougetyourhandsdirty.HookupanLEDtoa1kresistor,thena330,thena220,
Member#280256 / about3yearsago / 1

100,50,thenfinallyblowthethingupbyhookingitwithnoresistor.
Usingthismethod,butusinganarduinoUnoboardthatoutputs5vdcIwasntabletoblowtheLED.Is
thisduetothevoltagedropacrosstheLED?

SomethingtoconsiderTheprotectiondiodeinthiscircuitoffersonlyhalfwaverectificationwhichisa
DanP. / about4yearsago* / 1

veryinefficientuseofpower.Abuckmoreonthecircuitbyaddingabridgerectifierensuresthatno
matterhowyourwallwortisconnected,VCCwillflowtogroundontheexpectedpins.
Theprosofafullwavebridgerectifierarehugeincaseswhereyoudontknowwhatkindofpower
supplyyouoryourcustomersmayuse.Furthermorebridgerectifiersaretypicallymarkedwith(+,~,,~)
soyouhavebuiltindocumentationofthecurrentsflowontheboard.
Anicelittlewriteup,amongstmanyisofferedhere
Wouldbeaniceproducttoofferaswell)
Blacklab1 / about4yearsago* / 1
TheonlyproblemwithusingafullwavebridgerectifieristhatVoltagedropacrosstwodiodes,
insteadofNatesonediodedrop.IdontrememberwhatNatewasgivingforthevalueforthe
voltagedrop,butifmymemoryservescorrectlyeachdiodenormallyitsaround.75perdiode.
AsNatesaid>>
Therearesomedownsidestoaprotectiondiode:
Alldiodeshaveavoltagedrop,meaning9Vononesidewilldroptoabout8.5Vontheother.So
your9Vwallwartjustbecame8.5V.
Wellifyouusethe.75voltagedroptimes2diodes,yougeta1.5voltagedropthatmeansyour9
voltwallwartbecame7.5Voltspowersupply.Ifyourprojectdoesnotmindalowervoltagebefore
theregulator,goforit.Butifyougotsomepowerhogsthatswitchonandofforyouhavesomefast
CMOSrunningabove40mhz(thatcouldbe20Mhz)youregoingtoneedtoaddsome.01.1Fand
10Fstocompensateforthoseripplesonyourpowerrails.
IntheolddaysofTTL(TransistortoTransistorLogic),youweresuggestedtoadda.1Facross
eachIC,anditwassuggestedtoadda10FwherethepowerenteredorleftaPCB.Thenagainin
theolddaysofTTLitwasnotuncommontosee12VDCsupplyfeedingabunchof5Vregulators
whichfedalltheTTLgates.TTLjustlovetoeatpower.Thatalsowaswhenitwasnotuncommon
tofindaFairchild5voltregulatorrunningat3to10amps(youcouldarcweldwiththe12Vsupply
side).Thatswhen74LSxxbecamepopular,followedbythe74ALSxx(AdvancedLowPower
Schottky),andfinelyovertothe74HCxx(HighspeedCMOS)andthe74HCTxx(Highspeed,
compatiblelogiclevelstobipolarparts)butthatsanothersubject
MaybeNatewillgetaroundtotalkingaboutusingswitchingpowersupplies,whichforonerun
cooleranduselesspowerlesspowergoesupinheattogiveyouthatsmallervoltage.Thenagain
youregoinghavetoaddcapsacrosstherailstocompensateforthehighfrequencyspikesthatcan
showuponyourpowerrails.
https://www.sparkfun.com/tutorials/57

20/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

AaronLLF / about4yearsago / 1
IorderedthekitandImhavingaproblem.Ifyoufacethebreadboardforward,withBreadBoardModel:
ZY20iatthetop,thesideoftheboardreads,goingdown,jihgfedcbabutonthepicturesit
showsabcdefghijgoingdown.DoIputeverythinginbasingitontheBreadBoardsign,ordoI
followtheletters?

Imnotabletoloadanyofthepicturesinthistutorialandsomeofthepicturesinthefollowingones.Im
teedub / about4yearsago / 1

notsureifitsmaybebecauseIchangedsomeofmybrowsersettings.IthinkIwasabletoseethepics
earlierthismonth.
EvanTeitelman / about4yearsago / 1
Itisntjustyou.Ibelievetheyarecurrentlyworkingongettingtheimagesback.

Thanks,Paradoxial,forthereply.ItwashelpfultoknowthatIwasnttheonlyonewhocouldnt
teedub / about4yearsago / 1

seethepics.Sorryaboutmyreallylatethanksreply.
Andthanks,SparkFun,forfixingthepics,andforcreating/maintainingthesetutorials.Theyare
awesome!

SafetyNote!

Member#230844 / about4yearsago / 1

Thatsnotwhatanelectrolyticcaplookslikeifyoureversevoltageit.Ifyouwanttotryandseewhatit
reallylookslike,doitoutside,wearsafetygoggles,andstayatleast10feetaway!Theyprettymuchgo
likefirecrackersbutdontreally.
Seriously,DONTreverseconnectthemevenforfunyoumaygetinjured.Becarefulltoalwaysput
theminright.
BTW,about90%offailedelectronicsinmyexperience(monitors,motherboards,powersupplies,radios,
cflbulbsetc)gobadfrombadcaps(leakingelectrolyte).Nottoobadtoreplaceandalotoftimesyou
cansavetheitem.Ivesaved3outof5badlcdmonitors,and5outof10motherboardsbyreplacingthe
bulgingcaps.Thesuccessrateisbetterifyoucanreplacethembeforethedevicestartsfailing(when
theyfail,theyoftenshortandtakeotherpartsoutwiththem).Idrecommendtoo,whenbuying
motherboards,lookforoneswithJapaneseand/orsolidelectrolyteelectrolyticcapacitors.
Cheero!
Mark.

Greattutorials!congratulations!

osnam / about4yearsago / 1

Primis / about4yearsago / 1
Justwouldliketosay,Halfoftheimagesinthistutorialarestillbroken,butitisntjustthistutorial,Isawit
happentoabunchoftutorials.
https://www.sparkfun.com/tutorials/57

21/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Cjhazdroid / about4yearsago / 1
Yes,Inoticedthisearliertodayandletstilldavidknow.However,asIhavenoticedafteracouplebeers
(yesitmusthelpmethink)thatjustthedirectoryhasmoved,soforeachimage,justchange
http://www.sparkfun.com/images/tutorials/BEELectures/
to
http://www.sparkfun.com/tutorial/BeginningEmbedded/
example:>Change
http://www.sparkfun.com/images/tutorials/BEELectures/1PowerSupply/BBPowerSupply4.jpg
to
http://www.sparkfun.com/tutorial/BeginningEmbedded/1PowerSupply/BBPowerSupply4.jpg
andyouwillgetyourpictures.
hodx / about4yearsago / 1
someofthisisgood,butalotofBeginningEmbeddedElectronicsneedstobeupdated

Whydontthepicturesworkforthistutorial?

Member#207315 / about4yearsago / 1

Iamhavingthesameproblem.Also,thereissomePermissionDeniederror,whenItrytoviewthe
dpgol88 / about4yearsago / 1

imagesseparately.

Metoo.Supwiththat?

lscarmic / about4yearsago / 1

onalltutorialsicantwiewimages.isendedaemailtosparkfun.
Allan4 / about4yearsago / 1

stilldavid / about4yearsago / 1
Yup,thanksfortheheadsup,all!Fixednow.

Hi,

Litago92A / about4yearsago / 1

Seemslikethepictureswentmissingagain:(

Woa!!IsentanemailtoLinzaboutthebrokenimagesandthenafewminutes
EdZilla / about4yearsago / 1

lateritwasfixedLookslikeyouwerefixingitrightthen.
Looksgood.thanks

https://www.sparkfun.com/tutorials/57

22/29

6/29/2015

Hi!

BeginningEmbeddedElectronics1SparkFunElectronics

!LH@N / about4yearsago / 1

GreatTutorial,thanksalot!Ijusthaveaquickquestion.Whydoyouputthecapsparallel?Howdoes
thatwork?Ialwaysthoughtifyouputsomethingparallelyouhavethesamevoltage,butobviouslythere
is9Vononecapand5Vontheother.Howdoesthatwork?
Pleaseexplain

Nevermind,foundtheanswermyselfthe10uFcapisinserieswiththeregulator,andthemtwo
!LH@N / about4yearsago / 1

areparalleltotheothercap.Thanksanyway!

Notquitetrue.Bothcapsareinstalledparalleltothevreg.Theyhavetobe,astheyblockDC
Rohar / about2yearsago / 1

currentoncetheyarefullycharged.Ifyouroscilloscopeshowsoutputpowerof5vforafew
seconds,thendropsto0v,youmayhaveinstalledacapacitorinseries.

ThanksIknowabsolutelynothingaboutelectronicsandwasabletobuildthebreadboardinjustthree
dantheman / about5yearsago / 1

evenings.IevenusedandlituptheextraLEDWow<br/>
<br/>
ThethingIdontreallyunderstandaboutbreadboardsishowthehole/rowsareconfigured.Ifyouarein
row5,forinstanceistherow6alwaysmeanttobethegroundrow?Oriseachrowisolatedfromthe
other?<br/>
<br/>
AlsoIstartwithACcurrentinthehousebutthewhenyougointothebreadboardnowthereisaground.
IsthisstillACcurrentnowordoesitturnintoDC.ThanksinadvanceIlovethissite.

Excellenttutorial!IhadneverthoughtaboutusingaPTCinavoltagesupplybefore,itsperfectsoa
ibot / about5yearsago / 1

beginnerlikemewontburnupanycomponents.

Idonttotallyunderstandthispart:

FLITE / about5yearsago / 1

Intheolddays,microcontrollerswereOTPoronetimeprogrammablemeaningyoucouldonlyprogram
themicroonce,testthecode,andifyourcodedidntwork,youthrewitoutandtriedagain.Nowmicros
areflashbasedmeaningtheyhaveflashmemorybuiltinsidethatallowstheircodetobewrittenand
rewrittenthousandsoftimes.Ivebeenprogrammingmicrosforyearsandalwaysburnoutthe
microcontrollerfarbeforeIhitthelimitofflashprogrammingcycles.
Igetthatitmeansyoucanprogramthemmorethanoncenow,butIamunsureastowhatismeantby
programming

CTC001 / about5yearsago / 1

https://www.sparkfun.com/tutorials/57

23/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Thisisagreatlectureanditgetsallthiscoolrawelectronicsgearinyourhands.Prettynewto
electronicssothisisperfect.ThissimplecircuitputtogetherwithanLEDandeverything,takenalong
withthefirst50pagesorsoofElectricalEngineering101,hasreallyhelpedmetofeellikeIgotmyfeet
wet.Fun!
http://www.sparkfun.com/commerce/product_info.php?products_id=9458

IhopeyouknowthatthetechnicalnameforanLEDthathashadtoomuchforwardorreversecurrent
RoboKaren / about5yearsago / 1

throughitisaDED:DarkEmittingDiode.
Pleasemodifyyourtutorialaccordingly.:)
SingleT / about5yearsago / 1
Thanksfortheinformation,andinput.Wewillmakesomechanges.
Snibble / about5yearsago / 1
AgreethattheAVRstuffisfuntoplaywithatthepricepoint,buthaverecentlybeendoingMSP430stuff
atworkandranacrossadealthatmightbeinterestingforsomereaders.$4.30foracoupleofvalue
lineMSPchipsandsupportingboardforexperimenting.
http://www.tiestore.com/Merchant2/merchant.mvc?Screen=PROD&Product_Code=MSPEXP430G2

Hi,iwouldliketoknowifIcanuseanalternativepartinsteadofusingPTCbecausePTCisnot
ThomasCruz / about5yearsago / 1

availableherebutNTCis..cananyonehelpmeaboutthisthanksinadvance

ARMmicrocontrollesactuallystandforAdvancedRISCMachineswhichweremadebyARMholdingsin
Klone38 / about5yearsago / 1

themid1980asaoriginalsubstitutefortheMotorola68000andNationalSemiconductor32016tobe
usedintheAcornBusinessComputer.theMotorola68000andNationalSemiconductor32016wernt
strongenoughinthecomputersoARMholdingsdecidedtoinventanewchipcalledtheARM.formore
infoyoucanwikipediaARMarchitecture,ARMHoldings,orAcornComputers.

Nicetutorial!

blen2r / about5yearsago / 1

Iwaswonderingifthatripplewewerefilteringwiththecapacitorsispresentwhenthepoweriscoming
fromabattery?

Igetaconsistent6.5ishvoltsoutofthe10orsoL7805CVsIvetestedthiswith.
alexl / about5yearsago / 1

Whatsgoingwronghere?Imusingastandard9vbatteryasmypowersource.

alexl / about5yearsago / 1

https://www.sparkfun.com/tutorials/57

24/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Ifigureditout:thebatteriesweredeadinmymultimeter.

CanthePocketAVRProgrammerbeusedinsteadoftheAVRSTKParallelPortDongleProgrammerto
SeaJay / about5yearsago / 1

supportlaptopswithoutparallelports?Ifnot,arethereanyotherfixes?Thanksinadvance.

ThisworkedformeaccordingtotheinstructionsandIusedubuntuasthe(parallelport)PC
ebrandt / about5yearsago / 1

programmer.Ihadtomaketwosmalleditstothemakefiletogetittowork:
1.removethePlpt1fromtheAVRDUDE_FLAGS(itsnotcalledlpt1onubuntu,andthedefaultvalueis
fine,soitsOKtoommitthatflagentirely.)
2.IhadtoaddEnoresettotheAVRDUDE_FLAGS.Thisdeactivatesthe/resetlineontheparallelport
afterprogramming.Withoutit,pin1stayedlowafterprogramminguntilIdisconnectedtheprogrammers
resetline.WiththisflagIcanleavetheprogrammerconnected.
Justafewtipsthatanyoneelseusingubuntumightfinduseful.Happyblinking

WouldlovetohearsomeexamplesofwhereyoufeelPICsareinadequateforyourpurposes.Isitjust
Robban / about5yearsago / 1

veryspecializedtasksorjustingeneral?ImstilljustanewbiebutIveplayedaroundwithafewdifferent
PICsinseveralprojectsandIveyettocomeacrosssomethingtheycantdo(ofcourse,thesearebasic
projects).

Ikeepbeingamazedathowhelpfulthesparkfuncommunityis.Goodjob!Wellexplained!
warlord / about6yearsago / 1

Thetuitorialisveryinformative.IthasturnedmeintoaSparkfunfan!
Ngesh / about6yearsago / 1

Greattutorial.Thanks!

Techn010g1ka11 / about6yearsago / 1

Thisisagreattutorial!Itwasalotoffuntoreaditcausethereisnothinglikethisforcomputer
hm / about6yearsago / 1

programmersthatknownothingofelectronics!
OnepointtomentionistoNotethatIBURNTMYLEDbecausetheGNDpinofmyvoltageregulatorwas
notconnectedtothesharedground!Theregulatorsoutputpininsteadof+5Vwasgivingout+9.8V!
JustbecauseofamissingGNDconnection.
IsuggestwemaketheGNDconnectionofourregulatorthefinalgateforallgroundsconnectionsinthis
circuit,soifthatgoescut,ourcircuitwouldturnoffinsteadofhavedangerousvoltage!

blalor / about6yearsago / 1

https://www.sparkfun.com/tutorials/57

25/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

TheresabrokenimagetheimageabovethetextThecaphasaminussignonthecoverindicating
thatpinneedstogotoGND.pointstohttp://www.sparkfun.com/commerce/images/Caps3.jpg,which
is404'ing.
SuryaSharma / about6yearsago / 1
HowarePTCscoded?Ineedonefor500mA/5V(USBspecifications)TheonesIhaveReadC1122
and0135.Howmanyampsarethese?

IjustgotthepartsinthemailyesterdayWhatsfunnytomeisthatIthoughtallthecomponentswere
thejam / about6yearsago / 1

muchbiggerthantheyactuallyare.ProbablybecauseIveonlybeenlookingatpicturesforthepast2
weeks.
ButIputthepowersupplytogether,anditworked!TheLEDlitupanddidntburnout.Andevenmore
thanthat,Icanreadtheschematicsnowtoo!ItallmakessensenowthatIcanseeitinmyhandsandon
theschematic.
Thanksforthesetutorials!

Thanksfortakingthetimetopostsuchagreattutorial.Iapologizeifthisistakenintoaccountinsomeof
NathanWong / about6yearsago / 1

yourlatertutorials(Iintendtoreadthemall!),butIjusthaveonequestion:Somecomponents,likethe
littleLCDscreenssoldhere,require3.3V.Howwouldthisusuallybeprovided?Woulditbeaparallel
splitattheendofthepowercircuitandanothervoltageregulator,orwoulditbeasplitbeforethevoltage
regulatorandthenhavetwocircuits,oneat5Vandoneat3.3V?Imjusttryingtounderstandhowto
takeadvantageofhaving9V(albeitunregulated)andneedingboth5Vand3.3V.:)Thanksagain!

Outstandingtutorial!Thanks.

KB8RWX / about6yearsago / 1

Greattutorial.Ilovelearningmoreaboutpowerflows.
spangaroo / about6yearsago / 1

Icanseetheresistorinthephoto,butIdontseethe1N4001diode.AmImissingsomething?Imjust
tryingtostudyallthecomponentssoIcansetitupproperlyfromthebeginning.
Snibble / about5yearsago / 1
SeeNatescommentinthesectionbelowthefirstphotoofthebreadboard:
Ididnotinstallareverseprotectiondiode.IonlyusecenterpositivepowersuppliessoIknowIm
safe."
(soundslikefamouslastwordstome)

ImnotsureIveeverbeensoexcitedtoseeanLEDlightup.Greatwriteup=D
mousewiz / about6yearsago / 1

https://www.sparkfun.com/tutorials/57

26/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

abitlengthybutawesometutorial

Michelle / about6yearsago / 1

Greattutorial.Thanks.

DavidMcFarland / about6yearsago / 1

Acoupleofquestionsaboutthecapacitors:
1.whydoyouusetwo?
2.whatwouldhappenifyouswitchtheirpositions(putthe10uFwherethe100uFisinyourschematic,
andviceversa).
Chandhooguy / about3yearsago / 1
1. Thevoltageregulatorshavefluctuationstooaftertheelectricitygoesthroughthem,there
maybenewfluctuations.
2. Well,your10uFdoesntlikethe9V,andyour100uFdoesntlikethe5V.Ifyoudothat,most
likelyyouwilldamage(eversoslightly)yourcaps.
MattTheGeek / about6yearsago / 1
ThanksforthetutorialNate.

5.1Vandalovelyyellowlight!!Thanksforagreat,wellthoughtouttutorial.Ontomicrocontrollers
BeanForge / about6yearsago / 1

Excellenttutorial.OnethingIdliketoaskisthatmyVoltageRegulatorgetsfairlywarmnotsowarmas
TheDoc / about6yearsago / 1

toburnme.Nevertheless,Imworkingonagadget(mostlyjustanRGBthingy)thatIwanttogivemy
grandma.Anyway,Ijustwanttofigureouttokeepthevoltageregularfromgettingsohot.CanIjustput
anextraresistorbetweenthepowerinandtheregulatororsomething?
Wickedtutorialatanyrate.Thankstons!

cpjolicoeur,

TBaumg / about6yearsago / 1

AnLEDandResistorinseriescreateasinglepath(circuit)forelectricitytoflowthrough.Itdoesn?tmatter
iftheresistorisbeforeoraftertheLEDbecausethetotalimpedanceofthatcircuitislimitedbythe
resistor.
Itissimilartoawaterhoseandavalve.Thevalveislikearesistoritcanlimithowmuchwatercanflow
throughit.Itdoesn?tmatterifthevalveisatthesupplysideortheopensideofthehose,theendresult
willbethesamelimitedamountofwater.
AslongasyoulimittheamountofcurrentthatflowsthroughtheLEDitwillbefine.Hopethishelps.

cpjolicoeur / about6yearsago / 1

https://www.sparkfun.com/tutorials/57

27/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Imstillrelativelynewtoelectronicsandhaveaquestion.WhentalkingabouttheLEDyoumentioned:
Youmaybewonderingiftheresistor/LEDordermatters.Itdoesnot.Theresistorcancomefirstand
thentheLEDorasshown.EitherconfigurationwillcorrectlylimitcurrentthroughtheLED."
Whyisthisso?IdontunderstandwhyyoucanputtheresistoroneithersideoftheLED.Wouldntthe
resisterneedtocomebeforetheLEDtoresisttheflowofpowerintotheLED?Howdoesithelp
afterwardswhenthepowerhasalreadygonethroughtheLED?

thisisagreattutorial,havingfun.

peterb / about6yearsago / 1

whenisetupmypowersupplythough,imonlygetting4Vontherails.whywouldthatbe?
thanks,
Peter

TheLM7805ouputis4.3Vwhenusinga5Vpowersupply,but5.01Vwhenusinga9Vor18Vpower
ico / about5yearsago / 2

supply.
CheckedthedatasheetofLM7805,whichsaiditshouldworkswelloninputVo=5Vto18Vand
24V,notsurewhyitouput4.3Vwhentheinputis5Vonly.

oopss.gaveitthewrongsmilye.

boris_1981 / about5yearsago / 1

ThanksNate:)

Gillerire / about7yearsago / 1

IagreewiththecommentabovecouldyoupleaseaddsomemoreexplanationofthePTCandhowit
Gillerire / about7yearsago / 1

connectstothecircuit.
Also,Ihavealwayswonderedaboutthevaluesoffilteringcapacitors.Whydoyouuse100uFonone
sideand10uFontheother?Whenshoulda0.1uFbeused?
Theexplanationofthecapacitormaxvoltagewasveryhelpful.SomethingIneverknewabout.
Nate / about7yearsago / 1
Goodpoints.IveaddedmoreonthePTCandcaps.Largercapsobviouslystoremoreenergy,but
theyreactmoreslowly.Ifyouhavealargepoweroutage(powerdipsfor10100ms),abigcap
(100uFto1000uF)willhelpholdupthefallingvoltage.Asmallercap(0.1uF)willhelpsuppress
higherfrequencynoiseandshorterpowerdips(noiseinthe1usto100usrange).Therefore,0.1uF
capsarelocatednearthemicrocontrollertohelpwithshortbursts,where100uFand10uFcapsare
usedonthepowerrails.

Estwald / about7yearsago / 1

https://www.sparkfun.com/tutorials/57

28/29

6/29/2015

BeginningEmbeddedElectronics1SparkFunElectronics

Greattutorial,aniceadditionforthetotallyinexperiencedwouldbetoaddthediagramsforcenter
positiveandcenternegativebarrelconnectors.

https://www.sparkfun.com/tutorials/57

29/29

You might also like