intel galileo essentials -...

Post on 13-Dec-2018

240 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

IntelGalileoEssentials

TableofContents

IntelGalileoEssentials

Credits

AbouttheAuthor

AbouttheReviewers

www.PacktPub.com

Supportfiles,eBooks,discountoffers,andmore

Whysubscribe?

FreeaccessforPacktaccountholders

Preface

Whatthisbookcovers

Whatyouneedforthisbook

Whothisbookisfor

Conventions

Readerfeedback

Customersupport

Downloadingthecolorimagesofthisbook

Errata

Piracy

Questions

1.GettingStartedwiththeGalileo

UnpackingandconnectingtheGalileo

DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachine

DownloadingthesoftwareandconnectingtheGalileotoaMac

DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachine

RunningtheIDEfortheGalileo

SettingtheIDEtoconnecttoyourboard

SelectingtheproperCOMportforWindows

SelectingtheproperCOMportfortheMac

SelectingtheproperCOMportforaLinuxMachine

Updatingthefirmware

OpeninganduploadingafiletotheGalileo

AccessingtheGalileo’sLinuxcapabilities

Summary

2.AccessingtheGPIOPins

TheGPIOcapabilityoftheGalileo

UsingtheGPIOpins

Connectingyourfirstexternalhardware

Pluggingyourwiresintothebreadboard

Settinguptheelectronics

TheIDEandLEDCode

Gettingsignalsfromtheoutsideworld

InterfacingdigitalinputsignalswithGalileo

InterfacinganaloginputsignalswithGalileo

Summary

3.AddingDisplayFunctionality

Thesimpleserialdisplay

EnablingtheserialdisplayintheIDE

TheTFTshield

AccessingthedisplaywiththeIDE

Summary

4.ControllingDCMotors

DCmotorbasics

ConnectingaDCmotordirectlytotheGalileo

GalileocodeforDCmotorspeedcontrol

ConnectingaDCmotorusinganH-bridgeandtheGalileo

GalileocodeforDCmotordirectioncontrol

ControllingDCmotorsusingashield

GalileocodefortheDCmotorshield

Summary

5.AddingSensors

Sensingdistance

TheInfraredsensor

ConnectinganIRsensortotheGalileo

AccessingtheIRsensorfromtheGalileoIDE

ConnectingadigitalcompasstotheGalileo

AccessingthecompassfromtheIDE

ConnectinganaccelerometerorgyrototheGalileo

AccessingtheaccelerometerfromtheIDE

Connectinganaltimeter/pressuresensortotheGalileo

Accessingthealtimeter/pressureSensorfromtheGalileoIDE

Summary

6.RemoteControl

ConnectinganXBeeinterfacetotheGalileo

ConfiguringtheXBeedevices

EnablinganXBeeInterfaceintheIDE

ConfiguringaWi-FiconnectionontheGalileo

UsingWi-FifromtheIDE

Summary

7.GoingFurtherwithGalileo

TheGalileoandLinux

CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

Buildingrobotsthatcanwalk

Howservomotorswork

Buildingthequadrupedplatform

Usingaservocontrollertocontroltheservos

CommunicatingwiththeservocontrollerviaaPC

ConnectingtheservocontrollertotheGalileo

CreatingaprograminLinuxsothatyoucancontrolyourquadruped

Summary

8.SpeechOutput

Hookingupthehardwaretomakeaninputsound

Usinganapplication

UsingEspeaktoallowourprojectstorespondinarobotvoice

Summary

Index

IntelGalileoEssentials

IntelGalileoEssentialsCopyright©2015PacktPublishing

Allrightsreserved.Nopartofthisbookmaybereproduced,storedinaretrievalsystem,ortransmittedinanyformorbyanymeans,withoutthepriorwrittenpermissionofthepublisher,exceptinthecaseofbriefquotationsembeddedincriticalarticlesorreviews.

Everyefforthasbeenmadeinthepreparationofthisbooktoensuretheaccuracyoftheinformationpresented.However,theinformationcontainedinthisbookissoldwithoutwarranty,eitherexpressorimplied.Neithertheauthor,norPacktPublishing,anditsdealersanddistributorswillbeheldliableforanydamagescausedorallegedtobecauseddirectlyorindirectlybythisbook.

PacktPublishinghasendeavoredtoprovidetrademarkinformationaboutallofthecompaniesandproductsmentionedinthisbookbytheappropriateuseofcapitals.However,PacktPublishingcannotguaranteetheaccuracyofthisinformation.

Firstpublished:February2015

Productionreference:1180215

PublishedbyPacktPublishingLtd.

LiveryPlace

35LiveryStreet

BirminghamB32PB,UK.

ISBN978-1-78439-890-3

www.packtpub.com

CreditsAuthor

RichardGrimmett

Reviewers

AustinHughes

AlanPlotko

JasonWright

CommissioningEditor

AshwinNair

AcquisitionEditor

SamWood

ContentDevelopmentEditor

MohammedFahad

TechnicalEditor

NaveenkumarJain

CopyEditors

NehaKarnani

MerilynPereira

ProjectCoordinator

PuravMotiwalla

Proofreaders

StephenCopestake

PaulHindle

Indexer

RekhaNair

ProductionCoordinator

ShantanuN.Zagade

CoverWork

ShantanuN.Zagade

AbouttheAuthorRichardGrimmetthasalwaysbeenfascinatedbycomputersandelectronicsfromhisveryfirstprogrammingprojectthatusedFortranonpunchcards.Hehasabachelor’sandmaster’sdegreeinelectricalengineeringandaPhDinleadershipstudies.Healsohas26yearsofexperienceinelectronicsandcomputers.HepossessesoneoftheoriginalbrickphonesaswellasaGoogleglass.HenowteachescomputerscienceandelectricalengineeringatBrighamYoungUniversity-Idaho,wherehisofficeisfilledwithhismanyroboticsprojects.

Iwouldcertainlyliketothankmywife,Jeanne,andfamilyforprovidingmewithawonderful,supportiveenvironmentthatencouragesmetotakeonprojectslikethis.Iwouldalsoliketothankmystudents;theyshowmethatamazingthingscanbeaccomplishedbythosewhoareunawareofthebarriers.

AbouttheReviewersAustinHughesisasoftwareengineerwithaninterestinmicrocontrollers,embeddedsystems,androbotics.

AlanPlotkoisatechnologyenthusiastwithexperienceindevelopingacrossthefullstack.Hewasfirstexposedtoprogrammingattheageof9whenhediscoveredtheviewsourcecodeoptioninhisbrowser.Codingthenquicklyturnedintoahobby;thisledtohisstudyingcomputerscienceattheuniversitylevel.AlanlovesdevelopingapplicationsfortheWebandalwaysmakestimetoattendhackathons,whicharetypicallyweekend-longprogrammingcompetitionswhereparticipantsbuildprojectsfromscratchtobenefitthecommunity.Alan’sexperienceextendstoPythondevelopment,variousdatabasetechnologies,includingNoSQL,andframeworksforrapidapplicationdevelopment.Whenhe’snotwritingcode,Alanspendshistimewritingstories;heisanavidwriter,havingpreviouslyself-publishedafantasynovel.

JasonWrightisahardwareengineerinIntel’sNewDevicesGroup,whereheworksonprojectsintheareaoflow-powerembeddedandwearablecomputing.Previously,heworkedonGalileo-basedurbansensingdeviceswithinIntelLabsEurope.JasonreceivedhisBSandMEngdegreesinelectricalandcomputerengineeringfromCornellUniversityin2012and2013.

Jasonwouldliketothankhisfamilyandfriendsfortheircontinuedloveandsupport.

www.PacktPub.com

Supportfiles,eBooks,discountoffers,andmoreForsupportfilesanddownloadsrelatedtoyourbook,pleasevisitwww.PacktPub.com.

DidyouknowthatPacktofferseBookversionsofeverybookpublished,withPDFandePubfilesavailable?YoucanupgradetotheeBookversionatwww.PacktPub.comandasaprintbookcustomer,youareentitledtoadiscountontheeBookcopy.Getintouchwithusat<service@packtpub.com>formoredetails.

Atwww.PacktPub.com,youcanalsoreadacollectionoffreetechnicalarticles,signupforarangeoffreenewslettersandreceiveexclusivediscountsandoffersonPacktbooksandeBooks.

https://www2.packtpub.com/books/subscription/packtlib

DoyouneedinstantsolutionstoyourITquestions?PacktLibisPackt’sonlinedigitalbooklibrary.Here,youcansearch,access,andreadPackt’sentirelibraryofbooks.

Whysubscribe?FullysearchableacrosseverybookpublishedbyPacktCopyandpaste,print,andbookmarkcontentOndemandandaccessibleviaawebbrowser

FreeaccessforPacktaccountholdersIfyouhaveanaccountwithPacktatwww.PacktPub.com,youcanusethistoaccessPacktLibtodayandview9entirelyfreebooks.Simplyuseyourlogincredentialsforimmediateaccess.

PrefaceOverthelastfewyears,anumberofimportanttechnologicaltoolshavebeenintroducedthathaveenabledthemigrationofcomplexelectronicsprojectsfromtheUniversityorGovernmentLabtoalmostanyone’sprojectdesk.TheGalileo,aninexpensiveprocessorsystembyIntel,isanexampleofoneofthesetoolkits.Thissmall,inexpensive,butpowerfulboardcanbeusedinawiderangeofprojects.

Butjustasimportantasthehardwareisthecommunityofdeveloperswhonotonlyprovidehelpintheareaofsoftwaredevelopment,butalsoprovidehardwareadd-onsfortheprocessorboarditself.Still,itcanbeabitintimidatingtostartusingGalileotobuildyourveryownprojects.

Thisbookisdesignedtohelpanyone,eventhosewithnoprogrammingbackgroundorexperience,tobesuccessfulinbuildingbothsimplebutalsoquitecomplexprojects.Itwillleadyouthroughtheprocessstepbystepsothatyourprojectdesignscancometolife.Hopefully,thisbookwillinspirethosewiththeimaginationandcreativespirittobuildthosewildlyinventivedesignsthatwillrevolutionizetheworld!

WhatthisbookcoversChapter1,GettingStartedwiththeGalileo,beginswithadiscussionofhowtoconnectpowerandendswithafullsystem,configuredandreadytobeginconnectingamazingdevicesandSWcapabilitiestofulfillalmostanyproject.

Chapter2,AccessingtheGPIOPins,showsyoutohowtoaccessthesepins,bothinputandoutput,soyoucandoallsortsofamazingthings.Oneofthecapabilitiesyou’llneedtocompleteyourprojectsisabasicknowledgeofhowtoaccesstheGPIOpinssothatyoucanaccessallsortsofadditionalhardwarecapabilities.

Chapter3,AddingDisplayFunctionality,showsyouhowtheGalileocanbeconnectedtoadisplaysothatyoucanbothseeoutputandalsogetinputfromatouchscreen.OneofthefirstthingsyoumightwanttodoistoconnectadisplayuptotheGalileo.

Chapter4,ControllingDCMotors,detailshowtocontrolaDCmotorsothattheunitcandrivewheelsortracks.

Chapter5,AddingSensors,showsyouhowtoaddIR,Sonar,andevenacompasstoyourproject.

Chapter6,RemoteControl,covershowtocommunicatewirelesslywithyourGalileoprojects,asyoumaywanttoaccessyourprojectswithoutconnectingwires.

Chapter7,GoingFurtherwithGalileo,introducesyoutotheLinuxcapabilitiesoftheGalileousingtheexampleofconstructingaquadrupedrobot.

Chapter8,SpeechOutput,covershowtomakeyourprojecttalkasanexampleofhowtousefree,opensourcesoftwaretoaddcomplexfunctionalitytoyourprojects.Oneoftheamazingfeaturesoftoday’scomputersystemsistheabilitytoprovideoutputwithoutascreenorkeyboard.

WhatyouneedforthisbookThemostimportantpieceofsoftwarerequiredforthefirstsixchaptersofthebookistheGalileoIDE,whichisavailableathttps://communities.intel.com/docs/DOC-22226.Theonlyothersoftwarethatwillberequiredforthesechaptersisthesoftwaredriversassociatedwiththehardwarethatyoumightaddtoyourproject;thesewillbedetailedintheindividualchaptersthemselves.

ForChapter7,GoingFurtherwithGalileo,you’llneedtodownloadaversionofDebianLinuxavailableathttps://communities.intel.com/message/231688.ToburntheimagetoanSDcard,you’llneedWin32DiskImageavailableathttp://sourceforge.net/projects/win32diskimager/.You’llalsoneedaterminalemulatorprogram;PuTTYisonesuchprogram,availableathttp://www.chiark.greenend.org.uk/~sgtatham/putty/.Finally,you’llneedacontrolprogramforservos,availableatwww.pololu.com/docs/0J40/3.b.

ForChapter8,SpeechOutput,you’llneedafree,opensourcesoftwarepackagecalledEspeakthatisavailablebyusingthecommandsudoapt-getinstallespeak.

WhothisbookisforThisbookisforanyonewithalittleprogrammingskill,abitofimagination,andthedesiretocreatetheirowndazzlingprojects.ThebookisdesignedtostartbyteachingbeginnersthebasicsofGalileoandhowtoprogramit.You’lltacklemoreandmorechallengingprojectsuntilyouhavetheknow-howtobuildyourownamazingprojects.

ConventionsInthisbook,youwillfindanumberofstylesoftextthatdistinguishbetweendifferentkindsofinformation.Herearesomeexamplesofthesestyles,andanexplanationoftheirmeaning.

Codewordsintext,databasetablenames,foldernames,filenames,fileextensions,pathnames,dummyURLs,userinput,andTwitterhandlesareshownasfollows:“Thiswillun-archiveasetoffilesanddirectoriesunderthearduino-1.5.3-Intel.1.0.3directorystructure.”

Ablockofcodeissetasfollows:

qData=false;//Initializeonreset

gSerialStdPtr->begin(9600);//Receiver

gSerialTwoPtr->begin(9600);//Sender

waitForUser(5);//Giveusrtimetoopenserialterminal

gSerialStdPtr->println("XBee-Receiver-setup");

pinMode(led,OUTPUT);

Anycommand-lineinputoroutputiswrittenasfollows:

mvmaestro-linux-100507.tar.gz\?file_id\=0J315maestrolinux-100507.tar.gz

Newtermsandimportantwordsareshowninbold.Wordsthatyouseeonthescreen,inmenusordialogboxesforexample,appearinthetextlikethis:“SelecttheStart|ControlPanel|DeviceManagerinsideWindows.”

NoteWarningsorimportantnotesappearinaboxlikethis.

TipTipsandtricksappearlikethis.

ReaderfeedbackFeedbackfromourreadersisalwayswelcome.Letusknowwhatyouthinkaboutthisbook—whatyoulikedormayhavedisliked.Readerfeedbackisimportantforustodeveloptitlesthatyoureallygetthemostoutof.

Tosendusgeneralfeedback,simplysendane-mailto<feedback@packtpub.com>,andmentionthebooktitleviathesubjectofyourmessage.

Ifthereisatopicthatyouhaveexpertiseinandyouareinterestedineitherwritingorcontributingtoabook,seeourauthorguideonwww.packtpub.com/authors.

CustomersupportNowthatyouaretheproudownerofaPacktbook,wehaveanumberofthingstohelpyoutogetthemostfromyourpurchase.

DownloadingthecolorimagesofthisbookWealsoprovideyouwithaPDFfilethathascolorimagesofthescreenshots/diagramsusedinthisbook.Thecolorimageswillhelpyoubetterunderstandthechangesintheoutput.Youcandownloadthisfilefrom:https://www.packtpub.com/sites/default/files/downloads/B03435.pdf.

ErrataAlthoughwehavetakeneverycaretoensuretheaccuracyofourcontent,mistakesdohappen.Ifyoufindamistakeinoneofourbooks—maybeamistakeinthetextorthecode—wewouldbegratefulifyouwouldreportthistous.Bydoingso,youcansaveotherreadersfromfrustrationandhelpusimprovesubsequentversionsofthisbook.Ifyoufindanyerrata,pleasereportthembyvisitinghttp://www.packtpub.com/submit-errata,selectingyourbook,clickingontheerratasubmissionformlink,andenteringthedetailsofyourerrata.Onceyourerrataareverified,yoursubmissionwillbeacceptedandtheerratawillbeuploadedonourwebsite,oraddedtoanylistofexistingerrata,undertheErratasectionofthattitle.Anyexistingerratacanbeviewedbyselectingyourtitlefromhttp://www.packtpub.com/support.

PiracyPiracyofcopyrightmaterialontheInternetisanongoingproblemacrossallmedia.AtPackt,wetaketheprotectionofourcopyrightandlicensesveryseriously.Ifyoucomeacrossanyillegalcopiesofourworks,inanyform,ontheInternet,pleaseprovideuswiththelocationaddressorwebsitenameimmediatelysothatwecanpursuearemedy.

Pleasecontactusat<copyright@packtpub.com>withalinktothesuspectedpiratedmaterial.

Weappreciateyourhelpinprotectingourauthors,andourabilitytobringyouvaluablecontent.

QuestionsYoucancontactusat<questions@packtpub.com>ifyouarehavingaproblemwithanyaspectofthebook,andwewilldoourbesttoaddressit.

Chapter1.GettingStartedwiththeGalileoYou’vechosenIntel’snewGalileoprocessorboardandyouarereadytostartsomeamazingprojects.However,youmightbenewtothiskindofprocessor,oryoumighthaveusedanothersimilarprocessorbutnottheGalileo.Thisbookisdesignedtoleadyoustep-by-stepthroughanumberofexamplesthatwillprovideyouwiththeknowledgeyouneedtoaccessthepoweroftheGalileo.You’llalsolearnhowtoaddadditionalhardwaretosensetheworldaroundyou,displayinformation,andevencontrolmotorsorservos.

Inthischapter,you’llstartbyunpackingandconnectingtheGalileotoyourhostmachine,thenyou’lllearnhowtousetheGalileofromyourremotecomputer.IfyouknowhowtouseMacorLinuxmachines,thischapterwillshowyouhowtousethem.You’lltakeapeekintotheinternalsoftheGalileoandlearnabouttheLinuxmachinehidingbehindthesimpleGalileoexterior.

Forthischapter,theobjectivesareasfollows:

UnpackingandconnectingtheGalileotoahostcomputerLoadingandconfiguringtheGalileoIDE,basedontheArduinoIDEDownloadingandrunningsomesimpleexampleprogramsTakingapeekattheLinuxmachineattheheartoftheGalileo

UnpackingandconnectingtheGalileoTheGalileoispackagedwithapowercable.Hereisapictureoftheboard:

Thisishowtheboardwilllookwithouttheadapter:

NoteThisparticularGalileoisaGen2board.ThisversionisaslightlyimprovedversionoftheoriginalGen1board,andhasafewconnectorchanges.Theexamplesinthisbookhavebeentestedonbothversions,andshouldworkunlessnoted.

Thepowerconnectionisverystraightforward.However,you’llalsoneedanothercabletostartworkingwiththeGalileo.ThisisaUSB-to-microUSBcable.Hereisapicture:

ThiscablewillgobetweentheGalileoandthehostmachinetodevelopanddebugthecode.Herearethespecificconnections:

TopreparefordevelopingtheGalileo,plugthepowerintoanoutletandtheboard.AgreenpowerLEDclosetotheUSBconnectorshouldlight.NowyouarereadytoconnectyourboardtoaremotecomputertobeginprogrammingThenextsectionswillcoverhowtoconnectyourGalileotoacomputerrunningWindows,OSX,orLinux.

DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachineThefirststepinsettingupyourremotecomputerfordevelopmentwiththeGalileoistodownloadtheIntegratedDevelopmentEnvironment(IDE)softwarefromhttps://communities.intel.com/docs/DOC-22226.ChoosethedownloadlinkforWindows.ThiswilldownloadtheIDEaswellasthedriversfortheGalileo.Whenthisfileisdownloaded,unzipthefileusinganarchivemanager(forexample7-zip)toalocationonyourC:.Thiswillun-archiveasetoffilesanddirectoriesunderthearduino-1.5.3-Intel.1.0.3directorystructure.

PlugtheUSBfromtheGalileointoyourcomputer.IfyouareusinganewerversionofMicrosoftWindows,whenyouplugtheGalileointothesystemitwilltrytoinstallthedriversautomatically.Thedevicewillfailtoinstall.You’llneedtoinstallthedriversmanually,usingthefollowingsteps:

1. SelecttheStart|ControlPanel|DeviceManagerinsideWindows.UndertheOtherdevicesmenu,selecttheGadgetSerialv2.4device.ThenselectUpdateDriverSoftware,asshowninthefollowingscreenshot:

2. NextclickonBrowsemycomputerfordriversoftware.

3. ClickonBrowse…nexttothefilepathinputbox.4. IfyouinstalledyourArduinoIDEfolderintherootofyourharddrive,navigateto

C:\ardunio-1.5.3\hardware\arduino\x86\toolsandclickonOK.Ifyouhaveinstalleditinadifferentlocation,navigatetothisdirectory,selectit,andthenclickonOK.

Youwillgetasecuritywarning;clickonOKandthedriverswillinstall.Whenyourdriversareinstalled,youshouldseethefollowingdevicewhenyounavigatetoStartMenu|DevicesandPrinters:

Inthiscase,thedeviceisconnectedtoCOMport34.NotedowntheCOMporttheGalileoisconnectedtoasyou’llneedthatinaminute.

DownloadingthesoftwareandconnectingtheGalileotoaMacIfyouareusinganOSXmachine,downloadtheOSXversionoftheIDEsoftwareathttps://communities.intel.com/docs/DOC-22226.UnzipthisfileintoyourApplicationsfolder.Thenconnectthe5VpowertotheGalileo.ConnecttheUSBcablefromtheGalileotoanavailableUSBsocketonyourcomputer.WaitforaminutewhiletheGalileobootsup.ToverifythattheGalileohasloadedproperly,opentheSystemInformationwindow.ThencheckundertheUSBtabforaGadgetSerialv2.4entryasdemonstratedinthefollowingscreenshot:

YoushouldalsocheckundertheNetworktabtofindthedevicenameofyourGalileo.ItshouldbesomethinglikeusbmodemXXXX.NotedownthisnameasyouwillneedittoselectthecorrectportlaterwhenyouconfiguretheconnectiontotheGalileo.Youarenowreadytorunthesoftware.

DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachineIfyouareusingaLinuxmachine,downloadtheLinuxversionoftheIDEsoftwarefromhttps://communities.intel.com/docs/DOC-22226.Unpackthisfileusingtar-zxvfarduino-1.5.3-linux32.tar.gz.YouwillalsoneedtodisablethemodemmanageronmostLinuxdistributionstoenableuploadingtotheboard.Howyoudothiswillvarybydistributionbut,ifyouareusingtheUbuntudistribution,typesudoapt-getremovemodemmanager.

ToconnecttheGalileoboardtotheLinuxmachine,simplyplugintheUSBconnectortooneoftheUSBportsontheLinuxmachine.Openaterminalandtypesudols/dev/ttyACM*andthiswilllistthedeviceconnectedtothemachine.Youshouldnotedownthisvalueasyouwilllaterneedtospecifytheport.

RunningtheIDEfortheGalileoNowthatthedeviceisinstalled,youcanruntheIDE.Selectandruntheprogrambasedonthetypeofmachineyouareusing.TheIDEshouldstartandyoushouldseesomethingresemblingthefollowingscreenshot:

Thisistheenvironmentyouwillusetodevelopyourapplications.YoucanusethisIDEtocompilethecode,uploadittothedevice,andthenrunit.

SettingtheIDEtoconnecttoyourboardThefirstthingyou’llneedtodoissettheIDEtocreatecodefortheproperGalileoboard.Fortunately,theIDEletsyousetthatbychoosingtheboard.Todothis,navigatetoTools|Board|Intel®GalileoGen2,asshowninthefollowingscreenshot:

Thenextstep,selectingaporttoconnecttheboardtotheIDE,willdependonthetypeofoperatingsystemyouareusing.

SelectingtheproperCOMportforWindowsTospecifytheportforWindows,navigatetoTools|SerialPort|COM23,(theportyounotedearlier)asshowninthefollowingscreenshot:

TheIDEshouldnowindicatethatyouareusingtheGalileoonCOM23inthelower-rightcorneroftheIDE,asintheprecedingscreenshot.

SelectingtheproperCOMportfortheMacTospecifytheportforMac,navigatetoTools|SerialPort|andselecttheportyounotedearlierwhenyouinstalledthedrivers.TheIDEshouldnowindicatethatyouareusingtheGalileoontheproperportinthelower-rightcorneroftheIDE.

SelectingtheproperCOMportforaLinuxMachineTospecifytheportforaLinuxmachine,navigatetoTools|SerialPort|andselecttheportyounotedearlierwhenyoufirstconnectedtotheboard.TheIDEshouldnowindicatethatyouareusingtheGalileoontheproperportinthelower-rightcorneroftheIDE.

UpdatingthefirmwareThefirstthingyou’llwanttodoisupdatethefirmwareontheGalileo.Todothis,selectHelp|GalileoFirmwareUpdate,asshowninthefollowingscreenshot:

Havingthelatestfirmwareisalwaysagoodidea;youmightwanttorepeatthisstepeveryweekorsojusttomakesureyouhavethelatest.

OpeninganduploadingafiletotheGalileoNowthatyourboardisconnectedandyouarerunningthelatestfirmware,youcanopenanduploadasimpleexamplefile.Itiscalledtheblinkapplication.Ithasalreadybeenwrittenforyou,soyouwon’tneedtodoanycoding.

Togettheblinkapplication,performthefollowingsteps:

1. NavigatetoFile|Examples|01.Basics|Blink,asshowninthefollowingscreenshot:

2. YoushouldthenseetheBlinkcodeintheIDEwindow,asinthefollowingscreenshot:

3. SelecttheUploadbutton,asinthefollowingscreenshot:

4. Onceyouhaveuploadedthefile,itwilltellyouinthelower-leftcorneroftheIDEdisplaythatthefileisuploaded,asinthefollowingscreenshot:

Whentheprogramisuploaded,itwillautomaticallystartrunningandthegreenLEDthatispositionedclosetotheUSBconnectionontheGalileowillstartblinking.ThefollowingimagesshowstheLED:

YouhavenowsuccessfullyuploadedyourfirstprogramtoyourGalileo!

AccessingtheGalileo’sLinuxcapabilitiesThereareseveraldifferencesbetweentheGalileoandthemorecommonArduinoboardthatmanyofyoumightbefamiliarwith.TheGalileohassignificantlymoreprocessingpower.However,italsostartsupintoaLinuxoperatingsystem,andthenexposesitsprogrammingenvironmentinanArduino-likeinterface.Whileyou’llalmostexclusivelyusetheArduinoIDEinterfaceinthisbook,youcanalsoaccesstheLinuxcapabilitiesoftheGalileo.You’lllearnmoreaboutthisinChapter7,GoingFurtherwithGalileo.

SummaryYou’vecompletedthenextstageofyourjourney.YouhaveyourGalileoup-and-talkingwithyourexternalcomputer,andknowhowtoconnecttotheIDEtocreatecode.YournextstepwillbelearninghowtoaccesstheGPIOpinssothatyoucaninteractwiththeoutsideworld.

Chapter2.AccessingtheGPIOPinsNowthatyouarefamiliarwiththeGalileoIDEandknowhowtocreate,edit,anduploadaprogram,thischapterwillnowfocusonhardware.You’lllearnaboutthecapabilitiesoftheGeneralPurposeInput/Output(GPIO)pinsandhowyoucanconnecttoandaccessthemviasoftware.Specifically,you’lllearnaboutthefollowing:

TheGPIOpins,whattheycanandcan’tdoHowtouseandaccessthemusingsomeverybasiccircuitsandverysimpleprogrammingexamplesthatdemonstratehowtomaketheGalileoaccesstheoutsideworld

TheGPIOcapabilityoftheGalileoTheGalileowasbuilttomodelhowtheArduinoaccessestheoutsideworld.MuchofthataccessshouldbethroughtheGPIOpins.TheGalileocomeswithastandardsetof14digitaland6analogIOpins,alongwithsomeadditionalpinstoprovidepowerandserialIO.Fortunately,thepinsareactuallywelllabeledontheboarditself.

Hereisaclose-up:

Hereisalistofpinsthatareavailable,andabriefdescriptionofwhateachpincando,startingattheupperrightandgoingclockwise.Amorein-depthdescriptionofthesepinswillcomelaterasyouactuallyusetheminsomeexampleprojects:

GalileoPin Description

AREF

Thispinprovidesareferencevoltagefortheanaloginputs.Thevaluesontheanalogpinswillbereportedinreferencetothisvoltage.You’llalsousethisinsomeapplicationstoprovideareferencevoltageforsensingdevices.Youcanalsoprovideanexternalreferencevaluetothispin,whichmeansthatthenumericalvaluesoftheinputswillbescaledaccordingtothevaluesuppliedonthispin.

GND ThispinprovidesagroundreferencefortheAREFpin.

Digital(PWM~)13/2

These11pinscanbeusedtoeitherreadorwritedigitalvalues.Ifinput,thevaluewillbereadaseithera0or1basedonthevoltagelevelattheinput.Ifoutput,thevaluewillbesettoeithera0or1basedonthelogicvoltagelevel(theactualvoltagewilldependonthevoltagelogiclevelofyourArduino.Someare5Vlogiclevel,othersare3.3Vlogiclevel).

DigitalTX->1

Thispin,andtheRXpinnexttoit,provideaserialinterfacethatcanbeusedtocommunicatewithotherdevices.

DigitalRX->0

Thispin,andtheTXpinnexttoit,provideaserialinterfacethatcanbeusedtocommunicatewithotherdevices.

AnalogINA5/A0

Thesepinsdodoubleduty.Normally,theyareusedasA/DinputstotheGalileotoreadcontinuousvoltagevaluesandturnthemintointegervalues.However,theycanalsobeusedasDigitalI/O,verysimilartotheDigitalI/Opins.

PowerVin

YoucanpowertheGalileofromthispin.Thiscanbeespeciallyusefulafteryouhaveuploadedyourprogram.YoucanthendisconnecttheUSBportand,whenyouapplyvoltagetothispin,yourGalileowillbootandruntheuploadedprogram.FortheGen1board,thisneedstobe5volts.FortheGen2board,youcanuseavoltagevaluefrom7to12Volts,soawidevarietyofDCpoweradapterorbatteryconfigurationscanbeused.

PowerGND ThispinwouldgivethegroundconnectionassociatedwiththePowerVinconnection.

PowerGND ThisisagroundnormallyassociatedwiththePower5VandPower3.3Voutputs.

Power5V Thisisavoltageoutputsetto5Volts.

Power3.3V Thisisavoltageoutputsetto3.3Volts.

RESET Thispinwillresettheprocessor,whichwillcausetheprogramtorunfromthebeginning.

IOREF Thisprovideseithera3.3V,or5Vreference,indicatingthelogicleveloftheboard.

UsingtheGPIOpinsNowthatyouareawareofalltheGPIOcapabilities,youcanstartputtingthemtowork.Inordertodothis,itisbesttopurchaseasmallbreadboardandsomejumperwires;thiswillmakeconnectingtotheoutsideworldeasier.Hereisapictureofsuchabreadboard:

Theyareeasytofind,youcanpurchaseoneatalmostanyelectronicsstore,oronanyelectroniconlinesites.You’llneedsomejumperwirestoconnectfromtheGalileotothebreadboard.ThejumperwiresyouwantaretheMale-to-Malesolder-lessjumperwires.Hereisapictureofthissortofwire:

ThesejumpercablesplugeasilyintotheheaderpinsontheGalileoandthebreadboard.

Nowthatyouhavethecablesandthebreadboard,youcanstartaccessingandcontrollinghardware.

ConnectingyourfirstexternalhardwareYourfirstprojectwillusetheDigitalIOpinstolightupanLED.Todothis,you’llneedtogathertwomorehardwarepieces.ThefirstisanLED(LightEmittingDiode).Thisisasmallpartwithtwoleadsthatlightsupwhenvoltageisapplied.Theycomeinawidevarietyofcolors.Ifyouwanttobuythemonline,searchfora3-mmLED.Youcanalsogetthematmostelectronicsshops.TheimageshowsanLED:

You’llalsoneedaresistortolimitthecurrenttotheLED;a220-ohmresisterwouldbetherightsize.Again,youcangetthemonlineoratmostelectronicsshops.Thefollowingimageshowsaresistor:

IfyougetthreeLEDsandresistors,youcanexercisethreeoftheDigitalIOpins.

PluggingyourwiresintothebreadboardNowthatyouhaveallthebitsandbobs,let’sbuildyourfirsthardwareproject.Beforeyoupluganythingin,let’slookatthebreadboardforamomentsothatyoucanunderstandhowyouaregoingtouseittomakeconnections.You’llbepluggingyourwiresintotheholesonthebreadboard.Theholesonthebreadboardareconnectedinauniquewaytomaketheconnectionsyoudesire.

Inthemiddleofthebreadboard,theholesareconnectedacrosstheboard.Soifyoupluginawire,andanotherwireintheholerightnexttoit,thesetwowireswillbeconnected,likethis:

Thetworowsoneachsideoftheboardaregenerallydesignedtoprovidepower,sotheyareconnectedupanddown,likethis:

SettinguptheelectronicsSolet’splacetheelectronicsonthebreadboard.PlacetheLEDsinsuchawaythatonewireisononesideofthemiddlesplitofthebreadboard.ThedirectionoftheLEDisimportant;makesurethatthelongerofthetwowiresisontheleftsideofthehole,likethis:

Nowplacetheresistorsontheholesononeside.Thedirectionoftheresistordoesnotmakeanydifference,butmakesurethesecondwireleadisplacedintherowofholesattheendoftheboard,likethis:

Thesewillallbeconnectedtogether,andwillbeconnectedtotheGNDoftheGalileousingoneofthejumpercableslikethis:

Finally,usejumperwirestoconnecttheDigitalIOpins13,12,and11totheholesonthebreadboard,likethis:

Nowthatthehardwareisconfiguredcorrectly,you’llneedtoaddcodetoactivatetheLEDs.

TheIDEandLEDCodeTocreatethecodeforthisexample,starttheGalileoIDE.RecalltheBlinkexampleyouaccessedinChapter1,GettingStartedwiththeGalileo.TheIDEshouldlooklikethis:

Ifyourememberthiscode,intled=13littheorangeLEDontheboard.ItturnsoutthatLEDoutputpin13isalsotheconnectiontothe13pinontheGalileoconnector.Ifyouuploadandrunthisprogram,theLEDconnectedtopin13shouldflashatthesamerateastheLEDontheGalileo.Hereisapicture:

You’llneedtoaddasimilarbitofcodetogettheLEDsconnectedtopin12and11.AddthefollowingtothesketchontheIDE:

Here,youarereplicatingthecodebutconnectingtheLEDconnectedtopin13tothevariableled,theLEDconnectedtopin12tothevariableled1,andtheLEDconnectedtopin13tothevariableled3.Youthenprogramthemalltobeoutputpinsandtheninthemainlooptogglebetweenhighandlow.NoticeIhavetwopinstogglingtogether(pins13and11)withtheother(pin12)togglingintheexactoppositesequence.Theoutertwo

LEDsshouldlightforonesecond,thentheinnerLEDshouldlight.

IfoneormoreoftheLEDsdon’tlight,checktomakesuretheyarepushedfirmlydownintotheboard.YoucanalsochangethedirectionoftheLED;perhapsyouhavetheleadsinthewrongdirectionontheboard.

GettingsignalsfromtheoutsideworldYouknowhowtosendsignalstotheoutsideworld.Youmightalsowanttoreceiveinputsignalsfromtheoutsideworld.Thesesignalscanbedividedintotwotypes:digitalsignalsandanalogsignals.

InterfacingdigitalinputsignalswithGalileoTherearepinsontheGPIOconnectorsoftheGalileothancanbeusedtosensedigitalinput;thatis,aninputthatwillbeinterpretedaseithera0or1byaprogram.ThesearelabelledontheGalileo.Anexampleofhowtousetheseisasimplebuttonpresscircuit.Tocreatethiscircuit,you’llneedoneofthe220-ohmresistorsyouusedintheLEDcircuit.You’llalsoneedasimple,single-pole,single-throwswitch;youcangettheseatmostelectronicsstores.You’llalsoneedsomejumperwirestoconnecttheGalileotoyourcircuit.Hereisthecircuitdiagram:

Nowyou’llneedsomecode.YoucanuseoneoftheexampleprogramsincludedwiththeIDE.SelecttheExamples|02.Digital|Buttoncode,likethis:

Whenyouuploadthisexample,youwillfindthatpressingthebuttonlightstheLEDontheGalileoboard.Whenyoureleasethebutton,theLEDwillnotbelit.Youcannowgetdigitalinputintoyourproject.

InterfacinganaloginputsignalswithGalileoTherearesomesignalsthataren’teitheron,oroff.Youwillactuallywanttomeasurethelevelofthesignal.Theseareanalogsignals,andtheGalileocanhandlethemaswell.You’llneedtouseoneoftheanaloginputs,however.Thesearealsolabelledontheboard.Asanexample,youcanbuildasimpleelectroniccircuitusingapotentiometertoillustratethiscapability.Apotentiometerisavariableresistor;youcanchangetheresistancebetweentwopointsbyadjustingthepotentiometer,normallybyturninganadjustmenteitherwithyourfingers,orascrewdriver.Tocreatethiscircuit,you’llneedapotentiometer,availableatalmostallelectronicsstores.Hereisthecircuittobuild:

Youhavetoconnectthe5-voltconnectiontoonesideofthepotentiometer,andtheGNDconnectiontotheothersideoftheconnector.Themiddleterminalofthepotentiometerwillchangevoltagevalueasyouadjustthepotentiometer.Tomeasurethisvoltage,you’lluseanotherexampleprogramthatcomeswiththeIDE.SelecttheExamples|03.Analog|AnalogInput,codelikethis:

AdjustingthepotentiometerwillcausetheLEDontheGalileotoflashfasterorblinkmoreslowly.TheGalileoisreadingthevoltagevalueandusingthatvaluetodeterminehowlongtheLEDshouldbeonandoff.YoucannowgetanaloginputintoyourGalileo.

SummaryThat’sit.You’vecompletedyourveryfirstexampleofinterfacingwiththeoutsideworld.YoucanplaywithdifferentpatternsofLEDsequencesbyusingloopsanddifferentwaitstates.Nowthatyouhavecreatedyourveryfirsthardwareproject,inthenextchapterwe’llcoverhowtoaddhardwarecapabilityusingahardwareshield,apieceofhardwarethatplugsdirectlyintotheIOconnectorsoftheGalileo.

Chapter3.AddingDisplayFunctionalityInChapter2,AccessingtheGPIOPins,youlearnedhowtoconnecttotheGalileoanditsGPIOpinsusingjumperwires,breadboards,andcomponents.Inthischapter,you’lllearnmoreaboutaddingfunctionalitybyaddinghardwaredesignedtoplugintotheGalileo.Insomeoftheseexamples,you’llusespecialhardwaredesignedtobepluggedintotheGalileo’sGPIOpins;thesearecalledshields.

ThesimpleserialdisplayInordertounderstandhowtouseashield,let’sstartwithoneofthemostbasicdisplaymodulesavailablefortheGalileo,theserialLCDdisplay.Thereareseveraldifferentversionsoutthere,butmostprovideasimple2x16characterdisplaythatcanbedrivenbytheserialTXpinontheArduino.TheyareavailableatmostlocationswheretheGalileoisoffered.Thefollowingimageshowsthedisplay:

You’llneedthreepinstodrivethisdisplay.TheyareaGNDandVCCpin,andtheTXpin.TheVCCandGNDwillcomefromthe5VandGNDpinsontheGalileo.You’llusedigitalI/Opin1ontheGalileoasaTX.ToconnecttheGalileotothedisplay,connectthemaletomalejumpersto5Volts,GND,anddigitalinput.Connectthethreeconnectorstotheproperconnectionsontheboard,likethis:

Thisshouldcompletethehardwareconnectionstotheboard.Nowyou’llneedsomecodetowritecharacterstotheboard.

EnablingtheserialdisplayintheIDENowbringuptheIDE.Beforeyoustartcoding,you’llneedtogetthelibraryassociatedwithyourdisplayandinstallitintheIDE.Forthisparticulardisplay,you’llusetheseriallibraryfoundathttps://github.com/downloads/nkcelectronics/SerialLCD/SerialLCD.zip.

The.zipfileshouldthenexistinyourDownloadsdirectory.Nowyou’llneedtoplacethesefilesinthelibrariesdirectoryofyourDEinstallation.Performthefollowingsteps:

1. ToincludethislibraryinyourIDE,firststartyourIDEandthenselectSketch|ImportLibrary…|AddLibrary…,likethis:

2. NowgotoyourDownloadsdirectoryandselecttheZIPfilethatholdsyourlibrary.Whencomplete,thislibraryshouldbeaddedtoyourlibrarychoices.YoucancheckthisbyagainselectingSketch|ImportLibrary…|AddLibrary…likethis:

3. Oncethelibraryisinstalled,gobacktothemainIDEscreenandyoucanwritethefollowingcode:

ThiscodewaswrittenusingtheLCDdocumentationathttp://media.nkcelectronics.com/datasheet/LCM1602SK-NSW-BBW.pdf.Itisquitesimple.

Letsexplainthecodelinebyline:

charESC=0xFE;-Thischaracterneedstobesenttothedisplayeachtimeacommandissentvoidsetup()–ThesetupfunctioniscalledbytheGalileoeachtimetheprogramisrunSerial1.begin(9600);:-Setstheserialporttoabaudrateof9600Serial1.write(ESC);:-SendstheprecedingcharacterseteachtimeacommandissentSerial1.write(0x51);:-ThiscommandclearsthedisplaySerial1.write(ESC);:-SendsthepreviouscharacterseteachtimeacommandissentSerial1.write(0x46);:-Setsthecursortothefirstline,thefirstpositionSerial1.print("HelloWorld!");:-PrintsoutHelloWorld!

Serial1.write(ESC);:-SendstheprecedingcharacterseteachtimeacommandissentSerial1.write(0x45);:-SetsthecursortothesecondlineSerial1.write(0x40);:-SetsthecursortothefirstpositionSerial1.print("IntelGalileo");:-PrintsoutIntelGalileo!voidloop():–Thisloopiscalledoverandoverafterthesetup()functioniscomplete

4. NowuploadthesketchandyoushouldseeHelloWorld!IntelGalileoonthedisplay,likethis:

Nowyoucanaddallsortsoftext.Ifyouplaceamessageintheloop,besuretoaddindelay(2000).Thisisafunctionthatpausesforanumberofmilliseconds(inthiscase2000),thusallowingtheusertimetoreadthedisplaybeforeitischanged.

NowyoucandisplayinformationfromtheGalileo.Youmight,however,wantevenmoreflexibilitythanthisdisplaycanprovide,soyou’llnowlearnhowtoaddaTFTdisplay.

TheTFTshieldUsingaTFTdisplayshieldisanotherwayofaddingdisplaycapabilitytoyourGalileo.ThereisalimitedsetofTFTdisplaysthatwillworkwiththeGalileoandtheperformanceisn’tveryfast,butitdoeswork.First,you’llneedadisplay,forexampletheAdafruit2.8inchTFTV2availablefromadafruit.com.Thefollowingimageshowstheunit:

You’llplacethisshieldontotheGalileo,likethis:

Theunitwilllightupandshowthatitisconnected.Oncethehardwareisconnected,you’llnowneedtoaccessthedisplayviatheIDE.

AccessingthedisplaywiththeIDEToaccessthedisplay,you’llneedtofollowthesesteps:

1. GototheIDElibrariesdirectoryanddeletetheRobot_Controllibrary.Thishassomeduplicatefilesthatwillcauseproblemslaterifyoudon’tgetridofthem.

2. DownloadtheAdafruit_GFXlibraryandinstallitintheIDElibrary.Youcangetthislibraryathttps://learn.adafruit.com/adafruit-gfx-graphics-library.You’llneedtounzipit,changethenamefromAdafruit-GFX-Library-mastertoAdafruit_GFXandmoveitintotheIDElibrariesdirectory.

3. DownloadamodifiedversionoftheAdafruit_ILI9341libraryfromhttps://github.com/wallacezq/Adafruit_ILI9341.Unzipthislibrary.

4. GotothedirectoryAdafruit_ILI9341-master.Inthatdirectory,youwillfindtheArduinodirectoryandinsidethatdirectorythefileArduino.h.YoumustcopythatfileintotheIDEatthelocation\arduino-1.5.3-Intel.1.0.4\hardware\arduino\x86\cores\arduino.MakesureyoureplacetheexistingArduino.hfile.

5. IntheAdafruit_ILI9341-masterdirectory,thereisanotherdirectorynamedAdafruit_ILI9341-Library.RenameittoAdafruit_ILI9341andmoveitintotheIDElibrariesdirectory.

NowyouarereadytoopentheIDEandanexampleprogramthatwillaccessthedisplay.OpentheExamples|Adafruit_ILI9341|graphicstestexample,likethis:

NowuploadthefileusingtheIDEandyoushouldseethefollowingresult:

Youcannowdisplaygraphicsonthedisplay!Theonlyexamplefromthisdirectorythatwillworkisthegraphicstestexample.Theothersrequireaccesstothetouchscreencapabilitythatisnotyetavailableviathelibrary.

SummaryThat’sit.You’velearnedhowtoadddisplaycapabilitytoyourGalileoprojectsusingshields.You’llusethesesameconceptsinlaterchapterstoaddothertypesoffunctionalities.Infactinthenextchapter,you’llusetheshieldconcepttocontrolDCmotors.

Chapter4.ControllingDCMotorsInChapter3,AddingDisplayFunctionality,youlearnedhowtoconnecttotheoutsideworldusingjumperwiresandspeciallydesignedhardwarecalledshields.Inthischapter,you’lllearnthefollowing:

HowtousetheGalileotocontrolsmallDCmotorsHowtotakethistothenextlevel,learninghowtoaddmorefunctionalityusingashieldtocontrolthespeedanddirectionofmorepowerfulDCmotors

DCmotorbasicsBeforewegetstartedwithconnectingeverythingandmakingitallmove,let’sspendsometimeunderstandingsomeofthebasicsofDCmotorcontrol.Whetheryouchooseatwoorfourwheeledmobileplatform,oratrackedplatform,thebasicmovementcontrolisthesame.Theunitmovesbyengagingthemotors.Ifthedesireddirectionisstraight,themotorsarerunatthesamespeed.Ifyouwanttoturntheunit,themotorsarerunatdifferentspeeds.Theunitcanactuallyturninacircleifyourunonemotorforwardandonebackwards.

DCmotorsarefairlystraightforwarddevices.Thespeedanddirectionofthemotoriscontrolledbythemagnitudeandpolarityofthevoltageappliedtoitsterminals.Thehigherthevoltage,thefasterthemotorwillturn.Ifyoureversethepolarityofthevoltage,youcanreversethedirectionthemotoristurningin.

However,themagnitudeandpolarityofthevoltagearenottheonlyfactorthatisimportantwhenitcomestocontrollingyourmotors.Thepowerthatyourmotorcanapplytomovingyourplatformisalsodeterminedbythevoltageandthecurrentsuppliedatitsterminals.

Now,thereareactuallyGPIOpinsontheGalileothatyoucouldusetocreatethecontrolvoltageanddriveyourmotorsdirectly.ThechallengewiththismethodisthattheGalileocannotnormallysourceenoughcurrentandvoltageandthusyourmotorswouldnotbeabletogenerateenoughpowertomoveamobileplatform.

Thereareseveralsolutionstothisproblem.Thefirstistouseasimpletransistorcircuitandanexternalvoltagesource.You’llusethissolutioninthefirstexampleofthischapter.AnothersolutionistouseanH-bridge,achipthattheGalileocancontrolbutthatisconnectedtoapowersourceandcanprovideenoughcurrent.Thesecondexampleinthischapterwillshowyouhowtousethissortofchip.Thethirdsolutiontotheproblemistouseashieldthatcontainsallthecircuitryandcanconnecttoanexternalpowersourceinput.ThenyourGalileocanprovidebothvoltageandcurrentsothatyourplatformcanmovereliably.ThelastexampleinthischapterwilluseamotorcontrollershielddesignedfortheArduinotomakeDCmotorcontrolsimple.

ConnectingaDCmotordirectlytotheGalileoThefirststepinconnectingaDCmotortotheGalileoistoactuallyobtainaDCmotor.Themotorsthatyouwillbedealingwithherearesimple,smallDCmotors.Forthisexample,youcanuseasmall6VDCmotoravailableatmostelectronicsorhobbystores,oronlineatwww.amazon.com.Hereisapictureofonesuchmotor:

InordertoconnectthismotortoyourGalileo,you’llneedsomeadditionalparts.You’llneedtwomale-to-malejumpercablesandtwoalligatorclipjumpercables.You’llalsoneedatransistor,TIP120tobespecific.You’llalsoneedadiode,the1N4004diode,a1,000-ohmresistor,anda1µFaradceramiccapacitor.Thelastfourpartsshouldbeavailableatalmostanyelectronicsstore,oronline.Tocontrolthismotor,you’llconnectonemotorconnectortodigitalpin11,andtheotherconnectortoGND.YoucoulduseoneofthevoltagesourcesontheGalileo,butsomeDCmotorscandrawlotsofcurrent,morethanyourGalileocansupply.AsaferwayistoconnecttheDCmotorsupplytoabatteryholderwith4AAbatteries.

ConnecttheGalileo,transistor,diode,resistor,andpowersupplylikethis:

NowyoucanstarttheIDEsothatyoucanenteraprogramtosendacontrolsignaltotheDCmotor.

GalileocodeforDCmotorspeedcontrolOpentheIDEandthenenterthefollowingcode:

ThiscodesendsbasiccommandstotheGalileotocontrolthespeedofthemotor.Herearethedetails:

intmotorPin=11;:-ThissetsdigitalI/Opin11tothecontrolpinyou’llbeusing.voidsetup():–ThesetupfunctionexecutesonceyousetupyourGalileo.pinMode(motorPin,OUTPUT);:-Thissetsthispintofunctionasanoutputpin.Serial.begin(9600);:-Thisstartstheserialportwithabaudrateof9600.Serial.println("SetSpeed0-255");:-Thisprintstheline“SetSpeed0–255”.voidloop():–ThisloopisperformedoverandoveragainontheGalileo.

if(Serial.available()):–Ifthereisaserialinputdateontheserialport,thendothefollowingstatements.intspeed=Serial.parseInt();:-Thisbringsinthedataasaninteger.Serial.println("Speed");:-Thisprintstheline“Speed”.Serial.print(speed);:-Thisprintsthevalueinputfromtheserialport.Serial.println("");:-Thisfinishesthelineandgoestothenextline.if(speed>=0&&speed<=255):–Ifthespeedisintheproperrange,thenthissendsiton.analogWrite(motorPin,speed);:-Thiswritesthisvaluetothepin11.ThiswillsetthePWMsignaltothepropervaluetocontrolthespeedofthemotor.

NowuploadthecodetoyourGalileo.Yourmotorshouldstartrunning.Onceyouhaveuploadedthecode,you’llwanttoopenuptheSerialMonitorsoyoucancommandyourmotortorunatdifferentspeeds.Toopenthis,you’llselectTools|SerialMonitor.Whenyouopenthis,youshouldseethefollowingwindowpopup,displayingthetextfromyourprogram:

Enteravalue,say255,andthenclickonSend.Yourmotorshouldspeedup.Enteranothernumber,say0,clickonSend,andyourmotorshouldstop.NumbersbetweenthesetwovaluesshouldadjustthespeedofyourDCmotor.Unfortunately,themotorcanonlygoinonedirection.Thenextexamplewillprovideasolutionifyou’dlikebidirectionalcontrolofyourDCmotor.

ConnectingaDCmotorusinganH-bridgeandtheGalileoThenextstepistoaddabitmorefunctionalitywithanewtypeofchip,anH-bridge.AnH-bridgeisafairlysimpledevice;itbasicallyconsistsofasetofswitchesandfunctionalitiestoallowthedirectionofthecurrenttobereversedsothatthemotorcaneitherberunintheforward,orinthereverse,direction.

Let’sstartthisexamplebybuildingtheH-bridgecircuitandcontrollingjustonemotor.Todothis,you’llneedtogetanH-bridge.OneofthemostcommononesistheL293dualH-bridgechip.ThischipwillallowyoutocontrolthedirectionoftheDCmotors.Thesechipsareavailableatmostelectronicsstoresoronline.You’llalsoneedacapacitor;youcanusethe1µFaradfromthepreviousexample,ifyoulike.OnceyouhaveyourH-bridge,buildthefollowingcircuitwiththeGalileo,themotor,andbreadboard:

Specifically,you’llwanttoconnectthesepinsontheGalileotothepinsontheH-bridge.Hereistheconnectionlist:

GalileoPin H-BridgePin

9 1

4 2

3 7

Onceyouhavetheconnections,youcantestthesystem.Todothat,you’llneedtoaddsomecode.

GalileocodeforDCmotordirectioncontrolOpentheIDEandtypeinthefollowingcode:

Thiscodesetsuppins3,4,and9toenablethechipandcontrolthedirectionofthemotor.Asmentionedbefore,youcanusetheTools|SerialPorttosenddatatotheprogram.Sendinga0setspin3toHIGHandpin4toLOW,causingthemotortospininonedirection.Sendinga1setspin3toLOWandpin4toHIGH,causingthemotortospinintheotherdirection.

NowyouknowhowtobuildcircuitstocontrolboththespeedandthedirectionofDCmotors.However,insteadofprocuringallthepartsandbuildingthecircuitsyourself,youcanactuallybuyaDCmotorcontrolshield.

ControllingDCmotorsusingashieldForthisfinalexample,let’sgraduatefromasimpleDCmotortoawheeledplatform.Thereareseveralsimple,two-wheeledroboticsplatforms.Inthisexample,you’lluseonethatisavailableonseveralonlineelectronicsstores.ItiscalledtheMagicianChassis,sourcedbySparkFun.Thefollowingimageshowsthis:

Tomakethiswheeledroboticplatformwork,you’regoingtocontrolthetwoDCmotorsconnecteddirectlytothetwowheels.You’llwanttocontrolboththedirectionandthespeedofthetwowheelstocontrolthedirectionoftherobot.

You’lldothiswithanArduinoshielddesignedforthispurpose.TheGalileoisdesignedtoaccommodatemanyoftheseshields.Thefollowingimageshowstheshield:

Specifically,you’llbeinterestedintheconnectionsonthefrontcorneroftheshield,whichiswhereyouwillconnectthetwoDCmotors.Hereisaclose-upofthatpartoftheboard:

Itisthesethreeconnectionsthatyouwilluseinthisexample.First,however,placetheboardontopoftheGalileo,muchasyoudidwiththedisplayshieldfromthelastchapter’sexample.Thenmountthetwoboardstothetopofyourtwo-wheeledroboticplatform,likethis:

Inthiscase,Iusedalargecabletietomounttheboardstotheplatform,usingthefoamthatcamewiththemotorshieldbetweentheGalileoandplasticplatform.Thisparticularplatformcomeswitha4AAbatteryholder,soyou’llneedtoconnectthispowersource,orwhateverpowersourceyouaregoingtouse,tothemotorshield.Thepositiveandnegativeterminalsareinsertedintothemotorshieldbylooseningthescrews,insertingthewires,andthentighteningthescrews,likethis:

Thefinalstepistoconnectthemotorwirestothemotorcontrollershield.Therearetwosetsofconnections,oneforeachmotorlikethis:

Insertsomebatteries,andthenconnecttheGalileotothecomputerviatheUSBcable,andyouarenowreadytostartprogramminginordertocontrolthemotors.

GalileocodefortheDCmotorshieldNowthattheHWisinplace,bringuptheIDE,makesurethattheproperportanddeviceareselected,andenterthefollowingcode:

Thecodeisstraightforward.Itconsistsofthefollowingthreeblocks:

1. ThedeclarationofthesixvariablesthatconnecttotheproperGalileopins:

intpwmA=3;

intpwmB=11;

intbrakeA=9;

intbrakeB=8;

intdirectionA=12;

intdirectionB=13;

2. Thesetup()function,whichsetsthedirectionA,directionB,brakeA,andbrakeBdigitaloutputpins:

pinMode(directionA,OUTPUT);

pinMode(brakeA,OUTPUT);

pinMode(directionB,OUTPUT);

pinMode(brakeB,OUTPUT);

3. Theloop()function.Thisisanexampleofhowtomakethewheeledrobotgoforward,thenturntotheright.Ateachofthesesteps,youusethebraketostoptherobot:

//MoveForward

digitalWrite(directionA,HIGH);

digitalWrite(brakeA,LOW);

analogWrite(pwmA,255);

digitalWrite(directionB,HIGH);

digitalWrite(brakeB,LOW);

analogWrite(pwmB,255);

delay(2000);

digitalWrite(brakeA,HIGH);

digitalWrite(brakeB,HIGH);

delay(1000);

//TurnRight

digitalWrite(directionA,LOW);//Establishesbackwarddirectionof

ChannelA

digitalWrite(brakeA,LOW);//DisengagetheBrakeforChannelA

analogWrite(pwmA,128);//SpinsthemotoronChannelAathalfspeed

digitalWrite(directionB,HIGH);//Establishesforwarddirectionof

ChannelB

digitalWrite(brakeB,LOW);//DisengagetheBrakeforChannelB

analogWrite(pwmB,128);//SpinsthemotoronChannelBatfullspeed

delay(2000);

digitalWrite(brakeA,HIGH);

digitalWrite(brakeB,HIGH);

delay(1000);

Onceyouhaveuploadedthecode,theprogramshouldruninaloop.Ifyouwanttorunyourrobotwithoutconnectingtothecomputer,you’llneedtoaddabatterytopowertheGalileo.TheGalileowillneedatleast2Amps,butyoumightwanttoconsiderproviding3Ampsormorebasedonyourproject.Tosupplythisfromabattery,youcanuseoneofseveraldifferentchoices.Mypersonalfavoriteistouseanemergencycellphonechargingbattery,likethis:

Ifyouaregoingtousethis,you’llneedaUSB-to-2.1mmDCplugcable,availableatmostonlinestores.Onceyouhaveuploadedthecode,youcandisconnectthecomputer,thenpresstheresetbutton.Yourrobotcanmoveallbyitself!

SummaryBynow,youshouldbefeelingabitmorecomfortablewithconfiguringHWandwritingcodefortheGalileo.Thisexampleisfun,andprovidesyouwithamovingplatform.Inthenextchapter,you’llchangethisplatformfromonebasedonDCmotorstoonebasedonservos,andyou’llbuildarobotthatcanwalk.

Chapter5.AddingSensorsInChapter4,ControllingDCMotors,youlearnedhowtousetheGalileotocontrolDCmotors.Inthischapter,you’lllearnhowtoaddsensorstoyourprojects.Sensorsareimportantbecauseyoucanusethemtofind,oravoid,objects.Youcanusethemtosenseyourdirectionandspeed,andalsotemperature.Youcanalsousethemtosenseacousticandelectromagneticwaves,pressure,andmanyotherphysicalphenomena.OneofthechallengesofusingtheGalileoisthatitusestheLinuxoperatingsystematitscore,sotherearechallengesifasensorneedstodoreal—timeprocessingofsignalswithtighttiming.Linuxisnotareal-timeoperatingsystem,andmightbedoingotherthingswhenyouneedtomakesomethingspecifichappen.Thiswilllimitsomeofthesensorsyoucanuseonyourproject.ForacompletelistofsensorsandotherhardwarethatarecurrentlysupportedbytheGalileo,seehttps://communities.intel.com/docs/DOC-23423.ThegoalofthischapteristowalkyouthroughafewoftheexamplesfromthislisttoshowyouhowtoconnectsensorstotheGalileo.

SensingdistanceTherearetwobasicsensorsthatwillreturninformationonthedistancetoanobject:sonarandinfrared.Inthecaseofsonar,thesensorusesultrasonicsoundtocalculatethedistancetoanobject.Thesensorconsistsofatransmitterandreceiver,thetransmittercreatesasoundwavethattravelsoutfromthesensor,asillustratedhere:

Thedeviceistriggeredbyanelectronicsignaltosendoutasoundwave.Ifanobjectisinthepathofthesewaves,thenthewavesreflectofftheobject,sendingwavesthatreturntothesensor,asshownhere:

Thebasicsensorthenmeasuresthereceivedsoundwaveandsendsoutanelectronicsignal.Theusercanthencalculatethetimedifferencebetweenwhenthesoundwavewassentoutandwhenitreturnstomeasurethedistancetotheobject.Unfortunately,thereturntimemustbemeasuredwithprecisionforthistypeofsensortowork.ThisischallengingforaprocessorsuchastheGalileo,thatrunsLinuxasthebaseoperatingsystem.Therearewaystomakethiswork,butitisnotsimple.Pleaseseetheshieldcompatibilityguideathttps://communities.intel.com/docs/DOC-23423fordetails.

TheInfraredsensorNow,alittletutorialonIRsensors.Thesensoryouareusinghasbothatransmitterandasensor.Thetransmittertransmitsanarrowbeamoflight,andthesensorreceivesthisbeamoflight.Thedifferenceintransitendsupasananglemeasurementatthesensor,asshownhere:

Thedifferentanglesgiveyouanindicationofthedistancetotheobject.Unfortunately,therelationshipbetweentheoutputofthesensorandthedistanceisnotlinear,soyou’llneedtodosomecalibrationtopredicttheactualdistanceanditsrelationshiptotheoutputofthesensor.

Thevoltagetodistancechartforthedevicelookslikethis:

Thiskindofchartwillcomefromthesensor’sdatesheet.Therearereallytwopartstothecurve;thefirstisthedistanceuptoabout15centimeters,thenthedistancefrom15centimetersoutto150centimeters.Youcansimplifythecodeifyouignoredistancescloserthan15centimeters,andmodelthedistancefrom15centimetersandoutasadecayingexponentialwiththeformConstant*InputValue-exponentialvalue.Thiswillbethecalculationthatyouwilluselaterintheprogram.

ConnectinganIRsensortotheGalileoThefirststepinconnectinganIRsensortoyourGalileoistoobtainasensor.OnepopularchoiceistheSharpseriesofIRsensors.Thefollowingimageshowsoneofthemodels,theSharp2Y0A02,aunitthatprovidessensingtoadistanceof150cm:

Toconnectthisunit,you’llconnectthethreepinsthatareavailableonthebottomofthesensor.Hereistheconnectionlist:

GalileoPin SensorPin

5V Vcc

GND Gnd

A3 Vo

Unfortunately,therearenolabelsontheunit,butherearethepinsyou’llconnect:

Oneofthechallengesofmakingthisconnectionisthatthefemale-to-maleconnectionjumpersaretoobigtoconnectdirectlytothesensor.You’llwanttoorderathree-wirecablewithconnectorswiththesensor.Manyversionscomewiththiscable.YoucanmaketheconnectionsbetweenthiscableandtheGalileousingthemale-to-malejumperwires.Hereisthediagram:

Oncethepinsareconnected,youarereadytoaccessthesensorviatheIDE.

AccessingtheIRsensorfromtheGalileoIDENowbringuptheIDE.Thefollowingthatprovidesaccesstothesensorandreturnsviatheseriallinkthedistancetotheobject:

Thisisquitesimple.Thethreeglobalvariablesatthetopsettheinputpinto3,andprovideastoragelocationfortheinputvalueanddistance.Thesetup()functionsimplysetstheserialportbaudrateto9600andprintsoutsinglelinetotheserialport.TheSerialMonitorcommunicateswiththeGalileoviaaserialport,andthebaudratespecifiesthecommunicationratebetweentheGalileoandthehostcomputer.

Intheloop()function,youfirstgetthevaluefromtheA3inputpin.Thenextstepistoconvertittoadistancebasedonthevoltage.

IfyouopentheSerialMonitorwindowandplaceanobjectinfrontofthesensor,you’llseethereadingsforthedistancetotheobject,likethis:

Bytheway,whenyouplacetheobjectcloserthan15cm,youshouldbegintoseedistancesthatseemmuchlargerthanindicated.Thisisduetothevoltage-to-distancecurveatthesemuchshorterdistances.Ifyoutrulyneedveryshortdistances,you’llwantadifferentsensor.

ConnectingadigitalcompasstotheGalileoOneoftheimportantpiecesofinformationthatmightbeusefulforyourprojectisitsdirectionoftravel.ThiscouldbegivenbyaGPSunit,butaGPSunitcanbeexpensive,anditoftendoesn’tworkwellinsidebuildings.Youcanalsojust“keeptrack”ofthedirectionassociatedwithyourhardware,butyou’llneedtocarefullyupdatethiswheneveryourprojectmightmove.Usingacompassfreesyoufromalwayshavingtokeeptrack,andwillalsoallowyoutoavoidinaccuraciesthatcanaccumulatefrominaccuraciesinyourcontrolsystem.So,let’slearnhowtohookupadigitalcompasstotheGalileo.

Thereareseveralchipsthatprovidedigitalcompasscapability;oneofthemostcommonistheHMC5883L3-AxisDigitalCompasschip.Thischipispackagedontoamodulebyseveralcompanies,butalmostallofthemresultinasimilarinterface.HereisanimageofonebyacompanycalledSainSmart,thatisavailableatanumberofonlineretailers,suchaswww.amazon.com:

Theconnectionstothischiparestraightforward,thedevicecommunicateswiththeGalileousingtheI2Cbus,astandardserialcommunicationsbus.Onthebackofthemodule,theconnectionsarelabelled,likethis:

Herearetheconnectionsthatyou’llneedtomakebetweentheGalileoandthedevice:

GalileoPin SensorPin

5V 5V

GND GND

A5 SCL

A4 SDA

Youwon’tconnecttothe3.3voltpin,asyouareusingthe5volttoconnecttothedevice.TheDRDYpinisanoptionalconnectionthatisusedwhenyouwanttocommunicateathigherdatarates.NowyouarereadytotalkwiththedeviceusingtheIDE.

AccessingthecompassfromtheIDEThefirststepinaccessingthecompasscapabilityfortheIDEistoinstallalibrary.Findingalibrarytosupportthemoduleisabitdifficult,buttheonethatworkswellforthisdeviceisavailableatwww.emartee.com/product/42254/HMC5883L%203%20Axis%20Digital%20Compass%20Module

Followthesestepstoinstallthelibraryandruntheexample:

1. SelecttheArduinoLibraryforHMC5883Llinkonthispageanditwilltakeyoutoasetoflibraryselections.

2. YouneedtoselecttheHMC5883L/HMC5883LLibraryforArduino.rarlinktowardsthebottomofthispage,andthiswilldownloada.rarfilethatholdsthelibrary.

3. UnzipthisfileintothelibrariesdirectoryofyourGalileoIDEinstallation.4. Now,bringuptheIDE.IftheIDEwasalreadyopen,you’llwanttocloseitandopen

itagainsoitcanrecognizethenewlibrary.SelectFile|ExamplesandyoushouldbeabletoselecttheHMC5883Llibraryexample,likethis:

Onceyouhaveselectedthisexample,uploadittoyourGalileoandopentheSerialMonitor.Youmighthavetoresizethedisplaytogetagoodlookattheresults,butyoushouldseesomethinglikethis:

Nowyoucanadddirectiontoyourproject!Asyoumovethedevicearound,youshouldseetheHeadingvaluechange.Thisisveryusefulforhelpingyougivedirectiontoyourprojects.Thefirstthreenumbersaretherawmagneticsensorreadings,andthemiddlethreeareanglereadingsfromthemagnetsensors.Thelasttwoaretheheadingsinradiansanddegrees.Themagneticsensorissensingthemagneticfieldoftheearth.Asyoumovethedevicearound,youshouldseethesereadingschange.Thisdatacanbethenusedtosensewhatdirectionyourprojectisfacing.Thedevicehaslotsofcapability,includingtheabilitytocalibratethedevicesothataparticularpositionisinthe0position.Formoreinformationaboutthesecapabilities,feelfreetolookatbothexampleprogramsprovidedbythelibrary.However,youmightwanttoaddevenmoreinformationtoyourproject,suchasthespeedandtilt.Fortunately,therearesensorsforthisaswell.

ConnectinganaccelerometerorgyrototheGalileoTheabilitytomeasurespeedandtiltisimportantinmanyroboticsapplications.Thiscantellyouhowfastyourrobotistraveling,andinwhatdirection.Fortunately,therearechipsthatcandothisforyou.OneofthoseistheMPU-6050,whichprovidesacompletesetofinformationonmovement,includingaccelerationandtilt.Formoreinformationonthistypeofdevice,seehttps://www.sparkfun.com/pages/accel_gyro_guide.ThereareseveraldifferentmanufacturerswhoplacethischiponasmallboardaccessibletotheGalileo.OneoftheseistheSparkFunversion,theSparkfunSEN-11028,availableatwww.sparkfun.com.Itispicturedhere:

Theinterfacetotheboardisquitesimple,withonlyoneissue.ThisparticularchipwillrequireyoutosolderheaderpinstotheboardtoconnectthejumperwirestotheGalileo.Youcanpurchasetheseatwww.sparkfun.comaswell,justsearchfortheArduinostackableheader,the10-pinversion.Or,ifyoudon’tliketosolder,youcantryasolderlessversion,athttps://www.sparkfun.com/products/10527.Oncetheheaderisconnectedtotheboard,thedevicewilllooklikethis:

Nowyoucanusemale-to-malejumpercabletoconnecttheGalileoandtheboard.Hereisthetablefortheconnections:

GalileoPin SensorPin

3.3V VDD

GND GND

A5 SCL

A4 SDA

3.3V VIO

You’llnoticethatyouneedtomaketwoconnectionstothe3.3Vsupply,soyoumightwanttocreateamale-to-malejumpercablewithtwoconnectionsononeend.Thiscanbedonebyusingtwomale-to-malecables,bycuttingoffoneendandstrippingbacktheinsulation,solderingthethreecablestogether,andthenwrappingthesolderconnectioninelectricaltape.

AccessingtheaccelerometerfromtheIDENowthatthetwodevicesareconnected,you’llneedtobringuptheIDEandaddalibrarysothatyoucanaccessthefunctionalityfromtheSW.Togetthelibraries,dothefollowingsteps:

NoteFromtheSparkfunpageonthedeviceatwww.sparkfun.com/products/11028you’llfindagithubrepositorythatsupportsnotonlythisdevice,butanumberofdevicesthatusetheI2Cinterface.

1. Gotohttps://github.com/jrowberg/i2cdevlibandlookontherightsideofthepageforthedownloadlink.Thiswilldownloadtheentirelibrary.

2. Nowyoushouldunzipthefiletoahandylocation,Iunzippedmineinthedownloaddirectory.WhatyouwantisjustthefilesassociatedwiththeArduino,sogotothedirectorythatsupportsthosefiles,likethis:

3. Eventhoughyouwon’tneedalltheselibrariesrightnow,youcanjustcopyallthesetothelibrariesdirectoryofyourGalileoforfutureuse.Bytheway,you’llnoticethatthereisaduplicateoftheHMC5883Llibraryyouinstalledearlier,soyoucandecidetomergethesedirectories.

4. Onceyouhavethesedirectoriesinstalled,bringuptheGalileoIDE.IftheIDEisalreadyrunning,you’llwanttorestartitsoitcanrecognizethelibrary.NowbringuptheexampleprogramthatreadstherawvaluesoftheaccelerometerandgyrobyselectingExamples|MPU6050|Examples|MPU6050_raw,likethis:

Thiswillopenawindowthatprovidesthecodetoreadtherawdatafromyoursensor.WhenyouuploadthecodeandopentheSerialMonitor,youshouldseesomethinglikethis:

Thefirstthreenumbersarethex,y,andzrawaccelerometerreadings,andthelastthreearex,y,andzanglereadingsfromthegyroscope.Ifyoumountthedeviceflatinyourproject,x,y,andzwouldbeassociatedwiththeyaw,pitch,androllofthedevice.Hereisadiagramofhowtheyaw,pitch,androllindicatethepositionofadevice:

Asyoumovethedevicearound,youshouldseethesereadingschange.Thisdatacanthenbeusedtosensewhenyourdeviceismoving,andinwhatdirection.Thedevicehaslotsofcapability,includingtheabilitytosettheoffsetsofthedevicesothataparticularpositionisinthe0position.Formoreinformationaboutthesecapabilities,feelfreetolookatbothexampleprogramsprovidedbythelibrary.

Connectinganaltimeter/pressuresensortotheGalileoThefinalsensoryou’lllearnaboutinthischapteristhealtimeter/pressuresensor.Thealtimeterisusefulwhenyouwanttoknowthealtitudeofyourproject.Thisisparticularlyusefulwhenyouwanttobuildarobotthatcanfly.Formoreonpressuresensorsandhowtheywork,seehttp://www.sensorsmag.com/sensors/pressure/fundamentals-pressure-sensor-technology-846.First,you’llneedtoselectadevice.OnedevicethatcanprovidethisinformationistheSainSmartBMP085Module,DigitalBarometricPressureSensor,availableatmanyonlineretailers,includingwww.amazon.com.Thisdeviceusespiezo-resistivetechnologytomeasurealtitude.Thefollowingimageshowsthis:

Itlooksverysimilartothedigitalcompass;justlikethetwopreviousdevices,itconnectsviatheI2Cinterface.Youcanevenusethesamelibrariesyoujustdownloadedfortheaccelerometer/gyroforI2Csupport.

TheconnectionsbetweentheGalileoandthedevicewillbethesameasthedigitalcompass,likethis:

GalileoPin SensorPin

5V 5V

GND GND

A5 SCL

A4 SDA

Theconnections,justlikethoseofthedigitalcompass,areclearlymarkedonthebackofthedevice,andyoucanusethefemale-to-malejumperstomaketheconnections.

Accessingthealtimeter/pressureSensorfromtheGalileoIDEAswiththeprevioustwoexamples,thefirststepinaccessingthedeviceistodownloadtheappropriatelibrary.Youcanusethelibrarydescribedinthesectionontheaccelerometer/gyro,oryoucandownloadalibraryjustforthisdevice.Ifyouwanttodownloadthelibraryforthisdevice,gotowww.sainsmart.com/sainsmart-bmp085-digital-pressure-sensor-module-board.htmlpageandselecttheDownloadLinkselectiontowardsthebottomoftheDescription.Thiswilldownloada.rarfilethatwillincludeanexamplesketch.IpersonallyprefertousetheI2Clibraryversion,itismoreup-to-date,soIwillfollowthatexamplehere.

OpentheexamplebyselectingFile|Examples|BMP085|Examples|BMP085_basic,likethis:

NowyoucanuploadthesketchontheGalileoand,whenyouopentheSerialMonitor,youshouldseesomethingthatlookslikethis:

Youcanseenotonlythealtitude,butthetemperatureandpressureaswell.TheTisthetemperatureinCelsius,thePisthepressureinPascals,andtheAisthealtitudeinmeters.

SummaryTherearemanymoresensorswecouldhavecoveredinthischapter,buthopefullyyouhaveafeelforhowyoumightbeabletoaddthemafterfollowingtheinstructionsforthesesensors.Yourprojectnowhaslotsofpossiblecapabilities,butyouarestilltetheredtothecomputer.Inthenextchapter,you’lllearnhowtocommunicatewithyourprojectwirelesslysoitwon’tneedacabletoacceptcommands.

Chapter6.RemoteControlNowyoumightwantyourprojecttobemobile.You’llatleastwanttodisconnectitfromthetethercablethatyouhavebeenusingtocommunicatewithittosendcontrolcommands.Inthischapter,you’lllearnhowtocommunicatewirelesslywithyourproject.Dependingonyourchoiceofdevice,you’llbeabletocommunicateacrosstheroomoracrossadistanceofuptoamile.

Inthischapter,you’lllearnthefollowing:

HowtocommunicatewiththeGalileousinganXBeetransmitter/receiver,apoint-to-pointcommunicationsystemthatallowsyoutocommunicatebetweentwoGalileosorbetweenaGalileoandahostcomputerHowtoconfiguretheGalileousingaWi-FiminiPCIExpresscardsoyoucancommunicateviaWirelessLAN

ConnectinganXBeeinterfacetotheGalileoOneofthemostpopularandwell-documentedwaysofconnectingtotheGalileoviaanRFconnectionistouseanXBeedevice.ThisdeviceusesatechnologycalledZigBeeanditismadeforlonger-rangewirelesscommunications.Thesetypesofdevicescanworkuptoarangeofonemile.TheZigBeestandardisbuiltupontheIEEE802.15.4standard,astandardthatwascreatedtoallowasetofdevicestocommunicatewitheachothertoenablelowdataratecoordinationofmultipledevices.

TheotherstandardthatyoumighthearaboutasyoutrytopurchaseorusedevicessuchastheseisXBee.Thisisaspecificcompany’simplementation,Digi,ofseveraldifferentwirelessstandardswithstandardhardwaremodulesthatcanconnectinmanydifferentwaystodifferentembeddedsystems.TheymakesomethatsupportZigBee.HereisanimageofthistypeofdevicethatsupportsZigBeeattachedtoasmall,XBee-specificshieldthatprovidesaUSBport:

TheadvantageofusingthisdeviceisthatitisconfiguredtomakeitveryeasytocreateandmanageasimplelinkbetweentwoXBeeseries#1devices.Tomakethiswork,you’llneedfouritems:

1. MakesureyouhavetwoXBeedevicesthatsupportZigBeeseries#1.2. You’llalsoneedtopurchaseasmall,XBee-specificshieldthatprovidesaUSBport

connectiontooneofthetwodevices.Thiswillprovidecommunicationfromahostcomputer.

3. You’llalsoneedtobuyashieldthatplugsintoyourArduinosoyoucaninterfacetotheXBeedevices.ThisshieldistheWirelessSDcardshield,andhasheaderpinsreadyfortheXBeedevice.HereisanimageoftheshieldpluggedintoaGalileo,

withtheXBeedevicepluggedin:

Nowlet’sgetstartedwithconfiguringyourtwodevicestotalk.

ConfiguringtheXBeedevicesYou’llneedtoconfigurebothdevicesbypluggingthemintoyourhostcomputer.Plugoneofthedevicesintothesmall,XBee-specificUSBshieldandthenconnecttheshieldtoyourpersonalcomputer.Yourcomputershouldfindthelatestdriversforthedevice.Ifyourcomputerdoesnotfindthedeviceorisunabletocorrectlyinstallthedrivers,seehttp://ftp1.digi.com/support/images/Win7DriverInstall.pdfforhelp.Youshouldseeyourdeviceafteryou’veselectedDevicesandPrintersfromtheStartmenu,likethis:

ThedeviceisnowavailabletocommunicateviatheIEEE802.15.4wirelessinterface.YoucouldsetupafullZigBee-compliantnetwork,butyou’rejustgoingtocommunicatefromonedevicetoanotherdirectly,soyou’lljustusethedeviceasaserialportconnection.Double-clickonthedevice,selecttheHardwaretab,andyoushouldseethis:

NotethatthedeviceisconnectedtotheCOM20serialport.You’llusethistocommunicatewiththedeviceandconfigurethedevice.Youcanuseanyterminalemulatorprogram;IliketousePuTTY.Ifyoudon’thavePuTTY,youcandownloaditfromwww.chiark.greenend.org.uk/~sgtatham/putty/download.html.Thiswillprovideanexecutablethatyoucanruntotalkwithandconfigurethedevices.

NoteDigihasrecentlyintroducedanewgraphicaltoolforconfiguringXBeedevices.ItprovidesaccesstoalltheconfigurationsettingsontheXBee.Ifyouwouldliketousethistool,seehttp://www.digi.com/products/wireless-wired-embedded-solutions/zigbee-rf-modules/xctu

Performthefollowingstepstoconfigurethedevice:

1. OpenupPuTTY,selectSerial,andthe(inthiscase)COM20port.HereishowtofillinthePuTTYwindowtodothis:

2. Configuretheterminalwindowasshowninthescreenshot:

3. Now,intheTerminalwindow,makesureyoualsoselectLocalechoForceon,andchecktheImplicitCRineveryLFandImplicitLFineveryCR(availableunderTerminalintheCategory:selection.):

4. ConnecttothedevicebyselectingOpen.5. Enterthefollowingcommandsbytypingthemintotheterminalwindow:

TheOKresponsecomesbackfromthedeviceasyouentereachcommand.Thefirstdeviceisnowconfigured.Removeitfromthesmall,XBee-specificshieldandplugitintotheArduinoXBeeshield.

Nowplugtheseconddeviceintothesmall,XBeeshieldandthenplugitintothePC.NotethatitmightchooseadifferentCOMport,gototheDevicesandPrintersoption,double-clickonthedevice,andselecttheHardwaretabtofindtheCOMport.Followthesamestepstoconfiguretheseconddevice,excepttherearetwochanges.Hereistheterminalwindowforthesecommands:

Thetwodevicesarenowreadytocommunicate.

ConfiguringthedeviceusingaMacisverysimilar.Followthesestepstostartaterminalconnectionwiththedevice:

1. PlugtheXBeemoduleintotheXBeeshieldandhookittoyourMacviaUSB.2. OpenupaCoolTermwindowandthenhittheOptionsonthetoolbar.3. SelectthecorrectportforyourXBeedevice.Itwilllooksomethinglikeusbserial-

XXXXXXXX.4. Ifyourdevicedoesn’tappear,plugitbackinandclickonRe-ScanSerialPorts.5. HittheOkbuttonandtherestofthedefaultswillworkjustfine.6. HittheConnectbuttononthetoolbarandyoushouldbetalkingtoyourXBee.

Nowyoucanconfigureyourdeviceasshownpreviously.IfyouareusingLinuxtoconfigureyourdevice,youwillsimilarlyopenaterminalwindow,connectittotheproperUSBserialport,andthenconfigurethedevice.

EnablinganXBeeInterfaceintheIDELet’sfirstsetuptheIDEfortheXBeethatwillbeconnectedtotheGalileo.OnceyouhaveconnectedtheshieldtotheGalileo,simplyconnecttheGalileowiththeUSBcabletoyourhostcomputers.BringuptheIDEandthentypeinthefollowingcodeintothesketchwindow:

Hereisanexplanationofthissetofcode:

ThissetofcodeinitializestheserialportontheGalileo,soyoucanreceiveviatheserialinterface:

TTYUARTClass*gSerialStdPtr=&Serial;//Galileo,/dev/ttyGSO,Txpin

TTYUARTClass*gSerialTwoPtr=&Serial1;//Galileo,/dev/ttySO,Rxpin

boolgGalileo=true;

boolqData;

intled=13;

Thissetofcodestartsthesendandreceiveprocess,you’llonlyusethereceiveprocessforthisapplication:

qData=false;//Initializeonreset

gSerialStdPtr->begin(9600);//Receiver

gSerialTwoPtr->begin(9600);//Sender

waitForUser(5);//Giveusrtimetoopenserialterminal

gSerialStdPtr->println("XBee-Receiver-setup");

pinMode(led,OUTPUT);

ThiscodewaitsforavalidinputfromtheserialportontheXbeeandthenprintsittotheSerialMonitorscreen.ItalsotakesthedataandturnsontheonboardLED,connectedtoPin13,iftheinputisa1;itturnsitoffifthedataisa0:

if(qData==false)

gSerialStdPtr->println("XBee-Receiver-waiting");

//GetdatafromSenderandprinttoReceiverserialport

while(gSerialTwoPtr->available())

{

charc=gSerialTwoPtr->read();//ReadXBeedata

if(c=='1')

digitalWrite(led,HIGH);

if(c=='0')

digitalWrite(led,LOW);

gSerialStdPtr->write(c);//Writelocal

qData=true;

}

if(qData==false)delay(1000*1);//Slowdownuntildataisrec

}

Thiscodewaitsforasettimefortheusertobringuptheserialport:

voidwaitForUser(unsignedintaSec)

{

//Giveusertimetobringuptheserialport

for(inti=aSec;i>0;i--)

{

delay(1000*1);

gSerialStdPtr->print(i);

}

gSerialStdPtr->println("");

}

Oncethecodeisuploaded,you’llneedtophysicallychangeaswitchsettingontheWirelessShield,sothedevicewillnowacceptcommandsfromyourXBeecontroller.Itisontheoppositeendoftheshieldfromthedevice,andlookslikethis:

ThisswitchconnectstheXBeetoeithertheUSBserialportorthemicrocontroller(inthiscase,theGalileo)serialport.ChangeittotheMICROsettingonceyoursketchhasfinishedcompilationanduploadedtotheGalileo.

NowconnecttheotherXBeedeviceviathesmall,Xbee-specificUSBshieldtothe

computer.OpenPuTTYoranotherterminalemulatorwindow.Makesureyousettheterminalemulatordatarateto9600baud.InPuTTY,yourconfigurationwilllooklikethis:

Nowopentheterminalwindow.YoushouldnowbeabletoentercommandsintothePuttywindowandmonitorthemusingtheSerialMonitorontheGalileo.HereisapictureofthePuttyapplication:

HereiswhatyoushouldseeifyouopentheSerialMonitoronyourGalileo:

Mostimportantly,eachtimeyouentera1youshouldseetheLEDontheGalileoturnonand,whenyoutypea0,youshouldseeitturnoff.Now,ifyoursystemisnotworking,thereareacoupleofwaystotryanddeterminewhatisgoingwrong.Firstandforemost,makesuretheGalileoisturnedonandisexecutingthecorrectcode.Second,checktoseethatcharactersarebeingtypedinthePuttywindow.Third,checkthebaudrateofthePuTTYwindow.Ifitistoohigh,youwillseecharacterscomethroughthesystem,butyoutheywillnotbeinterpretedcorrectlyontheGalileo.Fourth,makesureyouactuallyconfiguredboththedevicesinsteadofjustone.Fifth,makesuretheserialswitchontheXbeeshieldisintherightposition.Finally,makesurethedevicesareinrange.

ConfiguringaWi-FiconnectionontheGalileoYoucanalsocommunicatewiththeGalileoviaWirelessLAN.Todothis,you’llneedsomeadditionalhardware.Thefirstpieceofhardwareyou’llneedisaminiPCIwirelessdevice.ThebasicGalileoPokyoperatingsystemsupportstwodevices:theIntel®Centrino®Wireless-N135andIntel®Centrino®Advanced-N6205adapters.Ifyoudon’twanttocompileyourowndrivers,youshouldpurchaseoneofthesetwodevices.

NoteIfyouwishtopurchaseadifferentminiPCIwirelessdevice,seehttp://www.malinov.com/Home/sergey-s-blog/intelgalileo-addingwififorhowtocompiledriversforyourdevice.

You’llalsoneedsomecablesandantennas.You’llneedtwo6dBiRPSMAantennasandtwo8-inchUFLcables.Therearekitsavailable,forexampleathttp://www.amazon.com/gp/product/B00DP64JRG.AlsousefulisaHalftoFullHeightMiniPCIExpress(PCI-E)CardBracketAdapter,thismakesthewirelesscardeasiertoinstall.Onceyou’vegatheredallthehardware,installthecardintotheGalileo.Itisstraightforwardbut,ifyougetconfused,followtheinstructionsathttp://ionospherics.com/intel-galileo-setting-up-wifi/toinstallallthehardwareintotheGalileo.Hereiswhatitshouldlooklike:

Onceyouhavethewirelesshardwaresetup,you’llalsoneedacabletoestablishaterminalconnectiontotheLinuxoperatingsystemonyourdevice.FortheIntelGalileoGen2board,thecableyouwillneedisaUSBconnectorononeendandaFDTI6pinconnectorontheother.Theseareavailableatmostonlineelectronicsstores:

IfyouareusingtheGalileoGen1board,thisis3.5mmtoUSBcable.PlugthiscableintotheterminalportontheGalileo,andtheUSBconnectoronyourhostcomputer.

Nowthatyouhaveallthehardware,herearethestepstogetyourGalileoupandconnectedtoWi-Fi:

1. First,you’llneedanewversionoftheLinuxoperatingsystemforyourGalileo.Togetthisgotohttp://www.intel.com/content/www/us/en/do-it-yourself/downloads-and-documentation.html#galileosoftwareandselectDownloadSD-CardLinuxImageforIntelGalileo(48MB,.bz2).Thiswilldownloada.tarfile(anarchivedfile)withthesupportforyourwirelessconnection.

2. You’llneedtoun-archivethisfileusinganarchiveutilitysuchas7-Zip.3. NowcopyallthefilesundertheSDCarddirectoryontoamicroSDcard.4. You’llneedaterminalwindowtointeractwithyourGalileo.Ifyouareusing

Windows,you’llneedaterminalemulatorwindowtocommunicatewiththeGalileo.Onepopular,freeversioniscalledPutty.FormoreinformationonPuttyandhowtodownload,seehttp://www.chiark.greenend.org.uk/~sgtatham/putty/.However,anyterminalemulatorprogramwilldo.BothLinuxandtheAppleOScomewithterminalemulatorprograms.

5. OpenaterminalwindowandselecttheserialportthatisconnectedtotheUSBtotheFTDIconnectorusingabaudrateof115200.EverytimetheGalileoboots,itwilllookforanimageontheSDcardandbootthatimageifitispresent.Ifitisnotpresent,itwillbootthePokyversionthatisintheinternalmemory.Theterminal

windowwillallowyoutoselectbetweenthetwo.You’llnowwanttoboottheunitusingthemicroSDcardandthenewversionoftheGalileooperatingsystembyinstallingthecardandapplyingpower.Youshouldseethisbootupscreen:

Ifnotalreadyhighlighted,selectthesecondchoiceheretobootfromthecard.

6. Nowlogintothesystemusingrootastheuser.7. Typeifconfig–a.ThisshouldshowallLANinterfaces,andshouldlooklikethis:

Youcanseethewlan0interfacethatisnowavailabletoconnecttoyourWi-Finetwork.However,thereisnoaddressassigned;asyoucansee,thereisnoinetaddr:lineinthewlan0section.YoucanusetheIDEtoconnecttoyournetwork,thiswillbeshowninthenextsection.

NoteIfyouwanttoautoconnecttoagivennetworkeachtimeyouboottheGalileo,you’llneedtoaddyourwirelessnetworkIDandpasswordtothewpa_supplicant.conffile.Todothis,typewpa_passphraseWIFI-SSIDWIFI-PASSPHRASE>/etc/wpa_supplicant.conf.

8. YouwillneedtoeditonemorefiletoensureaccesstotheWi-FiconnectioneachtimeyoubootyourGalileo.Thefileis/etc/networks/config.Editthisfileusingvi(viistheeditorthatcomesonthisLinuxrelease.)Addautowlan0asthelastline.

9. Rebootyoursystem,asbefore.Log-inusingrootastheuser.

Nowthatthehardwareisconnected,youcanaccessthewirelesscapabilitiesinsidetheIDE.

UsingWi-FifromtheIDENowthatthehardwareisup-and-running,youcanruntheexamplesintheIDE.IfyoubringuptheIDEandselectExamples|Wi-Fi,youcanseethattherearemanychoices:

ThemostbasicofthesechoicesistheScanNetworkssketch.IfyouselectthissketchandthenopentheSerialMonitorWindow,youshouldseesomethinglikethis:

Theothersketchesprovidefurthercapabilities.TherearesketchesthatshowhowtoconnectusingWPAorWEPsecurityprotocols.OneofthemostusefulistheSimpleWebServerWi-FithatshowshowtoturnanLEDonandoffovertheWi-Finetworkviaanexternalwebpage.SimplyconnectaresistorandLEDinseriesbetweenGNDanddigitalIOpinnine,editthesketchtoincludetheSSIDandpasswordofyournetwork,andthenopenawebbrowser.WhenyouopentheSerialMonitor,itwillshowyouconnectedtothenetwork:

Nowgoonthehostcomputerandentertheaddressshownintheaddressline.The

followingshouldappearonyourbrowser:

YoucannowturntheLEDonandoff.

SummaryAsyounowknow,thereareseveralusefulwaysofconnectingwirelesslywithyourArduino.Inthischapter,you’velearnedhowtoconnectyourprojectwirelesslyusingXBee,areliablelong-rangeinterface.You’vealsolearnedhowtoconnectviaWi-Fi.Nowyourprojectcangountethered,needingonlyanoccasionalbatterychargetokeepitup-and-running.Inthenextchapter,you’lllearnhowtoaccesstheLinuxsystemonGalileoandaccessevenmoreinterestingcapabilities.

Chapter7.GoingFurtherwithGalileoWithyourGalileo,you’velearnedhowtobuildprojectsthatcanroll,nowlet’sbuildonethatcanwalk.Inthisfinalchapter,you’llmovefromusingthesimpleGalileoIDEtousingtheLinuxcapabilitiesoftheGalileotodriveanexternalUSBservocontrollersothatyoucancontrolthe12servosthatwillmakeyourquadrupedmove.

Inthischapter,youwilllearnhowtousetheGalileo’sLinuxcapabilitiestocontrolabasicquadrupedplatform.Todothisyouwilllearnthefollowing:

Galileo’sLinuxcapabilitiesHowservosworkHowtousetheGalileo’sLinuxcapabilitiestocontrolaservocontrollerthatcancontrollotsofservosCreatingcomplexmovementsoutofsimpleservocommands

TheGalileoandLinuxWhileyouhavebeenaccessingtheGalileoexclusivelythroughtheIDE,theGalileoactuallyhasbeenrunningaversionoftheLinuxoperatingsystemallalong.LinuxisanoperatingsystemsimilartoWindows,ortheAppleMacoperatingsystem.Infact,theMacoperatingsystemisbuiltuponaversionofUnix,whichisverysimilartoLinux.NowLinux,unlikeWindows,Android,orIOS,isnottightlycontrolledbyasinglecompany.Itisagroupeffort,mostlyopensource,andwhileitisavailableforfree,itgrowsanddevelopsbasedoncommunitydevelopmentandsupport.

Thus,anumberofdistributionshaveemerged,eachbuiltonasimilarkernel,orcoresetofcapabilities.ThesecorecapabilitiesareallbasedontheLinuxspecification.However,theyarepackagedslightlydifferently,anddeveloped,supported,andpackagedbydifferentorganizations.Angstromisoneoftheseversions.Debianisanother.Thereareothersaswell.TheoneincludedintheinternalmemoryassociatedwiththeGalileoiscalledPoky,andisbuiltusingasetoftoolscalledYocto.YoctoisatoolkitthatallowsuserstobuildtheirownLinuxdistribution.

Forthisproject,you’regoingtocreateanewSDcardimageofLinuxwithaDebiandistribution,installitonamicroSDcard,andboottheGalileofromthecard.ThisisaverypopularversionofLinuxthatsupportsawiderangeofdifferentcapabilities.

Nowyou’llneedtoconnecttheGalileototheLANtoaddcapability.Therearetwowaystodothis.Thefirstisusingawiredconnection;youcansimplyconnecttheGalileodirectlybyconnectingaLANcabletotheconnectorontheGalileo.YoucanalsoconnecttheGalileousingaWi-Ficonnection.ThisrequiresyoutoaddadditionalHardwareandconfigureyourWi-Ficonnection.Seehttps://software.intel.com/en-us/blogs/2014/03/13/configuring-wifi-for-the-intel-galileo-boardorhttp://www.hackshed.co.uk/how-to-use-wifi-with-the-intel-galileoformoreinformationonhowtoassemble,configure,andconnectyourGalileotoaWi-Finetwork.

CreatingandbootingtheDebianLinuxSDcardimageontheGalileoHerearethestepstofollowtoinstallandruntheDebianimageonyourGalileo:

1. Thefirstthingyou’llneedisaDebianLinuximagethatsupportsLANandDHCP.Thesiteathttps://communities.intel.com/message/231688hasaversion,thereareothers.Ifyougotothissite,youcandownloadthisfile.

2. IfyouareusingWindowsonyourcomputer,thisfilewillnowexistinyourDownloadsdirectory.Unzipthisfileandyoushouldendupwithagalileo.imgfile.

3. NowyouneedaprogramthatwillwritethisfiletoamicroSDcard.IfyouareusingWindows,downloadtheprogramWin32DiskImagerfromhttp://sourceforge.net/projects/win32diskimager/.InstallthisprogramonyourPC.IfyouareusingLinux,youcanusetheddcommandtowritetothecard.

4. IfyouareusingaPC,runWin32DiskImager.InsertyourmicroSDcardintoyourPC.YoumightneedamicroSDtoUSBadapterforthis.Now,specifythefileandthecardinWin32DiskImager,likethis:

Becarefulinselectingthedevice,youcancorruptadriveifyouchoosethewrongone.IfyouareusingLinux,usethecommandsudoddif=galileo.imgof=sdXwherethesdXisthelocationofthecardyouwanttowriteto.

5. NowtakethecardandinsertitintotheGalileo’smicroSDslot.6. Tomonitoryoursystem,youwillwanttoconnectaterminalcablebetweenthe

Galileoandyourhostcomputer.IfyouareusingtheGalileoGen2board,thecableyouwillwantwillhaveaUSBconnectorononeendandaFDTI6pinconnectorontheother.Theseareavailableatmostonlineelectronicsstores:

IfyouareusingtheGalileoGen1board,thisisa3.5mmtoUSBcable.

7. You’llnowwanttoboottheunitusingthemicroSDcardandDebianbyapplyingpower,butfirstalsoconnecttheLANcableandserialcable.FortheGalileoGen2,theserialcableconnectsrightnexttotheLANconnector;thereisa6pinFTDIconnectorforthecable.

8. You’llneedaterminalemulatorwindowtocommunicatewiththeGalileo.Onepopular,freeversioniscalledPutty.FormoreinformationonPuttyandhowtodownload,seehttp://www.chiark.greenend.org.uk/~sgtatham/putty/.However,anyterminalemulatorprogramwilldo.

9. OpenaterminalwindowandselecttheserialportofyourUSBtoFTDIconnector(orUSB-to-3.5mmconnector,ifyouhaveaGEN1board)andabaudrateof115200.EverytimetheGalileoboots,itwilllookforanimageontheSDcardandbootthatimageifitispresent.Ifitisnotpresent,itwillbootthePokyversionthatisintheinternalmemory.Theterminalemulatorwillallowyoutoselectwhichoperatingsystemyouwanttorun.

10. Powerontheunit.Youshouldseethisbootupscreen:

11. Selectthelastselectiononthislist.TheunitwillnowbootfromtheDebianLinuxdistributiononthecard.Typetheusernameandpassword,forthisdistributionitisuseranduser.Theunitwillnowprovideaterminalconnectionfromyourhostcomputerwhereyoucantypecommands.

12. YouwillneedtoeditafiletogetaccesstotheLANconnection.Thefileis/etc/networks/config.Editthisfileusingeithervi,ornano(bothareeditorsthatcomewiththisLinuxrelease.)Makesurethefilelookslikethis:

13. Rebootyoursystem.14. Runthecommandsudoifconfig.andyoushouldbeabletoseetheIPaddressof

yourGalileo.15. Thisimageisquitesmall.Whenyouwritetheimagetoyourcard,thesystemwill

nowseeyourSDcardasquitesmallaswell,evenifyouhaveamuchlargercardwithmorememoryavailable.Youcanfollowtheinstructionsathttp://sourceforge.net/p/galileodebian/wiki/How%20to%20expand%20the%20root%20filesystem%20to%20use%20the%20entire%20SD%20card/toexpandyourcardtoitsfullsize.

NowyoursystemisupandrunningandconnectedtotheInternet.Thisparticulardistributionalsohaspythonavailable,whichyouwilluselater.Youwillwanttorunthecommandsudoapt-getupdatetoupdatethelinksforanyinstallsyouwanttodointhefuture.Youwillalsowanttorunthecommandsudoapt-getupgradetoupdateyoursystemtothelatest.

BuildingrobotsthatcanwalkNowthatyourGalileocanrunLinux,you’llneedtobuildaquadrupedthathasfourlegs.You’llbeusing12servossoeachleghasthreepointsthatcanmove,orthreedegreesoffreedom(DOF).YoucouldusetheIDEanditsGeneralPurposeInput/Output(GPIO)pinstocontrolalimitednumberofservos.However,youneedtocontrol12servosforthisproject,sothiswon’twork.Inthisproject,you’lluseanexternalservocontrollerthatcansupplythecontrolsignalsandvoltagesforall12servos.ThisexamplewillalsoshowyouhowtousetheLinuxcapabilitiesoftheGalileoforevenmorecomplexroboticsprojects.

Sinceservosarethemaincomponentofthisproject,itisperhapsusefultogothroughatutorialonservosandhowtocontrolthem.

HowservomotorsworkServomotorsaresomewhatsimilartoDCmotors;however,thereisanimportantdifference.WhileDCmotorsaregenerallydesignedtomoveinacontinuousway—rotating360degreesatagivenspeed—servosaregenerallydesignedtomovetoalimitedsetofangles.Inotherwords,intheDCmotorworld,yougenerallywantyourmotorstospinwithacontinuousrotationspeedthatyoucontrol.Intheservoworld,youwantyourmotortomovetoaspecificpositionthatyoucontrol.

ThisisdonebysendingaPulse-Width-Modulated(PWM)signalonthecontrolconnectoroftheservo.Thelengthofthispulsewillcontroltheangleoftheservo,likethis:

Thesepulsesaresentoutwitharepetitionrateof60Hz.Youcanpositiontheservotoanyanglebysettingthecorrectcontrolpulse.

BuildingthequadrupedplatformYou’llfirstneedsomepartssoyoucanbuildyourquadrupedrobot.Thereareseveralkitsoutthere,includingtheonesfoundatwww.trossenrobotics.com/p/PhantomX-AX-12-Quadruped.aspx.However,suchkitscanbeexpensiveso,forthisexample,you’llcreateyourownkitusingasetofLynxmotionparts.Theseareavailablefromseveralonlineretailers,suchaswww.robotshop.com.Tobuildthisquadruped,you’llneedtwosetseachofthetwolegparts,andthenoneseteachofthebody.Herearethepartswiththeirrobotshoppartnumber:

Quantity Description

1 LynxmotionSymmetricQuadrapodBodyKit-MiniQBK-02

2 Lynxmotion3”AluminumFemurPair

2 LynxmotionRobotLeg“A”Pair(NoServo)RL-01

4 LynxmotionAluminumMulti-PurposeServoBracketTwoPackASB-04

2BallBearingwithFlange-3mmID(pair)

ProductCode:RB-Lyn-317

ThelastpartisnotaLynxmotionpart,butisabearingyou’llneedtoconnectthelegtothebody.

You’llalsoneed12standardsizeservos.Thereareseveralpossiblechoices,butIpersonallyliketheHitecservos.Theyareaveryinexpensiveservoyoucangetatmosthobbyshopsandonlineelectronicsretailers.Nowlet’stalkbrieflyaboutthemodelofservo.Servoscomeindifferentmodelnumbers,primarilybasedontheamountoftorquetheycangenerate.

Torqueistheforcethattheservocanexerttomovethepartconnectedtoit.Inthiscase,yourservoswillneedtoliftandmovetheweightassociatedwithyourquadruped,soyou’llneedaservowithenoughtorquetodothis.Inthiscase,IsuggestyouuseeightmodelHS-485HBservos,you’llusethesefortheservosattachedtotheendofthelegandforthebody.Thenyou’llusefourmodelHS-645MGservosforthemiddleoftheleg;thisistheservothatwillrequirethehighestamountoftorque.YoucanalsojustusetwelveHS-645MGservos,buttheyaremoreexpensivethantheHS-485,sousingthetwodifferentservoswillbelessexpensive.

Herearethestepsforassemblingthequadruped:

1. Putthelowerpartoftherightlegtogether;itshouldlooklikethis:

2. Nowconnectthisassemblytoaninterconnectingpiece,likethis:

3. Completethelegbyconnectingtwooftheservobracketstogetheratrightangles,mountingtheHS-645MGontooneofthebracketsandthenconnectingthisservototheinterconnectedpiece,likethis:

4. Putanotherrightlegtogether.5. Nowputtwoleftlegstogetherfollowingthesamestepsasmentionedpreviously,but

inleftlegconfiguration.Theylooklikethis:

6. Thenextstepistobuildthebodykit.Therearesomeinstructionsatwww.lynxmotion.com/images/html/sq3u-assembly.htm,butitshouldlooklikethis:

7. Thenconnecteachlegtothebodykit.First,connecttheemptyservobrackettothebodyusingthebearing,likethis:

8. Nowconnecttheotherservototheemptyservobracketandthebody,likethis:

Yourquadrupedshouldnowlooklikethis:

Nowthatyouhavethebasichardwareassembled,youcanturnyourattentiontotheelectronics.

UsingaservocontrollertocontroltheservosTomakeyourquadrupedwalk,youfirstneedtoconnecttheservomotorcontrollertotheservos.TheservocontrolleryouaregoingtouseforthisprojectisasimpleservomotorcontrollerutilizingUSBfromPololu(Pololuitem#:1354availableatwww.pololu.com)thatcancontrol18servomotors.Hereisanimageoftheunit:

Makesureyouordertheassembledversion.ThispieceofhardwarewillturnUSBcommandsfromtheGalileointosignalsthatcontrolyourservomotors.Pololumakesanumberofdifferentversionsofthiscontroller,eachabletocontrolacertainnumberofservos.Inthiscase,youmightwanttochoosethe18servoversionsoyoucancontrolall12servoswithonecontrollerandalsoaddanadditionalservotocontrolthedirectionofacameraorsensor.Youcouldalsochoosethe12-servoversion.Oneadvantageofthe18-servocontrolleristheeaseofconnectingpowertotheunitviascrewtypeconnectors.

Therearetwoconnectionsyou’llneedtomaketotheservocontrollertogetstarted;thefirsttotheservomotors,andthesecondtoabattery.

First,connecttheservostothecontroller.Inordertobeconsistent,let’sconnectyour12servostotheconnectionsmarkedzerothrough11onthecontrollerusingthisconfiguration:

ServoConnector Servo

0 RightFrontLowerLeg

1 RightFrontMiddleLeg

2 RightFrontUpperLeg

3 RightRearLowerLeg

4 RightRearMiddleLeg

5 RightRearUpperLeg

6 LeftFrontLowerLeg

7 LeftFrontMiddleLeg

8 LeftFrontUpperLeg

9 LeftRearLowerLeg

10 LeftRearMiddleLeg

11 LeftRearUpperLeg

Hereisapictureofthebackofthecontroller;thiswilltelluswheretoconnectourservos:

Nowyouneedtoconnecttheservomotorcontrollertoyourbattery.Forthisproject,youcanusea2SRCLiPobattery,itwillsupplythe7.4voltsandthecurrentneededbyyourservos,whichcanbeintheorderof2Amps.Hereisapicture:

Thisbatterywillcomewithtwoconnectors,onewithlarger-gaugewiresfornormalusageandasmallerconnectorforconnectingtothebatteryrecharger.YoucanusetheXT60ConnectorPairs,soldersomewirestothematingconnectorofthebattery,andtheninsertthebareendofthewiresintotheservocontroller.

Yoursystemisnowfunctional.Nowyou’llconnectthemotorcontrollertoyourpersonalcomputertochecktoseeifyoucancommunicatewithit.Todothis,connectaminiUSBcablebetweentheservocontrollerandyourpersonalcomputer.

CommunicatingwiththeservocontrollerviaaPCNowthatthehardwareisconnected,youcanusesomesoftwareprovidedbyPolulutocontroltheservos.Let’sdothisbyusingyourpersonalcomputer.First,downloadthePolulusoftwarefromwww.pololu.com/docs/0J40/3.aandinstallitbasedontheinstructionsonthewebsite.Onceitisinstalled,runthesoftwareandyoushouldseethisscreen:

YouwillfirstneedtochangetheconfigurationonSerialSettings,soselecttheSerialSettingstabsandyoushouldseethis:

MakesurethattheUSBChainedoptionisselected,thiswillallowyoutoconnectandcontrolthemotorcontrolleroverUSB.NowgobacktothemainscreenbyselectingtheStatustabandnowyoucanactuallyturnonthetwelveservos.Thescreenshouldlooklikethis:

Nowyoucanusethesliderstoactuallycontroltheservos.Makesurethattheservo0movestherightfrontlowerservo,1therightfrontmiddleservo,2therightfrontupperservo,andsoon.Youcanalsousethistocentertheservos.Setalltheservossothatthesliderisinthemiddle.Now,unscrewtheservohornoneachservountiltheservosarecenteredatthislocation.Atthezerolocationofallservos,yourquadrupedshouldlooklikethis:

ConnectingtheservocontrollertotheGalileoYou’vecheckedtheservomotorcontrollerandtheservos;you’llnowconnectthemotorcontrolleruptotheGalileoandmakesureyoucancontroltheservosfromit.

Let’snowtalktothemotorcontroller.Herearethesteps:

1. ConnectGalileotothemotorcontrollerbyconnectingaminiUSB-to-miniUSBcable.ConnectthecabletotheUSBhostconnectionontheGalileo,likethis:

2. DownloadtheLinuxcodefromPololuatwww.pololu.com/docs/0J40/3.b.PerhapsthebestwayistologontoyourGalileo,thentypewgethttp://www.pololu.com/file/download/maestro-linux-100507.tar.gz?file_id=0J315.

3. Then,movethefileusingthiscommand:

mvmaestro-linux-100507.tar.gz\?file_id\=0J315maestro-linux-

100507.tar.gz

4. Unpackthefilebytypingtar–xzfvmaestro_linux_011507.tar.gz.Thiswillcreateadirectorycalledmaestro_linux.Gotothatdirectorybytypingcdmaestro_linuxandthentypels,youshouldseesomethinglikethis:

ThedocumentREADME.txtwillgiveyouexplicitinstructionsonhowtoinstallthesoftware.Unfortunately,youcan’trunMaestroControlCenteronyourGalileo,yourversionofwindowsdoesn’tsupportthegraphics,butyoucancontrolyourservosusingtheUscCmdcommandlineapplication.Firsttype./UscCmd--listandyoushouldseethefollowing:

Theunitseesyourservocontroller.Ifyoujusttypemono./UscCmd,youcanseeallthe

commandsyoucansendtoyourcontroller:

Noticeyoucansendaservoaspecifictargetangle,althoughthetargetisnotinanglevaluessoitmakesitabitdifficulttoknowwhereyouaresendingyourservo.Withaservoandbatteryconnectedtotheservocontroller,trytyping./UscCmd--servo0,10.Theservowillmovetoitsfullangleposition.Type./UscCmd–servo0,0anditwillstoptheservofromtryingtomove.Inthenextsection,you’llwritesomepythoncodethatwilltranslateyouranglestothecommandsthattheservocontrollerwillwanttoseetomoveittospecificanglelocations.IfyouarestrugglingwiththeUSBconnection,seehttp://www.linux-usb.org/FAQ.htmlformoreinformation.

NoteIfyoudidn’truntheWindowsversionofMaestroControllerandsettheSerialSettingstoUSBChained,yourmotorcontrollermightnotrespond.ReruntheMaestroControllercodeandsettheSerialSettingstoUSBChained.

CreatingaprograminLinuxsothatyoucancontrolyourquadrupedYounowknowthatyoucantalktoyourservomotorcontroller,andmoveyourservos.Inthissection,you’llcreateapythonprogramthatwillletyoutalktoyourservostomovethemtospecificangles.You’llusepythonasitisverysimpleandeasytorun.

Let’sstartwithasimpleprogramthatwillmakeyourleggedmobilerobot’sservosgoto90degrees(thisshouldbesomewhereclosetothemiddleofthe0to180degreesyoucanset.)IfyouareunfamiliarwiththeeditingcodeinLinux,thebestsourceisatutorialontheeditoryouareusing.Fornanotryhttp://www.howtogeek.com/howto/42980/the-beginners-guide-to-nano-the-linux-command-line-text-editor/.Hereisthecode:

Hereisanexplanationofthecode:

1. #!/usr/bin/python:-Thisfirstlineallowsyoutomakethispythonfileexecutefromthecommandline.

2. importserial:–Thislineimportstheseriallibrary.YouneedtheseriallibrarytotalktoyourunitviaUSB.

3. defsetAngle(ser,channel,angle):-Thisfunctionconvertsyourdesiredsettingofservoandangleintotheserialcommandthattheservomotorcontrollerneeds.Tounderstandthespecificsofthecodeusedtocontroltheservos,seehttps://www.pololu.com/docs/0J40.

4. ser=serial.Serial("/dev/ttyACM0",9600):–Thisopenstheserialportconnectiontoyourservocontroller.

5. Nowyoucanseteachservotothemiddle(home)position:

foriinrange(0,15):

setAngle(ser,i,90)

Thedefaultwouldbetoseteachservoto90degrees.Ifyourlegsaren’tintheirmiddleposition,youcanadjustthembyadjustingthepositionoftheservohornsoneachservo.

Toaccesstheserialport,you’llneedtomakesureyouhavethepythonseriallibrary.Ifyoudon’t,thentypeapt-getinstallpython-serial.Afteryouhaveinstalledtheseriallibrary,youcanrunyourprogrambytypingpythonquad.py.

Onceyouhavethebasichomepositionset,youcannowaskyourrobottodosomethings.Let’sstartbyhavingyourquadrupedwave.Hereisthepythoncode:

Inthiscase,youareusingyoursetAnglecommandtosetyourservostomanipulateyourrobot’sfrontrightarm.Themiddleservoraisesthearm,andthelowersurveythengoesbackandforthbetweenanangleof100and130.

Oneofthemostbasicactionsyou’llwantyourrobottotakeistowalkforward.Hereisanexampleofhowtomanipulatethelegstomakethishappen:

Thisprogramliftsandthenmovesforwardeachleg,oneatatime,thenmovesallthelegstothehomeposition,whichmovestherobotforward.Notthemostelegant,butitdoeswork.Therearemoresophisticatedalgorithmsforwalkingwithyourquadruped,seehttp://letsmakerobots.com/node/35354andhttps://www.youtube.com/watch?v=jWP3RnYa_tw.Onceyouhavetheprogramworking,you’llwanttopackageallyourhardwareontothemobilerobot.

Youcanmakeyourrobotdomanyamazingthings.Walkforward,walkbackward,dance,turnaround;anynumberofmovementsarepossible.Thebestwaytolearnistotrynewanddifferentpositionswiththeservos.

SummaryYounowhavearobotthancanwalk!ThisshouldnowgiveyoutheopportunitytousetheLinuxsystemtoaddmorecomplexcapabilities.Debianisquitepowerful,andopensanentiresetofopen-sourcecapabilities.Inthenextchapter,you’llexploreusingtheGalileotoproducespeech.

Chapter8.SpeechOutputNowthatyou’velearnedhowtogettotheLinuxoperatingsystemonyourGalileo,youhaveawholenewsetofcapabilitiesthatyoucanaddtoyourprojects.Oneexampleisspeech;itisagoodbasicprojectandoffersanexampleofaddingcapabilityinbothhardwareandsoftware.You’llbeaddingaspeakertoyourGalileo.You’llalsoaddfunctionalitysotherobotcanrespondviathespeaker.

Specifically,inthischapteryou’lllearnhowto:

HookupthehardwaretoinputsoundUseEspeaktoallowyourprojectstorespondinarobotvoice

ThisprojectrequiresaUSBmicrophoneorspeakeradapter.Theboarditselfdoesnothaveaudiooutoraudioin.OntheGalileoGen1board,the3.5mmconnectoristoconnecttothehostcomputer.Soyou’llneedthefollowingtwopiecesofhardware:

AUSBdevicethatsupportsmicrophoneinandspeakerout.Theseareinexpensiveandcanbepurchasedatanyonlineelectronicsoutlet.Refertothefollowingimage:

ApoweredspeakerthatcanplugintotheUSBdevice.Again,theseareavailableonlineoratanyaudiostore.Refertothefollowingimage:

Makesurethespeakerispoweredbecauseyourboardwillgenerallynotbeabletodriveapassivespeakerwithenoughpowerforyourapplications.Thespeakercanuseeitherinternalbatterypower,oranexternallypoweredUSBhub.

HookingupthehardwaretomakeaninputsoundForthistask,youaregoingtohookupyourhardwaresothatyoucanrecordandplaysound.Todothis,assembleyourGalileoandthecomponents.PlugintheLANcable,orconnectviathewirelessadapter.PluginthemicrophoneorspeakerUSBdevice.Also,pluginyourspeakersandthemicrophone.Pluginthepower,aswellastheUARTconnector.Theentiresystemshouldlooklikethefollowingimage:

Pluginthepower.Oncetheterminalwindowcomesup,loginwithyourusernameandpassword.Nowtypeincat/proc/asound/cards.TheGalileowilltellyouwhatsoundcarditseesattached.Youshouldseearesponsethatresemblesthefollowingscreenshot:

Thereisonlyoneaudiodevice,yourUSBaudioplugin.First,let’splaysomemusictotestthattheUSBsounddeviceisworking.You’llneedtoconfigureyoursystemtolookforyourUSBaudiopluginanduseitasthedefaultsounddevicetoplayandrecordsound.Todothis,you’llneedtoaddacoupleoflibrariestoyoursystem.ThefirstisAdvancedLinuxSoundArchitecture(ALSA).ItisgoingtoenableyoursoundsystemontheGalileo.Performthefollowingsteps:

1. Firstly,installtwolibrariesassociatedwithALSAbytypingsudoapt-getinstallalsa-basealsa-utils.Asareminder,youneedtohaveanetworkconnectiontodownloadnewpackages,andapt-getwillsearchthedefaultpackagerepositorybyname.

2. Then,alsoinstallsomefilesthathelpprovidethesoundlibrarybytypingsudoapt-getinstalllibasound2-dev.

Ifyoursystemalreadycontainstheselibraries,Linuxwillsimplytellyouthattheyarealreadyinstalledorthattheyareup-to-date.Afterinstallingbothlibraries,rebootyourGalileo.Ittakestime,andisnotalwaysrequired,butthesystemoftenneedsarebootafternewlibrariesorhardwareareinstalled.

UsinganapplicationNowyou’lluseanapplicationnamedalsamixertocontrolthevolumeofboththeinputandtheoutputofourUSBsoundcard.Performthefollowingsteps:

1. Typealsamixerontheprompt.Youshouldseeascreenthatlookslikethefollowingscreenshot:

2. Youcanusethearrowkeystosetthevolumeforboththespeakersandthemicrophone.UsetheMkeytounmutethemicrophone.Intheprecedingscreenshot,MMismuteand∞isunmute.

3. Let’smakesureyoursystemknowsaboutyourUSBsounddevice.Attheprompt,typesudoaplay–l.Youshouldnowseeascreenresemblingthefollowingscreenshot:

Nowthatyouhavesomesoundhardware,let’sfirstrecordsomesound.Todothis,you’regoingtousethearecordprogram.Attheprompt,typearecord-d5-r48000test.wav.Thiswillrecordfivesecondsofsoundata48,000Hzsamplerateandsaveittoafilecalledtest.wav.

Onceyouhavetypedthecommand,eitherspeakintothemicrophoneormakesomeotherrecognizablesound.Youshouldseethefollowingoutputintheterminal:

Onceyoucreatethefile,playitwithaplay.Typesudoaplaytest.wavandyoushouldheartherecording.Ifyoucan’thearyourrecording,checkalsamixertomakesureyourspeakersandmicrophonearebothunmuted.

NowyoucanplaymusicorothersoundfilesusingyourGalileo.Youcanchangethevolumeofyourspeakerandrecordyourvoiceorothersoundsonthesystem.You’rereadyforthenextstep.

UsingEspeaktoallowourprojectstorespondinarobotvoiceSoundisanimportanttoolinourrobotictoolkit,butyouwillwanttodomorethanjustrecordandplayyourvoice.Let’sallowyourrobottospeak.You’regoingtostartbyenablingEspeak,anopen-sourceapplicationthatprovidesuswithacomputervoice.DownloadtheEspeaklibrarybytypingsudoapt-getinstallespeak.Thedownloadmighttakeawhile,butthepromptwillreappearwhenitiscomplete.Nowlet’sseeifyourGalileohasavoice.Typethesudoespeak"hello"command.Thespeakershouldemitacomputer-voicedhello.Ifitdoesnot,checkthespeakersandvolumelevel.

Nowthatyouhaveacomputervoice,youmightwanttocustomizeit.Espeakoffersafairlycompletesetofcustomizationfeatures,includingalargenumberoflanguages,voices,andotheroptions.Toaccessthese,youcantypeintheoptionsatthecommand-lineprompt.Forexample,typeinespeak-v+f3"hello"andyoushouldhearafemalevoice.YoucanaddaScottishaccentbytypingespeak–ven-sc+f3"hello".ThecommandlineargumentsthatareavailableforEspeakaredocumentedathttp://espeak.sourceforge.net/commands.html.Onceyouhaveselectedthekindofvoiceyou’dlikeforyourprojects,youcansetitasthedefault,soyoudon’talwayshavetoincludeitinthecommandline.

Tosetthedefault,gotothedefaultfiledefinitionforespeak,whichisinthe//usr/lib/arm-linux-gnueabihf/espeak-data/voicesdirectory.Thedefaultfileistheonethatespeakusestochooseavoice.Togetyourdesiredvoice,sayonewithafemaletone,youaregoingtocopyafileintothedefaultfile.Thefile,thatis,thefemaletone,isinthe!vdirectory.Type\!vwheneveryouwanttospecifythisdirectory.Weneedtotypethe\characterbecausethe!characterisaspecialcharacterinLinux;ifwewanttouseitasaregularcharacter,weneedtoputa\characterbeforeit.Beforestartingtheprocess,copythecurrentdefaultfileintoafilenameddefault.old,soitcanberetrievedlater,ifneeded.Thenextstepistocopythef3voiceasyourdefaultfile.Typethesudocp./\!v/f3defaultcommand.Thishasallthesettingsforyourfemalevoice.Nowyoucansimplytypeespeakandthedesiredtext.Youwillnowgetyourfemalecomputervoice.

Nowyourprojectcanspeak.Simplytypeespeakfollowedbythetextyouwanttospeakinquotesandoutcomesyourspeech.Ifyouwanttoreadanentiretextfile,youcandothataswellusingthe–foptionandthentypingthenameofthefile.Trythisbyusingyoureditortocreateatextfilecalledspeak.txt;thentypetheespeak-fspeak.txtcommand.

Therearelotsofchoiceswithrespecttothevoicesyoumightusewithespeak.Feelfreetoplayaroundandchooseyourfavorite.Theneditthedefaultfiletosetittothatvoice.However,don’texpectthatyou’llgetthekindofvoicesthatyouhearfromcomputersinthemovies.Thoseareactorsandnotcomputers;oneday,though,wewillhopefullygettothepointwherecomputerswillsoundalotmorelikerealpeople.

SummaryNowyourprojectcanspeak.Youcanusethislaterwhenyouwanttointerfacewithyourprojectwithoutusingthedisplay.Youshouldalsofeelmorecomfortableinstallingnewhardwareandsoftwareinyoursystem.Inthenextchapter,you’lladdcapabilitythatwillallowyourrobotstoseeandusevisiontotrackobjects,ormotion,orwhateverelseyourrobotneedstotrack.

IndexA

accelerometerconnecting,toGalileo/ConnectinganaccelerometerorgyrototheGalileoURL/ConnectinganaccelerometerorgyrototheGalileoaccessing,fromGalileoIDE/ConnectinganaccelerometerorgyrototheGalileo,AccessingtheaccelerometerfromtheIDE

Adafruit2.8inchTFTV2URL/TheTFTshield

Adafruit_GFXlibraryURL,fordownloading/AccessingthedisplaywiththeIDE

Adafruit_ILI9341libraryURL,fordownloading/AccessingthedisplaywiththeIDE

AdvancedLinuxSoundArchitecture(ALS)/Hookingupthehardwaretomakeaninputsoundaltimeter/pressuresensor

connecting,toGalileo/Connectinganaltimeter/pressuresensortotheGalileoaccessing,fromGalileoIDE/Accessingthealtimeter/pressureSensorfromtheGalileoIDE

AnalogINA5/A0pin/TheGPIOcapabilityoftheGalileoanaloginputsignals

interfacing,withGalileo/InterfacinganaloginputsignalswithGalileoAREFpin/TheGPIOcapabilityoftheGalileo

Bblinkapplication

about/OpeninganduploadingafiletotheGalileoobtaining/OpeninganduploadingafiletotheGalileo

BMP085Module,DigitalBarometricPressureSensorURL/Connectinganaltimeter/pressuresensortotheGalileo

breadboardwires,plugging/Pluggingyourwiresintothebreadboard

CCOMport

selecting,forWindows/SelectingtheproperCOMportforWindowsselecting,forMac/SelectingtheproperCOMportfortheMacselecting,forLinuxmachine/SelectingtheproperCOMportforaLinuxMachine

DDCmotor

basics/DCmotorbasicsconnecting,toGalileo/ConnectingaDCmotordirectlytotheGalileoconnecting,H-bridgeused/ConnectingaDCmotorusinganH-bridgeandtheGalileoconnecting,Galileoused/ConnectingaDCmotorusinganH-bridgeandtheGalileocontrolling,shieldused/ControllingDCmotorsusingashield

DebianLinuxSDcardimagecreating,onGalileo/CreatingandbootingtheDebianLinuxSDcardimageontheGalileobooting,onGalileo/CreatingandbootingtheDebianLinuxSDcardimageontheGalileoURL/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

degreesoffreedom(DOF)/BuildingrobotsthatcanwalkDigi/ConfiguringtheXBeedevicesDigital((PWM~)13/2pin/TheGPIOcapabilityoftheGalileodigitalcompass

connecting,toGalileo/ConnectingadigitalcompasstotheGalileoaccessing,fromGalileoIDE/AccessingthecompassfromtheIDEURL/AccessingthecompassfromtheIDE

digitalinputsignalsinterfacing,withGalileo/InterfacingdigitalinputsignalswithGalileo

DigitalRX->0pin/TheGPIOcapabilityoftheGalileoDigitalTX->1pin/TheGPIOcapabilityoftheGalileodistance

sensing/Sensingdistance

Eelectronics

settingup/SettinguptheelectronicsEspeak

used,forrespondinginrobotvoice/UsingEspeaktoallowourprojectstorespondinarobotvoiceURL/UsingEspeaktoallowourprojectstorespondinarobotvoice

externalhardwareconnecting/Connectingyourfirstexternalhardwarewires,pluggingintobreadboard/Pluggingyourwiresintothebreadboardelectronics,settingup/Settinguptheelectronics

Ffile

uploading,toGalileo/OpeninganduploadingafiletotheGalileoopening/OpeninganduploadingafiletotheGalileo

firmwareupdating/Updatingthefirmware

GGalileo

unpacking/UnpackingandconnectingtheGalileoconnecting/UnpackingandconnectingtheGalileoconnecting,toWindowsmachine/DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachineconnecting,toMac/DownloadingthesoftwareandconnectingtheGalileotoaMacconnecting,toLinuxmachine/DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachineIDE,runningfor/RunningtheIDEfortheGalileofile,uploadingto/OpeninganduploadingafiletotheGalileoLinuxcapabilities,accessing/AccessingtheGalileo’sLinuxcapabilitiesGPIOcapability/TheGPIOcapabilityoftheGalileodigitalinputsignals,interfacing/InterfacingdigitalinputsignalswithGalileoanaloginputsignals,interfacing/InterfacinganaloginputsignalswithGalileoDCmotor,connectingto/ConnectingaDCmotordirectlytotheGalileoDCmotor,connectingwith/ConnectingaDCmotorusinganH-bridgeandtheGalileoIRsensors,connectingto/ConnectinganIRsensortotheGalileodigitalcompass,connectingto/ConnectingadigitalcompasstotheGalileoaccelerometer,connectingto/ConnectinganaccelerometerorgyrototheGalileogyro,connectingto/ConnectinganaccelerometerorgyrototheGalileoaltimeter/pressuresensor,connectingto/Connectinganaltimeter/pressuresensortotheGalileo,Accessingthealtimeter/pressureSensorfromtheGalileoIDEaltimeter/pressuresensor,accessingfrom/Accessingthealtimeter/pressureSensorfromtheGalileoIDEXBeedevices,connectingto/ConnectinganXBeeinterfacetotheGalileoWi-Ficonnection,configuring/ConfiguringaWi-FiconnectionontheGalileoandLinux/TheGalileoandLinuxDebianLinuxSDcardimage,booting/CreatingandbootingtheDebianLinuxSDcardimageontheGalileoDebianLinuxSDcardimage,creating/CreatingandbootingtheDebianLinuxSDcardimageontheGalileoservocontroller,connectingto/ConnectingtheservocontrollertotheGalileo

Galileocode,DCmotordirectioncontrol/GalileocodeforDCmotordirectioncontrolGalileocode,DCmotorshield/GalileocodefortheDCmotorshieldGalileocode,DCmotorspeedcontrol/GalileocodeforDCmotorspeedcontrolGalileoIDE

code,creating/TheIDEandLEDCode

IRsensor,accessingfrom/AccessingtheIRsensorfromtheGalileoIDEdigitalcompass,accessingfrom/AccessingthecompassfromtheIDEaccelerometer,accessingfrom/AccessingtheaccelerometerfromtheIDEaltimeter/pressuresensor,accessingfrom/Accessingthealtimeter/pressureSensorfromtheGalileoIDEXBeeinterface,enabling/EnablinganXBeeInterfaceintheIDEWi-Fi,using/UsingWi-FifromtheIDE

GalileopinsAREF/TheGPIOcapabilityoftheGalileoGND/TheGPIOcapabilityoftheGalileoDigital((PWM~)13/2/TheGPIOcapabilityoftheGalileoDigitalTX->1/TheGPIOcapabilityoftheGalileoDigitalRX->0/TheGPIOcapabilityoftheGalileoAnalogINA5/A0/TheGPIOcapabilityoftheGalileoPowerVin/TheGPIOcapabilityoftheGalileoPowerGND/TheGPIOcapabilityoftheGalileoPower5V/TheGPIOcapabilityoftheGalileoPower3.3V/TheGPIOcapabilityoftheGalileoRESET/TheGPIOcapabilityoftheGalileoIOREF/TheGPIOcapabilityoftheGalileo

GalileoPokyoperatingsystemIntel®Centrino®Wireless-N135/ConfiguringaWi-FiconnectionontheGalileoIntel®Centrino®Advanced-N6205/ConfiguringaWi-FiconnectionontheGalileo

GNDpin/TheGPIOcapabilityoftheGalileoGPIOpins

capability/TheGPIOcapabilityoftheGalileousing/UsingtheGPIOpins

gyroURL/ConnectinganaccelerometerorgyrototheGalileoconnecting,toGalileo/ConnectinganaccelerometerorgyrototheGalileo

HH-bridge

DCmotor,connectingwith/ConnectingaDCmotorusinganH-bridgeandtheGalileo

hardwarehookingup,forcreatinginputsound/Hookingupthehardwaretomakeaninputsound

Ii2cdevlib

URL/AccessingtheaccelerometerfromtheIDEIDE

downloading/DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachineOSXversion,downloading/DownloadingthesoftwareandconnectingtheGalileotoaMacLinuxversion,downloading/DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachinerunning,forGalileo/RunningtheIDEfortheGalileosetting,forconnectingtoboard/SettingtheIDEtoconnecttoyourboardserialdisplay,enabling/EnablingtheserialdisplayintheIDEused,foraccessingdisplay/AccessingthedisplaywiththeIDE

inputsoundcreating,byhookinguphardware/Hookingupthehardwaretomakeaninputsoundapplication,using/Usinganapplication

IOREFpin/TheGPIOcapabilityoftheGalileoIRsensor

about/TheInfraredsensorconnecting,toGalileo/ConnectinganIRsensortotheGalileoaccessing,fromGalileoIDE/AccessingtheIRsensorfromtheGalileoIDE

LLCD

URL/EnablingtheserialdisplayintheIDELED

connecting/TheIDEandLEDCodeLinux

andGalileo/TheGalileoandLinuxprogram,creatingforquadrupedcontrol/CreatingaprograminLinuxsothatyoucancontrolyourquadruped

Linuxcapabilities,Galileoaccessing/AccessingtheGalileo’sLinuxcapabilities

LinuxmachineGalileo,connectingto/DownloadingthesoftwareandconnectingtheGalileotoaLinuxmachineCOMport,selectingfor/SelectingtheproperCOMportforaLinuxMachine

LinuxoperatingsystemURL/ConfiguringaWi-FiconnectionontheGalileo

loop()function/AccessingtheIRsensorfromtheGalileoIDE

MMac

Galileo,connectingto/DownloadingthesoftwareandconnectingtheGalileotoaMacCOMport,selectingfor/SelectingtheproperCOMportfortheMac

MPU-6050/ConnectinganaccelerometerorgyrototheGalileo

Nnano

URL/CreatingaprograminLinuxsothatyoucancontrolyourquadruped

PPC

used,forcommunicatingwithservocontroller/CommunicatingwiththeservocontrollerviaaPC

PCIExpress(PCI-E)/ConfiguringaWi-FiconnectionontheGalileoPCIwirelessdevice

URL/ConfiguringaWi-FiconnectionontheGalileoPololu

URL/Usingaservocontrollertocontroltheservos,CommunicatingwiththeservocontrollerviaaPC,ConnectingtheservocontrollertotheGalileo

Power3.3Vpin/TheGPIOcapabilityoftheGalileoPower5Vpin/TheGPIOcapabilityoftheGalileoPowerGNDpin/TheGPIOcapabilityoftheGalileoPowerVinpin/TheGPIOcapabilityoftheGalileopressuresensors

URL/Connectinganaltimeter/pressuresensortotheGalileoPulse-Width-Modulated(PWM)/HowservomotorsworkPutty

URL/ConfiguringaWi-FiconnectionontheGalileoURL,fordownload/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

Qquadruped

building/Buildingrobotsthatcanwalkcontrolling,withLinuxprogram/CreatingaprograminLinuxsothatyoucancontrolyourquadruped

quadrupedplatformbuilding/BuildingthequadrupedplatformURL/BuildingthequadrupedplatformHS-485HBservos,using/BuildingthequadrupedplatformHS-645MGservos,using/Buildingthequadrupedplatform

RRESETpin/TheGPIOcapabilityoftheGalileo

Ssensors

used,forsensingdistance/Sensingdistanceserialdisplay

enabling,inIDE/EnablingtheserialdisplayintheIDEseriallibrary

URL/EnablingtheserialdisplayintheIDEservocontroller

using,forcontrollingservos/Usingaservocontrollertocontroltheservoscommunicating,withPC/CommunicatingwiththeservocontrollerviaaPCconnecting,toGalileo/ConnectingtheservocontrollertotheGalileo

servomotorsworking/Howservomotorswork

servoscontrolling,withservocontroller/Usingaservocontrollertocontroltheservos

setAnglecommand/CreatingaprograminLinuxsothatyoucancontrolyourquadrupedsetup()function/AccessingtheIRsensorfromtheGalileoIDEshield

using/Thesimpleserialdisplayused,forcontrollingDCmotor/ControllingDCmotorsusingashield

shieldcompatibilityguideURL/Sensingdistance

signalsobtaining,fromoutsideworld/Gettingsignalsfromtheoutsideworlddigitalinputsignals,interfacingwithGalileo/InterfacingdigitalinputsignalswithGalileoanaloginputsignals,interfacingwithGalileo/InterfacinganaloginputsignalswithGalileo

simpleserialdisplay/Thesimpleserialdisplaysolderlessversion

URL/ConnectinganaccelerometerorgyrototheGalileoSparkfun

URL/AccessingtheaccelerometerfromtheIDESparkfunSEN-11028

URL/ConnectinganaccelerometerorgyrototheGalileosudoapt-getupdatecommand/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

TTFTshield

about/TheTFTshielddisplay,accessingwithIDE/AccessingthedisplaywiththeIDE

UUSBDriver

URL,forinstallation/ConfiguringtheXBeedevices

Wwget

URL/ConnectingtheservocontrollertotheGalileoWi-Fi

configuring,onGalileo/ConfiguringaWi-FiconnectionontheGalileousing,fromGalileoIDE/UsingWi-FifromtheIDE

Win32DiskImagerURL/CreatingandbootingtheDebianLinuxSDcardimageontheGalileo

WindowsCOMport,selectingfor/SelectingtheproperCOMportforWindows,SelectingtheproperCOMportfortheMac

WindowsmachineGalileo,connectingto/DownloadingthesoftwareandconnectingtheGalileotoaWindowsmachine

XXBeedevices

about/ConnectinganXBeeinterfacetotheGalileoconfiguring/ConfiguringtheXBeedevices

XBeeinterfaceconnecting,toGalileo/ConnectinganXBeeinterfacetotheGalileoenabling,inGalileoIDE/EnablinganXBeeInterfaceintheIDE

ZZigBee/ConnectinganXBeeinterfacetotheGalileo

top related