Arduino Tutorial Lesson 3

Embed Size (px)

Citation preview

  • 7/24/2019 Arduino Tutorial Lesson 3

    1/30

    Arduino Tutorial Lesson 3 - Breadboard and LEDs

    Intro

    Starting

    Lesson 0

    Lesson 1

    Lesson 2

    Lesson 3

    Lesson 4

    Lesson 5

    #6 - LEDs

    LDs

    Et! " SD

    EL$%%%

    Bu& stu''

    (oru)s

    http://www.ladyada.net/learn/arduino/index.htmlhttp://www.ladyada.net/learn/arduino/starterpack.htmlhttp://www.ladyada.net/learn/arduino/lesson0.htmlhttp://www.ladyada.net/learn/arduino/lesson1.htmlhttp://www.ladyada.net/learn/arduino/lesson2.htmlhttp://www.ladyada.net/learn/arduino/lesson3.htmlhttp://www.ladyada.net/learn/arduino/lesson4.htmlhttp://www.ladyada.net/learn/arduino/lesson5.htmlhttp://www.ladyada.net/learn/arduino/LEDs.htmlhttp://www.ladyada.net/learn/arduino/lcd.htmlhttp://www.ladyada.net/learn/arduino/ethfiles.htmlhttp://www.ladyada.net/learn/arduino/help.htmlhttp://www.adafruit.com/index.php?main_page=index&cPath=17http://forums.ladyada.net/http://www.ladyada.net/learn/arduino/starterpack.htmlhttp://www.ladyada.net/learn/arduino/lesson0.htmlhttp://www.ladyada.net/learn/arduino/lesson1.htmlhttp://www.ladyada.net/learn/arduino/lesson2.htmlhttp://www.ladyada.net/learn/arduino/lesson3.htmlhttp://www.ladyada.net/learn/arduino/lesson4.htmlhttp://www.ladyada.net/learn/arduino/lesson5.htmlhttp://www.ladyada.net/learn/arduino/LEDs.htmlhttp://www.ladyada.net/learn/arduino/lcd.htmlhttp://www.ladyada.net/learn/arduino/ethfiles.htmlhttp://www.ladyada.net/learn/arduino/help.htmlhttp://www.adafruit.com/index.php?main_page=index&cPath=17http://forums.ladyada.net/http://www.ladyada.net/learn/arduino/index.html
  • 7/24/2019 Arduino Tutorial Lesson 3

    2/30

    o)e

    About

    o lad&ada*net

    o $ort'olio

    o +esear,!

    o $ress

    o $ubli,ation $resentation

    o $!otos

    o .i/i ba,/end

    $roe,ts

    o Arduino

    Datalogger S!ield

    Et!ernet S!ield

    $S S!ield

    $roto S!ield

    otor S!ield

    .ae S!ield

    o Ad* 7o8er su77l&

    o Brain a,!ine

    o BoArduino

    o DI Button

    o Dra8dio

    http://www.ladyada.net/http://www.ladyada.net/about.htmlhttp://www.ladyada.net/about.htmlhttp://www.ladyada.net/portfolio/2007/index.htmlhttp://www.ladyada.net/pub/research.htmlhttp://www.ladyada.net/pub/press.htmlhttp://www.ladyada.net/pub/pub.htmlhttp://www.flickr.com/photos/ladyada/http://www.ladyada.net/wikihttp://www.ladyada.net/make/http://www.ladyada.net/learn/arduino/lesson3.html#nogohttp://www.ladyada.net/make/logshield/http://www.ladyada.net/make/eshield/http://www.ladyada.net/make/gpsshield/http://www.ladyada.net/make/pshield/http://www.ladyada.net/make/mshield/http://www.ladyada.net/make/waveshield/http://www.ladyada.net/make/bbpsup/http://www.ladyada.net/make/bbpsup/http://www.ladyada.net/make/brain/http://www.ladyada.net/make/boarduino/http://www.ladyada.net/make/digg/http://www.ladyada.net/make/drawdio/http://www.ladyada.net/http://www.ladyada.net/about.htmlhttp://www.ladyada.net/about.htmlhttp://www.ladyada.net/portfolio/2007/index.htmlhttp://www.ladyada.net/pub/research.htmlhttp://www.ladyada.net/pub/press.htmlhttp://www.ladyada.net/pub/pub.htmlhttp://www.flickr.com/photos/ladyada/http://www.ladyada.net/wikihttp://www.ladyada.net/make/http://www.ladyada.net/learn/arduino/lesson3.html#nogohttp://www.ladyada.net/make/logshield/http://www.ladyada.net/make/eshield/http://www.ladyada.net/make/gpsshield/http://www.ladyada.net/make/pshield/http://www.ladyada.net/make/mshield/http://www.ladyada.net/make/waveshield/http://www.ladyada.net/make/bbpsup/http://www.ladyada.net/make/brain/http://www.ladyada.net/make/boarduino/http://www.ladyada.net/make/digg/http://www.ladyada.net/make/drawdio/
  • 7/24/2019 Arduino Tutorial Lesson 3

    3/30

    o (u9ebo:

    o a)e rrl

    o a)e o' Li'e

    o I,e Tube ,lo,/

    o IDIsense

    o ini$;

  • 7/24/2019 Arduino Tutorial Lesson 3

    4/30

  • 7/24/2019 Arduino Tutorial Lesson 3

    5/30

    (S+

    dS $!oto,ell

    Te)7erature

    Tilt

    $I+

    T!er)o,ou7le

    I+ +e,eier

    o Brea/out boards

    DS130 +T

    A?665

    AT)ega32u4 Brea/out"

    o $rodu,ts

    i2,FS$I LD ba,/7a,/

    >SB Boarduino

    AT)ega32u4 Brea/out"

    2*G T(T tou,!s,reen

    1*G S$I T(T

    +(IDF=(

    o !u)b& a,/er Board

    o Soldering tutorial

    o $o8er Su77l& tutorial

    o Brot!er -H033 tutorial

    http://www.ladyada.net/learn/sensors/fsr.htmlhttp://www.ladyada.net/learn/sensors/cds.htmlhttp://www.ladyada.net/learn/sensors/tmp36.htmlhttp://www.ladyada.net/learn/sensors/tilt.htmlhttp://www.ladyada.net/learn/sensors/pir.htmlhttp://www.ladyada.net/learn/sensors/thermocouple.htmlhttp://www.ladyada.net/learn/sensors/ir.htmlhttp://www.ladyada.net/learn/breakoutplus/http://www.ladyada.net/learn/breakoutplus/ds1307rtc.htmlhttp://www.ladyada.net/learn/sensors/thermocouple.htmlhttp://www.ladyada.net/learn/products/atmega32u4breakout/http://www.ladyada.net/products/http://www.ladyada.net/products/i2cspilcdbackpack/http://www.ladyada.net/products/usbboarduino/http://www.ladyada.net/products/atmega32u4breakout/http://www.ladyada.net/products/tfttouchbreakout/http://www.ladyada.net/products/18tftbreakout/http://www.ladyada.net/products/rfidnfc/http://www.ladyada.net/learn/chumby/http://www.ladyada.net/learn/soldering/http://www.ladyada.net/learn/powersupply/http://www.ladyada.net/learn/electroknit/http://www.ladyada.net/learn/sensors/fsr.htmlhttp://www.ladyada.net/learn/sensors/cds.htmlhttp://www.ladyada.net/learn/sensors/tmp36.htmlhttp://www.ladyada.net/learn/sensors/tilt.htmlhttp://www.ladyada.net/learn/sensors/pir.htmlhttp://www.ladyada.net/learn/sensors/thermocouple.htmlhttp://www.ladyada.net/learn/sensors/ir.htmlhttp://www.ladyada.net/learn/breakoutplus/http://www.ladyada.net/learn/breakoutplus/ds1307rtc.htmlhttp://www.ladyada.net/learn/sensors/thermocouple.htmlhttp://www.ladyada.net/learn/products/atmega32u4breakout/http://www.ladyada.net/products/http://www.ladyada.net/products/i2cspilcdbackpack/http://www.ladyada.net/products/usbboarduino/http://www.ladyada.net/products/atmega32u4breakout/http://www.ladyada.net/products/tfttouchbreakout/http://www.ladyada.net/products/18tftbreakout/http://www.ladyada.net/products/rfidnfc/http://www.ladyada.net/learn/chumby/http://www.ladyada.net/learn/soldering/http://www.ladyada.net/learn/powersupply/http://www.ladyada.net/learn/electroknit/
  • 7/24/2019 Arduino Tutorial Lesson 3

    6/30

    o >SB reerse-engineering tutorial

    o ali7ers tutorial

    o +B LED Stri7s

    o +B LED $i:els

    o LiIon Li$ol& Batteries

    Librar&

    o Arduino a,/s

    o Batteries

    o Boost al,

    o E*E* Tools

    o E*E* o)7uter

    o (ind $arts

    o its

    o Laser

    o u Anno&an,es

    o ;7en Sour,e ard8are

    o $B Design Ti7s

    o $I s* A

  • 7/24/2019 Arduino Tutorial Lesson 3

    7/30

    Store

    (oru)s

    lad&ada*netIntrodu,tion

    @ouJe started )odi'&ing s/et,!esK and 7la&ed a bit 8it! t!e onboard LED or i' &ou !ae an=K an LED &ou added* T!e ne:t ste7 is to start adding onto t!e !ard8are ,o)7onent o' t!eArduino* .e 8ill do t!is b& adding asolderless breadboardto our setu7K ,onne,ting u7 ne8 7arts8it! 8ire*

    et &our gear

    Asse)bled ArduinoboardK 7re'errabl& aDie,i)ila or 8!ateert!e latest ersion is but= is ; too

    Ada'ruit

    35

    >SB able* StandardA-B ,able is reMuired*An& lengt! is ;*

    Ada'ruit

    ;r an&,o)7utersu77l& store

    5

    http://www.adafruit.com/http://forums.adafruit.com/http://en.wikipedia.org/wiki/Solderless_breadboardhttp://en.wikipedia.org/wiki/Solderless_breadboardhttp://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=50http://www.adafruit.com/index.php?main_page=product_info&products_id=62http://www.adafruit.com/http://forums.adafruit.com/http://en.wikipedia.org/wiki/Solderless_breadboardhttp://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=50http://www.adafruit.com/index.php?main_page=product_info&products_id=62
  • 7/24/2019 Arduino Tutorial Lesson 3

    8/30

    LEDs

    (or t!is lessonK a redKgreen and blue LED are

    best* a/e sure &ou geta N5))N or N3))NLEDK 8it! t8o legsK ass!o8n in t!e e:a)7lei)age* N>ltrabrig!tNLEDs 1000 ),d ratingor !ig!er are 7re'erred

    An&ele,troni,ssu77l& store

    T!ree 1O +esistors

    bro8n bla,/ red goldAn& alues 'ro) 300 Oto 2O are 7robabl&;*

    An&

    ele,troni,ssu77l& store

    1

    Arduino $rotot&7ingS!ield 8it! tin&breadboard

    Ada'ruit

    15"Ada'ruit*50

    http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=51http://www.adafruit.com/index.php?main_page=product_info&cPath=18&products_id=65http://www.adafruit.com/index.php?main_page=product_info&cPath=17&products_id=51http://www.adafruit.com/index.php?main_page=product_info&cPath=18&products_id=65
  • 7/24/2019 Arduino Tutorial Lesson 3

    9/30

    Standard solderless

    breadboard

    I' &ou dont !ae a7rotos!ieldK t!is is asubstitute

    Ada'ruit

    5

    an& !obb&s!o7s andele,troni,sstores 8ill!ae t!ese

    oo/u7 .ire

    et 22 gauge solid-,ore8ire in redK bla,/ andso)e ot!er ,olor* a/esure its notstranded8ire%

    An&!ard8arestore

    Sa& !ello to t!e solderless breadboard%

    Solderless breadboards are an i)7ortant tool in &our Muest 'or ele,troni,s )aster&* T!e& allo8&ou to )a/e Mui,/ ,ir,uitsK test out ideas be'ore )a/ing a )ore 7er)anent $rinted ir,uit Board*T!e&Jre also ine:7ensie and reusable** @ou ,an 7i,/ on u7 at an& !obb& s!o7 or ele,troni,ssu77l& store* T!e& o'ten loo/ li/e t!is

    http://www.adafruit.com/index.php?main_page=product_info&cPath=18&products_id=64http://www.adafruit.com/index.php?main_page=product_info&cPath=18&products_id=64
  • 7/24/2019 Arduino Tutorial Lesson 3

    10/30

    Basi,all&K a ,!un/ o' 7lasti, 8it! a bun,! o' !oles* o8eerK so)et!ing s7e,ial is going oninside t!e breadboard% Alt!oug! &ou ,anJt see itK inside t!e breadboard are )an& stri7s o' )etalt!at ,onne,t t!e ro8s and ,olu)ns toget!er* T!e )etal stri7s are s7ring& so t!at 8!en &ou 7o/e a8ire into t!e !oleK t!e ,li7s grab onto it*

    In t!e i)ages aboe &ou ,an see !o8 t!ere are t8o /inds o' )etal stri7s* T!ere are s!ort onest!at ,onne,t 5 ro8 !oles at a ti)eK and t!en t!ere are er& long ones t!at ,onne,t 25 or )ore%,olu)n !oles at a ti)e* T!e long ,olu)ns are ,alled railsand t!e s!ort stri7s are ,alled rows*Breadboards are al)ost al8a&s )ade so t!at t!e& !ae t8o sets o' 5-!ole ro8s and on eit!er sidet!ere are a 7air o' rails* (or e:a)7le t!e breadboard on t!e le't !as 30 ro8 7airs and 2 sets o'

  • 7/24/2019 Arduino Tutorial Lesson 3

    11/30

    double rails on eit!er side* T!e one on t!e rig!t is Muite s)allK it !as onl& 1 ro8 7airs and norails*

    In t!is lessonK 8e 8ill s!o8 7i,tures o' bot! t!e tin& breadboard on a 7rotos!ield and also usinga JstandardJ breadboard 8it!out a s!ield* o8eerK a'ter t!is lessonK &ouJll be )ore on &our o8n

    to 'igure out !o8 to ,onne,t u7 t!e standard breadboardK ;P

    Warning!

    Distressing as it )a& soundK solderless breadboards ,an be very'la/e&K es7e,iall& as t!e& age* I'&ouJre !aing 7roble)s 8it! &our ,ir,uitK it ,ould be t!at t!e little )etal ,li7s on t!e inside arenJt8or/ing 8ell* Tr& 7o/ing it 8it! &our 'ingerK or )oing it to a di''erent se,tion*

    Sa& !ello to 8ires%

    To use t!e breadboardK &ouJll need u)7er 8ires* T!ese are basi,all& 22 gauge solid-,ore notstranded 8ires t!at are ,ut do8n and !ae t!e insulation 7ulled o''* @ou ,an use a 'ingernail orKbest o' allK a real 8irestri77er toolto re)oe t!e insulationK ust ta/es a 'e8 tries and t!en itsreall& eas&*

    eres !o8 to do it 8it! ust diagonal ,utters***ut t!e 8ire 'irstK using 8ire ,utters

    =i,/ t!e insulationK t!en 7ull it o''*

    http://www.ladyada.net/library/equipt/kits.htmlhttp://www.ladyada.net/library/equipt/kits.htmlhttp://www.ladyada.net/library/equipt/kits.html
  • 7/24/2019 Arduino Tutorial Lesson 3

    12/30

    To ,onne,t ro8s toget!erK ust sti,/ t!e 8ire ends 8it!out insulation into t!e sMuare !oles%

  • 7/24/2019 Arduino Tutorial Lesson 3

    13/30

    =o8 is a good ti)e to 7ra,ti,e )a/ing u)7ersK go 'ort! and )a/e a 'e8 3N long u)7ers%

    Sa& !ello to t!e resistor%

    T!e resistor is t!e )ost basi, and also )ost ,o))on ele,troni, 7art* An ele,troni, gadgetK su,!as an )73 7la&er !as easil& a thousandresistors inside o' it%

    Behold...a resistor!

    +esistors !ae one ob to doK and t!at is to resistt!e 'lo8 o' ele,tri,it& ot!er8ise /no8n ascurrent* T!atJs 8!& t!e&Jre ,alled resistors* B& resisting ,urrent t!e& ,ontrol 8!ere and !o8'ast it 'lo8s*

    ;ne ,o))on 8a& o' t!in/ing about t!is is i' 8e 8ere tal/ing about 8ater ,urrentK t!en 7i7es areli/e resistors* T!in 7i7es let less 8ater t!roug! !ig! resistan,eK t!i,/ 7i7es let a lot o' 8atert!roug! lo8 resistan,e* .t! a 'ire !&drantK &ou 8ant lo8 resistan,e* .it! a 8ater 'ountainK&ouJd 8ant !ig! resistan,e* I' &ou )i:ed u7 t!e t8o 7i7e si9esK &ou 8ouldnt be able to 7ut out a'ire and &ouJd !urt &oursel' 8!ile tr&ing to get a drin/*

    +esistan,e is )easured in ohmsK o'ten 8ritten as t!e s&)bol * T!e bigger t!e resistan,e aluein o!)s t!e )ore it 'ig!ts* ost resistors&ouJll see range bet8een 1 o!) and 1 )egao!) 1*0

    http://hacks.mit.edu/Hacks/by_year/1991/fire_hydrant/http://en.wikipedia.org/wiki/Resistorhttp://en.wikipedia.org/wiki/Resistorhttp://hacks.mit.edu/Hacks/by_year/1991/fire_hydrant/http://en.wikipedia.org/wiki/Resistor
  • 7/24/2019 Arduino Tutorial Lesson 3

    14/30

    O* Sin,e t!e resistie ele)ent is inside a ,era)i, ,asingK its not 7ossible to tell t!e resistan,eo' a resistor ust b& loo/ing at it* @ouJll !ae to read it b& loo/ing at t!e ,olored stri7es on t!ebod& o' t!e resistor* T!is is /no8n as t!e resistor color codeK and its a real 7ain 8!en &ou 'irststart ele,troni,s* Eentuall& &ouJll get reall& good at telling t!e alue o' a resistor ust b& glan,ebut to start o'' &ouJll 8ant to use a re'eren,e ,!art* ;r &ou ,an use a )ulti)eter to )easure t!e

    resistan,e a,,uratel&li,/ !ere to ie8 a re'eren,e ,!art t!at &ou ,an 7rint outin ,olor and use as &our guide*T!ere are also 8ebsite ,al,ulators t!at &ou )a& 'ind er& !and&

    Remember:Cust be,ause t!e stri7es are in a ,ertain order doesnJt )ean t!e resistor !as adire,tion% +esistors are t!e sa)e 'or8ard and ba,/8ardsK it doesnt )atter 8!i,! 8a& t!e& areused*

    Quick quiz!

    What is the color code for a 5 "#$ resistor%

    Highlight the text below to see the answerBro8n - Bla,/ - +ed - old

    What is the color code for a 5 & resistor%

    Highlight the text below to see the answer

    +ed - +ed - Bro8n - old

    What is the value of this resistor%

    Highlight the text below to see the answer

    T!e stri7es are &ello8 4 - iolet - red Q 100 R 400 O R 4*O

    What ha''ens if you 'ut a resistor in backwards%

    Highlight the text below to see the answera% Tri,/ MuestionK it is not 7ossible to 7ut a resistor in Jba,/8ardsJ* T!e& 8or/ eit!er8a&%

    (ote on Wattages""""

    In all t!ese e:a)7lesK 8e use 1F4. resistors* >nless ot!er8ise noted &ou ,an use 1F16 . or1F2. or 8!ateer &ou ,an get &our !ands on* ig!er 8attage resistors are larger and usuall&)ore e:7ensieK but so)eti)es &our lo,al !obb& s!o7 8ill onl& !ae 1F2.*

    Sa& !ello to t!e LED%

    http://www.ladyada.net/learn/multimeter/resistance.htmlhttp://www.ladyada.net/learn/multimeter/resistance.htmlhttp://www.ladyada.net/images/metertutorial/rescolorcode.jpghttp://www.ladyada.net/images/metertutorial/rescolorcode.jpghttp://www.dannyg.com/examples/res2/resistor.htmhttp://www.ladyada.net/learn/multimeter/resistance.htmlhttp://www.ladyada.net/learn/multimeter/resistance.htmlhttp://www.ladyada.net/images/metertutorial/rescolorcode.jpghttp://www.ladyada.net/images/metertutorial/rescolorcode.jpghttp://www.dannyg.com/examples/res2/resistor.htm
  • 7/24/2019 Arduino Tutorial Lesson 3

    15/30

    .eJe !ad so)e ti)e 8it! t!e LED alread&K but lets get to /no8 !er a little better* T!e 8ordLED stands 'or )ight *mitting +iode* T!e lig!t-e)itting 7artK 8ellK t!at )a/es sense* .eJeused t!e LED to )a/e a blin/ing lig!t in lessons 1 and 2* T!e LED ,o)7onent turns ,urrent intolig!tK )u,! li/e an& sort o' lig!t bulb* But 8!at is t!is )&sterious diodeP

    A diodeis basi,all& a one-8a& street 'or ,urrent* I)agine su,! a one-8a& street 8it! a tra''i,7oli,e)an in 'ront* I' &ou 8ant to turn onto t!e street t!e 8rong 8a&K !e 8ill not let &ou*Li/e8ise t!e diode si)7l& does not let ,urrent go t!roug! it t!e 8rong 8a&* urrent in a diode,an onl& 'lo8 'ro) t!e 'ositiveside to t!e negativeside*

    I' &ou re,all 'ro) lesson 1K Arduino = users !ad to )a/e sure t!at t!e& inserted t!e LED in t!erig!t 8a&* I' &ou 7la,e t!e LED in ba,/8ards it 8onJt 8or/* Die,i)ila Arduino users alread&!ae t!e LED a er& er& s)all one soldered onto t!e ,ir,uit board t!e rig!t 8a&*

    Look again! Its a tiny LED

    As 8e )entioned be'oreK its eas& to 'igure out 8!i,! side o' an LED is 7ositie and 8!i,! one isnegatie* T!e 7ositie leg is slig!tl& longer and i' &ou loo/ insideK t!e ,!un/ o' )etal is larger ont!e negaie side*

    http://en.wikipedia.org/wiki/Diodehttp://www.ladyada.net/learn/arduino/lesson1.htmlhttp://en.wikipedia.org/wiki/Diodehttp://www.ladyada.net/learn/arduino/lesson1.html
  • 7/24/2019 Arduino Tutorial Lesson 3

    16/30

    Lig!t u7 )& breadboard

    .eJre going to no8 use t!e breadboard to lig!t u7 an LED* @ou 8ill need a breadboardK an LED

    and a 1*0 o!) resistor bro8n bla,/ red gold* I' &ou !ae a 7rotos!ieldK )a/e sure itsasse)bled 'irst*T!enK 7la,e t!e tin& breadboard on to7* @ou ,an re)oe t!e ba,/ing to sti,/ iton 8!i,! is 7er)anent or &ou ,an ust use double-sided ta7e* I' &ou !ae a regular breadboard&ouJll need 2 u)7er 8ires as 8ell*

    ,m'ortant (ote!

    .!ile LEDs 8ill not 8or/ 8!en 7la,ed ba,/8ardsK &ou donJt !ae to 8orr& about 8!et!er it8ill be da)aged as long as t!ere is a series resistor o' at least 100 o!)s ne:t to itK t!e LED 8illsurie t!e e:7erien,e%

    o8eerK using an LED 8it!out a series resistor is a sure-'ire 8a& to /ill it% @ouJll see a brig!t'las! and it )a& turn dar/-lwaysuse a resistor% A 1*0 o!) is a good 7la,e to start* .eJll ,oer !o8 to 'igure out t!e bestresistor alue later on*

    $la,e t!e resistor and LED as s!o8n* a/e sure t!e longer leg o' t!e LED is to t!e rig!tK,onne,ted to t!e resistor* T!e resistor doesnJt !ae a dire,tionK so it doesnt )atter 8!i,! 8a& itgoes in*

    http://www.ladyada.net/make/pshield/index.htmlhttp://www.ladyada.net/make/pshield/index.htmlhttp://www.ladyada.net/make/pshield/index.htmlhttp://www.ladyada.net/make/pshield/index.htmlhttp://www.ladyada.net/make/pshield/index.html
  • 7/24/2019 Arduino Tutorial Lesson 3

    17/30

    Click for a high resolution photo if necessary!

    I' &ouJre using a standard breadboardK &ouJll need to use 8ires to rea,! t!e Arduino* +un one8ire red to t!e 5.so,/et on t!e Arduino* +un t!e ot!er 8ire bla,/ to one o' t!e /(+so,/etson t!e Arduino* T!e ,olors arenJt essential but t!e& 8ill !el7 &ou re)e)ber 8!at t!e 8ires are,onne,ted to%

  • 7/24/2019 Arduino Tutorial Lesson 3

    18/30

    $lug in t!e ArduinoK &ou s!ould see t!e LED lig!t u7* I' notK ,!e,/ t!e 'ollo8ing

    Is t!e Arduino 7lugged inP loo/ 'or t!e little green lig!t on t!e Arduino as in lesson 0

    Is t!e LED in ba,/8ardsP Tr& 'li77ing it aroundK ust in ,ase* T!is 8ont da)age t!e

    LED*

    Are t!e 7arts 'ir)l& 7la,ed in t!e breadboardP Loose 7arts are a ,o))on breadboard

    7roble)K tr& iggling t!e) 8it! a 'inger and see i' it starts 8or/ing*

    Is t!e LED on and its ust er& di)P Tr& turning do8n t!e lig!ts or loo/ing at it !ead on

    so)e LEDs are er& dire,tional*

    Is t!e red 8ire going into t!e !ole labeled 5.P Is t!e bla,/ 8ire going into one o' t!e

    !oles labeled /(+P

    Tr& anot!er LED in ,ase t!is one is da)aged

    a/e sure t!e 7arts are as s!o8n in t!e i)age aboeK i' &ou !ae a 8ire in one ro8 and

    t!e resistor in t!e ot!erK t!e& arenJt ,onne,ted and it 8ont 8or/%

    S,!e)ing s,!e)ati,

    oora&K &ou ust built &our 'irst ,ir,uit% Its Muite si)7le but still 8ort! e:7laining*Basi,all& &ouJe ,onne,ted t!e LED and resistor in seriesone a'ter t!e ot!er to a 5< Jbatter&J*

  • 7/24/2019 Arduino Tutorial Lesson 3

    19/30

    T!e 7ositie 7in o' t!e LED is ,onne,ted to t!e 7ositie ter)inal o' t!e batter&K t!en t!e negatie7in is ,onne,ted to a resistor 8!i,! goes to t!e negatie ter)inal o' t!e batter&* T!e batter& issu77l&ing t!e ,urrent t!at 'lo8s t!roug! t!e LEDK )a/ing it lig!t u7*T!e 7ositie and negatie batte& ter)inals are o'ten ,alled t!e 'ower su''lyK as t!e& su77l&7o8er to our ,ir,uit* T!e 7ositie ter)inal is ,alled 'oweras t!ats 8!ere ,urrent 'lo8s 'ro)

    and t!e negatie ter)inal is ,alled groundK as it is 8!ere ,urrent 'lo8s to*

    Lets sa& &ou 8ant to NsaeN t!is design and send it to a 'riend to ,!e,/ out and build 'or!ersel'***one 8a& &ou ,ould do t!at is to ta/e a good 7!oto* But a better 8a& is to dra8 a 8iringdiagra)* T!en it 8ouldnJt )atter i' &our ,a)era 8asnJt er& good* A 8iring diagra) is also/no8n as a schematic* S,!e)ati,s are t!e standard )et!od 'or 7eo7le to trade in'or)ation about,ir,uits* Being able to read and 8rite s,!e)ati,s is a /e& s/ill% ere is a s,!e)ati, 'or a reall&big 7roe,tK a +oland TB-303 s&nt!esi9er ,lone

    Ea,! ele,troni, ,o)7onent !as a s,!e)ati, s&)bolK 8!i,! is a si)7li'ied dra8ing o' t!e 7art*(or resistors t!e s&)bol loo/s li/e t!is

    esistor sybol

    And t!e s&)bol 'or LEDJs loo/ li/e t!is

    LED sybol" positi#e pin on the left" negati#e pin on the right

    @ou ,an see t!at t!e resistor s&)bol is s&))etri,K ust li/e resistors t!e)seles* T!e LEDs&)bolK !o8eerK !as an arro8 t!ing going on* T!is is t!e dire,tion in 8!i,! ,urrent 'lo8s* T!elittle arro8s t!at are ,o)ing out o' t!e s&)bol indi,ate t!at t!is is a diode t!at e)its lig!t*

    $o8er and ground also !ae s&)bols

    $ower and %round sybols

    T!e onl& t!ing 8e need to do no8 is indi,ate !o8 t!e LED and resistor are !oo/ed u7 and s!o8t!e 5< and ground ,onne,tions*

    http://www.ladyada.net/media/x0xb0x/mainboard%20beta.jpghttp://www.ladyada.net/media/x0xb0x/mainboard%20beta.jpghttp://www.ladyada.net/media/x0xb0x/mainboard%20beta.jpghttp://www.ladyada.net/media/x0xb0x/mainboard%20beta.jpg
  • 7/24/2019 Arduino Tutorial Lesson 3

    20/30

    & barebones scheatic

    =e:t to s&)bolsK 8e o'ten 8rite i)7ortant in'or)ation li/e 8!at t!e resistor alue isK 8!at ,olorand si9e t!e LED s!ould beK and t!e oltage asso,iated 8it! t!e 7o8er su77l&*

    & well docuented scheatic!

    (or 7ra,ti,eK tr& dra8ing &our o8n s,!e)ati, on a 7ie,e o' 7a7er*

    A ui,/ +e8iring***

    .eJre going to )a/e a er& s)all )odi'i,ation to our 8ired u7 ,ir,uit

  • 7/24/2019 Arduino Tutorial Lesson 3

    21/30

    In our ne8 s,!e)ati,K instead o' ,onne,ting t!e resistor to "5< 7o8erK 8eJll ,onne,t it to ground*

    Be'ore &ou ,!ange &our breadboardK )a/e a guess o' 8!at 8ill !a77enWill the )*+ stay lit%Will the )*+ go out%

    0omething else%

    =o8 )a/e t!e ,!ange to &our breadboard

  • 7/24/2019 Arduino Tutorial Lesson 3

    22/30

    @ou 8ill noti,e t!atK in 'a,tK t!e LED !as gone out* T!at is be,ause it is no longer ,onne,ted to a7o8er sour,e and ,urrent is not 'lo8ing* B& ,onne,ting t!e resistor to "5< or groundK &ou ,anturn t!e LED on and o''* I' &ou 8ere er& 'ast at itK &ou ,ould )a/e t!e LED blin/%

    ))****

  • 7/24/2019 Arduino Tutorial Lesson 3

    23/30

    +e-isiting an old 'riend

    Start u7 t!e Arduino so't8are again and o7en u7 t!e 1y2links/et,! 'ro) lesson 2* I' &ou le't it8it! dela& ti)es o' 10)sK &ou )a& 8ant to )odi'& it so its ba,/ to 500)s on and 500)s o''*>7load t!e s/et,! to &our Arduino* =o8 ,!ange &our breadboard 8iring so t!at it )at,!es t!is

    s,!e)ati,*

    T!at isK instead o' ,onne,ting t!e resistor to 5< or groundK ,onne,t it to t!e Arduino 7in so,/etlabeled 13* I' &ou !ae an = ArduinoK &ouJll need to re)oe t!e old LED &ou usedK i' its still int!e so,/et*

  • 7/24/2019 Arduino Tutorial Lesson 3

    24/30

    @ou s!ould see t!e LED turn on and o''* I' &ou !ae a Die,i)ila ArduinoK bot! t!e on-boardLED and t!e 8ired LED 8ill blin/ in unison* Lets loo/ at t!at ,ode again

    void loop() // run over and over again

    {

    digitalWrite(ledPin, HIGH); // sets the LED on

    delay(!!); // "aits #or a se$ond

    digitalWrite(ledPin, L%W); // sets the LED o##

  • 7/24/2019 Arduino Tutorial Lesson 3

    25/30

  • 7/24/2019 Arduino Tutorial Lesson 3

    26/30

    T!e LED isnJt be blin/ing an&)ore% Lets 'i: it%o ba,/ to t!e beginning o' t!e s/et,! and 'ind t!is line again

    int ledPin ' ; // LED $onne$ted to digital pin

    T!is is t!e line o' ,ode t!at indi,ates 8!i,! 7in is ,onne,ted to t!e LED* !ange it so t!at it isno8 ,onne,ted to 7in 12

  • 7/24/2019 Arduino Tutorial Lesson 3

    27/30

    int ledPin ' *; // LED $onne$ted to digital pin * no"+

    +e-,o)7ile and eri'& t!e s/et,!K t!en send it oer t!e t!e Arduino* T!e LED s!ould no8 beblin/ing again* =ote t!at i' &ou !ae a Die,i)ila Arduino &ou 8ill not see an& blin/ing on t!eon-board LED* T!ats be,ause its ,onne,ted to 7in 13 onl&%

    *6ercises!

    0'end some time e6'erimenting with different 'ins"onne,t t!e LED to di''erent 7in

    so,/etsK and )odi'& t!e s/et,! so t!at t!e LED blin/s*

    7hange around your wiring so that it matches this schematic

    a/e sure to )odi'& &ou s/et,! so t!at t!e led3inis 13 again* +e-,o)7ile and u7load itto t!e Arduino* .!at does t!e LED doPHighlight the text below to see the answerIt blin/s ust li/e be'ore,f you have a +iecimila -rduino8 what do you notice about the breadboard )*+ and

    the on9board )*+%

    Highlight the text below to see the answer

    T!e& are alternating 8!en t!e& blin/Why do you think that is%

    Highlight the text below to see the answer.!en t!e 7in is L;. ,onne,ted to ground t!e breadboard LED is on ,urrent is'lo8ing 'ro) "5< to ground t!roug! t!e 7in* .!en t!e 7in is I ,onne,ted to "5

  • 7/24/2019 Arduino Tutorial Lesson 3

    28/30

    ; sure &ouJe !ad 7lent& o' 7ra,ti,e )essing around 8it! LEDs* ItJs ti)e to go 'ull ,olor% (inda redK green and blue LED* I' &ou !ae t!e Arduino Starter $a,/ t!e& 8ill be t!e t!ree ,learLEDs* @ou ,anJt tell 8!i,! one is 8!i,! until t!e& are lit so ust build t!e ,ir,uit and t!enrearrange t!e) i' needed*

    ed" green and blue LED scheatic

    In t!is s,!e)ati, 8e 8ill !ae t!ree LEDs ,onne,ted to t!ree di''erent 7ins #10K #11 and #12*

  • 7/24/2019 Arduino Tutorial Lesson 3

    29/30

    o ba,/ to &our s/et,! and ,!ange it so it loo/s li/e t!is

    int redPin ' *; // ed LED $onne$ted to digital pin *

    int greenPin ' ; // Green LED $onne$ted to digital pin

    void setup() // run on$e, "hen the s-et$h starts

    {

    pin.ode(redPin, %0P0); // sets the digital pin as output

    pin.ode(greenPin, %0P0); // sets the digital pin as output&

    void loop() // run over and over again

    {

    digitalWrite(redPin, HIGH); // sets the ed LED on

    digitalWrite(greenPin, HIGH); // sets the Green LED on

    delay(!!); // "aits #or hal# a se$ond

    digitalWrite(redPin, L%W); // sets the ed LED o##

  • 7/24/2019 Arduino Tutorial Lesson 3

    30/30