[PDF] Introduction to Arduino



Previous PDF Next PDF







Arduino - Tutorials

Arduino Booklet ( pdf ): an illustrated guide to the philosophy LED as light sensor (en Francais) Arduino and the Asuro robot Using Arduino from the command line



Zumo Pololu Guide utilisateur du Robot

Arduino qui disposent du même Form Factor qu'un Arduino Uno (comme le Duemilanove par exemple) Le shield est monté directement sur le châssis, connecté directement sur les moteurs, les connecteurs du bloc pile et l'Arduino vient se connecter sur les connecteurs mâles du shield Zumo (face vers le bas)



Arduino Projects Book - WordPresscom

Arduino can make your projects responsive, but only you can make them beautiful We’ll provide some suggestions along the way as to how you might do that Arduino was designed to help you get things done To make that happen, we kept the background material on programming and electronics to a minimum If you



Introduction to Arduino

LED blinking once a second (The “L” LED is on the Arduino directly behind the USB connection) 1 3 The Integrated Development Environment (IDE) You use the Arduino IDE on your computer (picture following) to create, open, and change sketches (Arduino calls programs “sketches” We will use the two words interchangeably in this book )



THE 37 SENSOR KIT TUTORIAL

This 37 Sensor Kit is suitable for Arduino Uno, Arduino Mega 2560, Arduino Duemilanove and Arduino Nano All the code in this user guide is also compatible with these boards Our Arduino board is fully compatible with Arduino This kit walks you through the basics of using the Arduino board in a hands-on way You'll



Arduino Cheat Sheet-final-01 - dlnmh9ip6v2uccloudfrontnet

Title: Arduino_Cheat_Sheet-final-01 Created Date: 6/22/2011 3:35:13 PM



Arduino Nano - Farnell

Arduino Nano Arduino Nano Front Arduino Nano Rear Overview The Arduino Nano is a small, complete, and breadboard-friendly board based on the ATmega328 (Arduino Nano 3 0) or ATmega168 (Arduino Nano 2 x) It has more or less the same functionality of the Arduino Duemilanove, but in a different package



The Arduino Mega 2560 is a microcontroller board based on the

The Arduino Mega 2560 is a microcontroller board based on the ATmega2560 (datasheet) It has 54 digital input/output pins (of which 14 can be used as PWM outputs),



EasyVR

and Arduino boards Some application examples include home automation, such as voice controlled light switches, locks or beds, or adding “hearing” to the most popular robots on the market EasyVR features A host of built-in Speaker Independent (SI) commands for ready to run basic controls, in the followings languages:

[PDF] arduino language reference

[PDF] reference arduino francais pdf

[PDF] arduino pour les nuls pdf download

[PDF] arduino pour les nuls pdf gratuit

[PDF] programmation arduino pour les nuls pdf

[PDF] comment dessiner un cube sur papier

[PDF] patron d'un rectangle avec languette

[PDF] patron d'un parallélépipède rectangle

[PDF] construire un parallélépipède rectangle

[PDF] cylindre face arête sommet

[PDF] nombre d'arête d'un cone

[PDF] solides faces arêtes sommets

[PDF] face arête sommet exercices

[PDF] qu'est ce qu'une arête en géométrie

[PDF] solide 8 faces 12 sommets 18 aretes

IntroductiontoArduino

Apieceofcake!

byAl anG.Smith

September30,2011

CoverPhotoCred it:ArduinoCake

Copyright©2011AlanG.Smith.

AllRight sReserved.

Cakemadeb yLisaSmithan dfamily

IntroductiontoArduino:Apieceofca ke!

Copyright©2011AlanG.Smith.AllR ight sR eserve d. Theauth orcanbecontactedat :alan@introtoarduino.com Thehar dcopyofthebookcanbepurch asedfr omhttp://www.amazon.com Themost recentPDFis freeathttp://www.introtoarduino.com

ISBN:14636983 48

ISBN-13:978-1463698348

Thisbookisded icatedt o:

Myw ifewhofirsten couragedmet oteachthiscla ssand

thenputup withmyspen dingco untlesshou rsonth isbook andalsohe lpedwit hnumerouscommen tsonthefir st proof.

Mychi ldrenwhoexcitemeaboutt eaching.

Myfa therwhospentmanyho urswithmeo ntheVic20,

Commodore64,andtheroboticarms cien ceproj ect.

Withouthisinvestmen t,Iwould n'tbetheengineerIam

today.

Allwhow oulddesire tomakesomething, maythisbook

helpyouwit hyourinventi ons. Whateveryoudo,worka titwithall yourhear t,asworkingfo r theLo rd,notformen.

Colossians3:23(NIV1984)

Contents

1GettingStarted1

1.1Whatis aMicrocontrol ler?.. ... ..................1

1.2Inst alltheSoftware.... ........ ...............3

1.3TheI ntegratedD evelopmentEnvironment(IDE).. ........5

1.4Ourfirst circuit.. ......... ..................7

1.5Updat edCircuit............ ........... ... ... 9

1.6OurF irstPro gram......... ................. .9

1.7Comme nts................. ... ... ... .. ... .12

1.8Gotc has............... ... ... ... ... ... ... .13

1.9Exer cises................... ... ... ... ... ..14

2MakingLightPatterns17

2.1"Blinky ".............. .. ... ... ... ... ... ..17

2.2IFSt atement s......................... ... ..17

2.3ELSE Statements... .........................20

2.4WHIL Estatements..... ......................21

2.5What istruth(tr ue) ?...........................22

2.6Combin ations................... ... ... ... ..24

2.7FORst atemen ts........................ ... ..25

2.8OurNe wCircuit ......... ............ .. ... ..26

2.9Intr oducingArrays.................. .........29

2.10Exer cises................... ... ... ... ... ..31

3Input33

3.1Push buttons........................ ... ... .33

3.2Pot entiometers............................ ..41

3.3RGBL EDs...... ............ .. ... ... ... ... 46

v

Contents

3.4Exe rcises................... .. ... ... ... ... 49

4Sound51

4.1OurCirc uit.... ........... ... ... ... ... ... ..51

4.2Simple note........ ........... ... ... ... ... 52

4.3Music.. ........... ... ... ... ... ... .. ... ..5 3

4.4Musicwi thfunctions. ........... ..............55

4.5Exer cises................... ... ... ... ... ..58

5Makingadigitalthermometer59

5.1Serial Monitor............ ................. .59

5.2Measuri ngthetemperature....... ......... ......62

5.3Hook inguptheLCD......... ..... ......... ...66

5.4Talkin gtotheLCD.... ...... ........ ...... ... 68

5.5Bring ingitalltogether..... ... ... ..............71

5.6Exer cises................... ... ... .. ... ... 73

6Graphics(Pictures)onourLCD75

6.1Binary andHex...... ...... ......... .. ... ... 75

6.2Using graphics...... ................. ... ... .77

6.3Makinga Chart.......... ... .............. ..8 2

6.4Exe rcises................... .. ... ... ... ... 89

7SensorsGalore91

7.1Intr oduction......................... ... ... 91

7.2Phot oCell(LightSensor) ..... ............... ....91

7.3TiltSe nsor.. ................. ... ... ... ... .93

7.4ReedSw itch(Magnetic FieldDetector)... .............95

7.5PiezoE lement(Vibr ationsensor)....... ............96

7.6Exer cises................... ... ... ... ... ..98

8Makingarubberbandgun99

8.1OneSe rvo... .............. ... ... ... ... ... 99

8.2Joys tick.................. .. ... ... ... ... ..101

8.3Pan/T iltbracket........ ................. ... .103

vi

Contents

8.4Addin gafiringmechanism... ... ........... .....106

8.5Exer cises................... ... .. ... ... ... 110

9Makeyourownproject!111

10N extSteps113

AArduinoReference115

A.1Str ucture................. ... ... ... ... ... .11 6 A.2Va riables................... ... ... ... ... ..1 20 A.3Fu nctions................... ... ... ... ... ..1 21 A.4PC D8544(LCDController)L ibrary..... .............125

BPartsinKit127

B.1Firstu sedinChapter 1..... ..... ...............127 B.2Firstu sedinChapter 2..... ...... ..............127 B.3Firstu sedinChapt er3.... ...... ...............12 8 B.4Firstu sedinChapt er4.... ...... ...............12 8 B.5Firstu sedinChapter 5..... ..... ...............128 B.6Firstu sedinChapter 6..... ...... ..............128 B.7First usedinChapt er7.... ...... ...............12 8 B.8Firstu sedinChapt er8.... ...... ...............12 9

CSampleSolutionstoSelectedExercises131

C.1Chapte r1Solutions...... ... ..................131 C.2Chapt er2Solutions..... ... ...................134 C.3Chapte r3Solutions..... ... ...................135 C.4Chapte r4Solutions...... .. ...................140 C.5Chapte r5Solutions...... ... ..................144 C.6Chapt er6Solutions..... ... ...................149 C.7Chapte r7Solutions..... ... ...................156 C.8Chapte r8Solutions...... .. ...................160 vii

Listings

1.1Simple stProgram......... ................. ..9

1.2led1/le d1.pde..................... ... ... ... 10

1.3Blink/ Blink.pde......................... ... .12

2.1blink_if /blink_if.pde..........................17

2.2blink_e lse/blink_else.pde.......................20

2.3blink_w hile/blink_while.pde.....................21

2.4blink_f or/blink_for.pde........................25

2.5lightP attern1/lightPattern1.pde....................28

2.6lightP attern1b/lightPattern1b.pde..................29

3.1butt on1/button1.pde..........................35

3.2butt on2/button2.pde..........................39

3.3Const rain............... ... ... ... ... ... ... 40

3.4pot1/ pot1.pde......................... ... ..42

3.5pot2/ pot2.pde......................... ... ..44

3.6pot3/ pot3.pde......................... ... ..44

3.7rgb_3p ot/rgb_3pot.pde........................48

4.1sou nd_simple/sound_simple.pde..................52

4.2soun d_2/sound_2.pde.........................54

4.3soun d_3/sound_3.pde.........................56

4.4soun d_array/sound_array.pde....................57

5.1blink_if _serial/blink_if_serial.pde..................59

5.2temp _serial/temp_serial.pde.....................63

5.3lcd1/lc d1.pde..................... ... ... ... 69

5.4temp _lcd/temp_lcd.pde........................71

ix

Listings

6.1temp _lcd_graphic/temp_lcd_graphic.pde..............79

6.2temp _lcd_graphic_chart/temp_lcd_graphic_chart.pde......83

7.1phot ocell/photocell.pde........................92

7.2tiltse nsor/tiltsensor.pde........................94

7.3reed 1/reed1.pde............................. 95

7.4knoc k1/knock1.pde...........................97

8.1serv o1/servo1.pde...........................100

8.2joys tick/joystick.pde..........................102

8.3pantilt /pantilt.pde...........................104

8.4rub berBandGun/rubberBandGun.pde................108

x

Chapter1

GettingStarted

Thepurp oseofthisbookistoget yousta rtedonthero adtocreatingthings usingmicro-c ontrollers.Wewilldiscussonlyenoughelectronicsforyouto makethecir cuits,and onlyenoughprogrammingforyouto getstarted.The focuswillbeony ourmakingthin gs .Itismy hopethatasyo ugothroughthis bookyouwil lbefloodedw ithideasofth ing sthatyoucanmake .Sole t'sget going...

Thefirstque stionwe'l lstartwithis:

1.1Whati saMicrocontr oller?

Wikipedia

1 says: cuitcontain ingaprocessorcore,memory,and pro grammablein- put/outputperipherals allco mputershave)andmemory,andsome input/outputp insthatyouc an control.(oftencalledGPI O-GeneralPurposeIn putOutputPins). 1 1

Chapter1GettingStar ted

Forthis book,wewillb eusingtheArdui noUnob oard.Thiscom binesa micro-controlleralongwithalloftheextrastomak eiteasyforyout obuild anddebu gyourprojects. Wewi llbeusingabr eadboa rdinthisbook.T his isarelativelyeasyway toma kecircuitsqui ckly.Breadboardsarema defordoingquickex periments. Theyarenotknownfork eepingci rcuitstogetherf oralongti me.Whe nyouare readytomakeap rojectt hatyouwantt ost ayaroundforawhile,youshould consideranalternativeme thodsu chaswire-wrappingorsolderingoreven makingaprintedc irc uitboard(PCB). Thefirstthi ngyoushou ldnoticeaboutt hebreadbo ardisallofthehole s. Thesearebroke nupinto2s etsofcolumnsandas etofro ws(therowsare 2

1.2Inst alltheSoftware

dividedinthemi ddle).The columnsar enameda,b,c,d,e,f ,g,h,i,andj(from lefttoright ).Ther owsarenumbered1-30.( fromtopto bottom).T hecolumns onthe edges donothavelettersorn umbers . Thecolu mnsontheedgesareconn ectedf romtopto bottominsideof the breadboardtomakeiteasytosu pplypo werandgro und.(Y oucanthinkof groundasthenegati vesideof abatteryan dthepowerasthepositiveside.)

Forthi sbookourpower willbe+5volt s.

Insideofthebreadboa rd, theholes ineachrowareconnectedupto thebre ak inth emiddleofth eboard.ForEx ample:a1,b 1,c1,d1,e1allh aveawire insid e ofthe breadb oardtoconnectthem.Thenf1,g1,h1 ,i1 ,andj1areal lconnecte d. buta1is notco nnecte dtof1.This maysoundconfusingnow,butitwillquickly cometomake sensea swewireupcir cuits.

1.2Install theSoftware

Ifyou haveac cesstotheintern et,therearestep-by-ste pdi rectionsandthesoft- wareavaila bleat:http://arduino.cc/en/Main/Software

Otherwise,theUSBstickinyourk it

2 hastheso ftware undertheSoftware Directory.Therearetwodire ctoriesundertha t.Oneis"W indows"andthe otheris"MacOSX" .Ifyou areinstal lingo ntoLinux, youwil lneedto follo w thedire ctionsat:http://arduino.cc/en/Main/Software

1.2.1Window sInstallations

1.Plu ginyourbo ardv iaUSBandwaitforW indowstobegin itsdriver

installationprocess.Afte rafewmoments,theprocess willfail.(Thisis notunexpe cted.)

2.Clic kontheStartMenu, andop enuptheCo ntrolPanel.

3.Wh ileintheContr olP anel,navigate toSystemandSecurity.Ne xt,click

onSyst em.OncetheSystemwind owisup,opent heDeviceMa nager. 2 Thisbookwasor iginal lywrittent ogoalongwithaclass.Ifyouha vethebook,butn otthe kitgotohttp://www.introtoarduino.comformor einformationa ndallofthesource codeinthis book. 3

Chapter1GettingStar ted

4.Lo okunderPorts (COM&LPT).Yousho uldseeanopenportn amed

"ArduinoUNO(COMxx)".

5.Righ tclickonthe"Ar duinoUNO(COMxx)" porta ndchooset he"Update

DriverSoftwar e"option.

6.Ne xt,choosethe"Br owsemycomputerfor Driversoft ware"option.

7.Fina lly,navigatetoandselect theUno'sdriverfile,named"ArduinoUNO.inf",

locatedinthe"Driver s"f olderofthe ArduinoSoftwaredownload(not the "FTDIUSBDrive rs" sub-directory).

8.Wind owswillfinishupthedriv erinstallati onfromthere.

9.Do uble-clicktheArduinoapplication.

10.Ope ntheLEDblin kexampleske tch:File>E xamples>1.Bas ics>Blink

11.Se lectArduinoUnoun dertheTools>Boardme nu.

12.Se lectyourserialpor t(ifyoudon'tk nowwhichone, disconnecttheUNO

andthee ntrythatdis appearsistherighto ne.)

13.Click theUplo adbutton.

14.A fterthemessage"Do neuploading" appears,youshouldseeth e"L"

LEDb linkingonceasecond.(The"L "LEDisontheAr duin odirectly behindtheUSBport .)

1.2.2MacInstal lation

1.Con necttheboardviaUSB.

2.Dr agtheArduin oapplicationon toyourharddrive.

3.Wh enNetworkPr eferencescomesup,jus tclick"Apply"(rememberthe

/dev/tty/usb.)

4.S tarttheprogram .

4

1.3TheI ntegratedD evelopmentEnvironment(IDE)

5.Ope ntheLEDblin kexampleske tch:File>E xamples>1.Bas ics>B lin k

6.S electArduinoUnoun dertheTools>Boardme nu.

7.Se lectyourserialpor t(ifyoudon'tk nowwhichone, disconnecttheUNO

andthee ntrythatdis appearsistherighto ne.)

8.Click theUplo adbutton.

9.A fterthemessage"Do neuploading" appears,youshouldseethe"L"

LEDbl inkingonceasecond.(The"L "LEDisontheArdu ino directly behindtheUSBconn ection)

1.3TheI ntegratedDevelopm entEnvironment (IDE)

Youuset heArduino IDEonyou rcomputer(picturefoll owing)tocr eate,open, andchang esketches(Ardu inocallsprograms"sketches".Wewillusethet wo wordsinterchan geablyinthisbook.).Sketchesdefinewhattheboardwilldo. Youcane itheruset hebuttonsalongthe topoftheI DEortheme nuit ems. 5

Chapter1GettingStar ted

PartsoftheID E:(fro mleftt oright,toptob ottom)

tobeconver tedintoinstructionsthattheboardunderstands.Th isprocess iscalle dcompiling. andyoup robablywon' thaveaneedtoeither. ) •Op enExistingSk etch-Thisloadsasketchfr omafileonyourcomputer. 6

1.4Ourfirst circuit

•UploadtoBoard-ThiscompilesandthentransmitsovertheUSBca ble toyou rboard. •S erialMonitor-Wewill discussthisinsect ion 5.1. •T abButton- Thisletsyoucreatem ul tiplefilesinyo ursketch.Thisisfor moreadvanc edprogrammingthanwewilldo inthisclass. alsowher eerrormessagesdis playifyoumakeamistak eintypingyour program.(oftencalleda syntaxerror) •LineNumber-Thisshowsyouwhatlinenumberyourcursorison.It is usefulsinceth ecompilergivese rrormessa geswithalinenumber

1.4Ourfi rstcircuit

Beforewegettothe program min g,let's connectanLED .LEDstandsforLig ht EmittingDiode.Adiodeonlya llowselectrici ty toflowthro ughit oneway ,so ifyo uhookitupb ackwardsitwon't wo rk. Ifyou connect theLEDdirectlytopoweran dgroun d,toomuchcurrentwillquotesdbs_dbs15.pdfusesText_21