RASPBERRY PI FOR BEGINNERS - Tentacle.Netprophet/raspberrypi/Raspberry Pi User Guide... ·...

Post on 17-Jul-2020

51 views 4 download

Transcript of RASPBERRY PI FOR BEGINNERS - Tentacle.Netprophet/raspberrypi/Raspberry Pi User Guide... ·...

RASPBERRYPIFORBEGINNERS

©2013,DogwoodApps

RaspberryPi®istheregisteredtrademarkofRaspberryPiFoundation,UnitedKingdom.

Importantnote:AuthorhasnoaffiliationwithRaspberryPiFoundation,UnitedKingdom.

Allrightsarereserved.

Alltrademarkholdersareownersoftheirrespectivetrademarks.

Thecopyrightofthise-book,aswellasthemattercontainedherein(includingillustrations),restswiththeauthor(s).Nopersonshallcopythenameofthebook,itstitledesign,matter,andillustrationsinanyformandinanylanguage,totallyorpartially,orinanydistortedform.Anybodydoingsoshallfacelegalactionandwillberesponsiblefordamages.

CONNECTWITHUSONFACEBOOK!

ComeandjoinourFacebookpagewhereyouwillbethefirst toknoweverythingaboutourupcomingtitles. Onourpage,wewillalsosharepromotionalinformationforourcurrentebooks.

Thisisalsoagreatplacetoaskusanyquestionsyoumayhaveconcerningourebooksaswell.

JoinourFacebookpagehere: https://www.facebook.com/DogwoodApps

ContentsChapter1

WhatisRaspberryPi?

Chapter2

ModelsofRaspberryPi

Chapter3

WhatDoYouNeedtoGetRaspberryPiUpandRunning?

Chapter4

InstallingtheOSonRaspberryPi

Chapter5

OtherOSesforPi

Chapter6

ProgrammingYourPiUsingScratch

Chapter7

ArduinoandRaspberryPi

Chapter8

AwesomePiUses

Chapter9

RaspberryPiasStandardProductivityComputer

Chapter10

UsingRaspberryPitoDriveaMultimediaCenter

Chapter11

UsingRaspberryPiforTime-LapsePhotography

Chapter12

UsingRaspberryPiasFMTransmitter

Chapter1

WhatisRaspberryPi?

RaspberryPiisanaffordable,creditcard–sized,single-boardcomputer.RaspberryPiwasdevelopedforcomputerscienceeducation.

This flagship product has been developed by Raspberry Pi Foundation, a charitableorganizationbasedinUnitedKingdom.

FeaturesRaspberryPiisasingle-boardcomputerthatisaboutthesizeofacreditcard.Itusesa32-bitcapableARMprocessorandFedorafromLinuxasitsdefaultoperatingsystem(OS).

Itcanbeprogrammedwithlanguages,suchasPython,thatwillcompilewithARM.

RaspberryPiisasystemonachip(SoC).Ithasconnectionports.

YoucanuseaRaspberryPi forbasic functions likewatchingHDvideos,workingwithspreadsheets,andeditingdocuments.Inotherwords,youcandoeverythingthatanormaldesktopcomputeriscapableofdoing.

InChapter2,wewilllearnaboutthedifferentversionscurrentlyofferedoftheRaspberryPi.

Chapter2

ModelsofRaspberryPi

RaspberryPihastwomodels.Surprisingly,bothmodelsareavailableatapocket-friendlyprice.

Model-A costs $25 and Model-B costs $35, excluding local taxes and shipping andhandlingcharges.Also,thisdoesnotincludechargesofpowersupplyandSDcard;youhavetobuythemseparately.

DifferencebetweenModel-AandModel-B

Model-A Model-B

Price $25 $35

SoC BroadcomBCM2835

CPU 700MHzARM1176JF-SCore

GPU VideoCoreIV,OpenGLES2,0,1080p30FullHDHPH.264

Memory 256MB 512MB

USB2.0ports 1 2(integrated)

Videooutputs CompositeRCA,HDMI

Audiooutputs 3.5mmjack,HDMI

Onboardstorage SD/MMC/SDIOcardslot

Low-levelperipherals GPIOpins,SPI,I2C,UART

Onboardnetwork None 10/100wiredEthernet

Real-timeclock Noclockorbattery

Powerratings 500mA(2.5W) 700mA(3.5W)

Powersource 5VviamicroUSBorGPIOheader

Size 85.60mm � 53.98mm

SupportedOSes DebianGNU/Linux,Fedora,ArchLinux

WheretoBuy?

Raspberry Pi Foundation hasmade exclusive distribution arrangementwith Farnell andRS;onecanbuyanymodelofRaspberryPifromthesedistributors.ResellersdosellonAmazonandeBay.

ResellerssellRaspberryPiwithdifferentoffers,sopricesmayvary.

RaspberryPiModel-A

RaspberryPiModel-B

Chapter3

WhatDoYouNeedtoGetRaspberryPiUpandRunning?

Raspberry Pi is not preloaded evenwith important peripherals like SD card and powersupply cable unless you purchase Pi from a reseller and pay extra for these essentialperipherals.

In this chapter, you will learn about the essential peripherals that are required to getRaspberryPiupandrunning.

First, select a model of Raspberry Pi that meets your needs, because each model ofRaspberry Pi is designed to perform different functions. Now let’s take a look at theperipheralsrequiredtostartusingyourRaspberryPi.

SDcard

RaspberryPiOSisstoredonaSDcard.IfyouhavepurchasedfromRS,youwillgetaSDcard.Incaseifyouhavepurchaseditfromelsewhere,youcanpurchasetheSDcardfromAmazonorfromanyothernearestelectronicgadgetsoutlet.

Requirements:SDHCmemorycard(4GBormore)

SDHCcard

Powersupply

YouwillneedapowersupplyforyourRaspberryPi.YoucanpurchaseitfromAmazonorfromanyothernearestelectronicgadgetsoutlet.

Requirements:MicroUSBpowersupply(5V,1.2mA[ideal],butneedstobe700mA)

ChargerforPi

HDMIcable

RaspberryPihasoneHDMIportfordigitalvideoandaudioconnection.YouwillneedtopurchaseaseparateHDMIcapabletoviewthePionanHDMImonitorortelevision.

HDMIcable

Important note: Raspberry Pi does not support VGA analog output. You can use aconverterbutwedon’trecommendusingonebecauseitmaycauseyouissueslater.UsingastraightHDMItoHDMIconnectionisbesttoavoidcompatibilityproblems.

HDMItoVGAconverter

USBkeyboardandmouse

YouneedaUSBkeyboardandamousetoestablishuserinterfaceforyourRaspberryPi.SinceRaspberryPicomeswithlimitedports,youcanpurchaseaUSBextensionincaseyouneedmorethanoneUSBports.

SinceyourPisupportsBluetooth-enabledwirelesskeyboardandmouse,youcanpurchasethemaswell.

Wirelesskeyboard

Internetconnection

UsingyourPi,youcanconnecttoInternetinmanyways.YoucanenjoywirelessInternetvia a USB–Wi-Fi dongle, and if you would like to connect with high-speed wiredconnection,thenyoucanuseEthernetcable.

USBmodem

Remember,EthernetportisonlyavailableinModel-B.

Ethernetcable

BeforeyouinstallanOS,makesureyouhaveassemblednecessaryperipheralswithyourPi.

Operatingsystem(OS)

OSisthesoulofyourRaspberryPi.SotogetyourRaspberryPiupandrunning,youneedtoinstallFedorawhichisthestandarddefaultLinuxdistributionusedastheOSforPi.

MostofthedistributorssellPiwithpreinstalledOS.But,ifincaseyouwanttoinstalltheOSyourself,thenreadChapter4.

Chapter4

InstallingtheOSonRaspberryPi

InstallingtheOSonthePicanbechallenging,somostpeopleandnewbiespreferbuyingapreprogrammedRaspberryPiasamucheasiersolution.

Installing OS on Raspberry Pi is not extremely difficult, but it does take some basiccomputerknowledgetoaccomplishonthefirstattempt.IfyouhaveworkedonWindowsoranyotherOSplatform inyourPC,youcando it yourself easily andcan savea fewbucks.Sointhischapter,youwilllearnaboutinstallingtheOSonRaspberryPi.

WeareinstallingFedoraRemixdistributionfromLinux,butbeforeweinstallFedora,weneedtodownloaditfromtheWeb.

SelectalatestcopyofFedoraRemix(FedoraRemix17or18);youcandownloaditfromhttp://fedoraproject.org/wiki/Fedora_ARM_Installer

Direct download: http://fossjon.fedorapeople.org/packages/fedora-arm-installer/fedora-arm-installer-1.0.3-7.x32.zip

PreparingtheSDcardforuse

RaspberryPineeds a storageand installationmedia toboot;weneeda singleSDcard.Youneedtouseatleasta4GBSDcard.Theimageofthefiledownloadedinthepreviousstepwillbestoredonthiscard.

Note:Beforewebegin,makesurethatnoimportantfileisinyouSDcard,becauseitwillbeformattedatalaterstage.

IfyouareusingWindowsasyourhostOS,thendownloadWin32DiskImagerutilityfromhttp://www.softpedia.com/get/CD-DVD-Tools/Data-CD-DVD-Burning/Win32-Disk-Imager.shtml

NowlaunchtheDiskImagerandextracttheimageyouhavedownloadedfromtheWeb.Youwillgetan.imgfile.MakesureyouformatSDcardusingFAT32filesystem.NowrunWin32DiskImagerwithadministratorprivilegesandselect theextractedimageandthedriveletteroftheSDcard.Alwayschoosethecorrectdriveorelsedataonthedrivewill be destroyed. Click on the ‘Write’ button and wait till it finishes extracting data.Dependingonyourhostmachinespeed,yourwriting timewillvary,butwillnot takealongtime.

Aftercompletion,exitthemanagerandejecttheSDcard,whichisnowreadyforuse.

YoucanalsousePowerISO,Flashnul,orothersimilarutilitiesaswell.

BootingupthePi

TransferofimagefiletotheSDcardisnowsuccessful.WecannowsetupthePi.Insertyour SD card containing Fedora into the slot and connect the power supply and yourmonitor.NowmakeanInternetconnectionusingEthernetcableconnectedwithInternet

gatewayandwaitwhileyourPibootsup.

SettingupthePi

FedorawillresizeyourSDcardautomatically;hence,youdonotneedtomakepartitionsmanually. Connect your keyboard andmouse.Once your Pi boots up and black screendisappears,start thefinalsystemconfiguration:setpasswords;createuseraccounts;andselectyourtimezone,graphicaluserinterface(GUI),andfonts.

FedoraRemixbootinguponthePi

YouarereadytoworkonyourPinow.InChapter5,wewilllearnabouttheotherOSesthatcanbeinstalledonPi(insimilarway)andtheiroverview.

Chapter5

OtherOSesforPi

TherearemanyOSesthatcanbeinstalledwithPi;wearecoveringafewoftheimportantones.

Raspbian‘wheezy’

Raspbian ‘wheezy’ is recommended for beginners. It’s a reference root file systemdevelopedbyAlexandDom.ItisanoptimizedversionofDebian,anditcontainsLXDE,Midori,developmenttools,andexamplesourcecodeformultimediafunctions.

RaspbianisreferredtoasgraphicalfaceoftheRaspberryPi.GUIisawesome.

PlayingagameonRaspbian

ArchLinuxARM

ArchLinuxARMisadistribution fromArchLinux,whichaims for simplicityand fullcontroltotheenduser.Itisnotrecommendedforbeginners.Latestversionofthisimagebootsupinjusttenseconds(commandprompt).

Android

Though Raspberry Pi was not designed for Android devices, but in recent years,developershavedevelopedways touseAndroidonRaspberryPi.Atpresent,notmuchhas been done toward implementing Android on Raspberry Pi, but it is possible thatAndroidwouldbecomethemostsuccessfulOSonPiinthenearfuture.

Chapter6

ProgrammingYourPiUsingScratch

Inthischapter,wewilllearnaboutprogrammingthePiwithScratch.

First, boot up your Raspberry Pi. You will find that Scratch is preinstalled in Fedora.LocateaniconoftheScratchinthedesktopmenu.

Scratchicon

YoucandownloadScratchfromhttp://scratch.mit.edu/

Gettingstarted

To get familiar with Scratch, it’s best to begin with easy preinstalled projects andresources that are part of themain application. In this chapter,we are going to discuss‘Aquarium’,whichasit’snamedisactuallyacoolanimatedaquariumwithfishandotherwaterdwellingcreatures.

So,herewego.BeginbyclickingontheScratchicononyourdesktoporyoucanusethestandard LXDE menu option to launch the Scratch Studio on your Pi. To load theAquariumproject,proceedwiththefollowing:

1.Selectthe‘File’>‘Open…’menu.

2.Click‘Examples’ontheleft.

3.Select‘Animation’atthetop.

4.Select‘Aquarium’fromthelist.

5.Clickthe‘OK’button.

TheAquariumprojectisnowloadedandwearereadyforsomefun.Beforewegetstartedthough,youneedtoknowafewthingsabouttheScratchStudio.

TheScratchStudio

TheScratchStudiocandesignmanyfunthingslikeanimationsandgames.Nowthatyouhave loaded the Aquarium Project, the Scratch Studio should appear similar to thisscreenshotbelow:

TherearethreedifferentblocksorpanelsintheScratchStudio.Ontheleftside,thereisa‘Blocks Panel’. The Blocks Panel contains the blocks used to program and buildprograms.Thevariousblocksaregroupedintoseveralcategories,suchassensing,control,motion,sound,etc.

Notethatthereisa‘BuilderPanel’inthecenter.Thisisthepanelwherewearegoingtodraganddropourblocks.TheBuilderPanelcanbeusedtorecordandimportsoundsinadditiontocreatingandeditingimages.

Ontheright,thereisthe‘StagingArea’.Onthetop,youcanseeavisualrepresentationof

your program. You will see a complete aquarium here. Underneath is a collection of‘sprites’.

Runningtheprogram

Above the ‘StagingArea’,note there isagreen flaganda redcircle.ThesebuttonsareusedtostartandstopthecreatedprogramandinourcaseAquarium.Pressthegreenflagtowatchyouranimation.

Enjoyyoursampleanimationcomingtolife.

Thestageanimation

So,howisstageanimationdoneinScratch?

StageanimationisdoneinScratchusingbackgrounds,setofblocks,andsprites.

Addingsound

Adding sound to animation enhances its quality and grabs attention from its viewer aswell.Youcanaddsound toyouranimationsusing ‘Sounds’ tab in ‘BuilderPanel’.Youcanimportsoundorusepreinstalledeffects.

Onceyouaddsoundeffects,youcanlistentothesoundbyclickingthe‘Play’button.Addanewblocksettoplaythechosensoundoveranimation;thiswillgetactivatedwhenthegreenflagisclicked.

Programming with Scratch is really easy, and you can similarly program your PiwithalanguagecalledPythonaswell.

InChapter7,wewilllearnaboutArduino,arivaltoRaspberryPi;whencombinedwithPi,highperformanceisdelivered.

Chapter7ArduinoandRaspberryPi

MakersofAdruinodefineitas:

Arduinoisanopen-sourceelectronicsprototypingplatformbasedonflexible,easy-to-usehardwareandsoftware.It’sintendedforartists,designers,hobbyists,andanyoneinterestedincreatinginteractiveobjectsorenvironments.

TheArduino board itself is an open-source circuit board (open source means you candesign it yourself using individual components available in market). It contains amicroprocessor and of course input/output pins for communication and controlling ofphysicalobjectslikeLED,servos,buttons,lights,thermosensors,photoreceptors,etc.ItispoweredviaaUSBconnection.

Arduino

Arduino using a similar programming language to C++ known as Arduino integrateddevelopmentenvironment(IDE).TheIDEallowsyoutowrite,compile,andthenuploadyourcompletedcodetotheArduinodevice.Thiscanbeusedforprototypingaparticularproductorproject.

Manydesigners,artists,developers,andcomputergeekshaveusedArduinototurntheirideasintoreality.

ArduinoisjustanalternativetoRaspberryPi.

YoucancombineArduinowithRaspberryPiincaseyouwouldliketousesensorswithyourRaspberryPi.

Chapter8AwesomePiUses

TillnowwewereonlydealingwiththeoreticalaspectsofourPi.Afterreadingourearlierchapters,youmaybethinking,Okay,IhaveunderstoodwhatPiis,buthowcanIuseit?Whatareitsuses?

You can design and develop numerous projectswith Pi. For starters,we are explainingsomeinterestingusesofRaspberryPi.

Chapter9RaspberryPiasStandardProductivityComputer

Didyouknowthata$35RaspberryPicanbeusedasastandardproductivitycomputer?UsingaRaspberryPi,youcansetupabasicofficecomputerforverylittlemoney.

So,whatyoudowithyourstandardcomputerthatyouhaveathome?

ProcessingWorddocuments,spreadsheets,PowerPoint,etc.

BrowsingInternet,socialnetworkingsites,andcheckinge-mails.

Programmingandcodinginvariouslanguages.

PlayingHDgames.

Watchingvideosandhearingsongs.

YoucanalsodothesethingswithRaspberryPi!NextwewillconvertourPitoastandardproductivitycomputer.

Whatdoyouneed?

Hardware

RaspberryPiModel-B

MiniUSBpower700mA,5V

32GBSDHCcard(minimum4GB)

EthernetorUSBmodem(optional)

Keyboardandmouse(wiredorwireless)

HDMIcable

MonitorwithHDMIinputsupport(incaseofVGA,purchaseHDMItoVGAconverter)

USBextension(optional)

Onceyouarereadywiththeseparts,hookupyourPiasinstructedinChapter3.BootupyourPiasinstructedusingtheOSofyourchoiceandconfigureyourPiaccordingly.

YourPicannowdoeverythingthatastandardcomputercando.Youcanuseitformanypurposes.Let’sseewhatarethesoftwareproductsrequiredtoconvertyourPiintoaPC.Incaseitispreinstalledwiththesesoftwareproducts,youneednotdownloadthem.

Software Features

LibreOffice4.0(free)

Download link:http://www.libreoffice.org/download/

LibreOffice is a comprehensive,professional-quality productivity suite(like Microsoft Office) from theDocument Foundation available forfree download. It supports 30languages and OS, includingMicrosoftWindows,MacOSX, andGNU/Linux(Debian,Ubuntu,Fedora,Mandriva,Suse,etc.)

RIPChromium(free) ThisisabrowserforyourPi.YoucanbrowseInternet,streamvideos,accesse-mail,andenjoysocialnetworks.

Scratch(visualanimationsoftware)

Downloadlink:http://scratch.mit.edu/

To create awesome animation andgamesusingScratch,allyouneedisalatestcopyofScratch.

VLCMediaPlayer

Download link:http://www.videolan.org/vlc/download-fedora.html

To playmost of the audio and videoformats.

ThesearesomeofthemostimportantandcommontasksthatastandardPCcanhandle.Incase you needmore tasks fromyourPi, you can get additional software products fromInternetforuseonyourRaspberryPi.

YoucanaddCDorDVDorBlu-raydrivestoRaspberryPiusingUSBslotsincaseyouwanttowatchamovieorplayHDgames.

Besides,RaspberryPiisreallyabetteroptionthannormalcomputersbecauseitiseasytohandle,affordable,andgreatforlearningprogramming.InChapter10,wewilllearnabouttheotherusesofRaspberryPi.

Chapter10

UsingRaspberryPitoDriveaMultimediaCenter

TheRaspberryPiisagreatlowcostsolutiontobuildingyourownminimediacenter.Inthischapter,youwilllearnaboutsettingupXboxMediaCenter(XBMC)onyourPiwithauniversal remotecontrolusingFLIRCwhich isnothingmore thanaUSBdongle thatcanbepluggedintothePi.

Whatyou’llneed?

ARaspberryPi(Model-B)

RaspberryPipowercharger

Mouseandkeyboard(wirelessorwired)

EthernetcableandworkingInternetconnection

FLIRC

Universalremote(orspareone)

APCorlaptop(onlyfortheinitialsetup)

SettingupXBMCInstallerontheSDcardforPi

First you need to load the XBMC (RaspBMC)media OS on the Raspberry Pi. In thissection,wearegoingtouseaWindowsPC;stepsarealmostsameforLinuxandMacPC.

Download the SD card image file from the following link:http://download.raspbmc.com/downloads/bin/installers/raspbmc-win32.zip

NowextracttheZipfile‘raspbmc-win32’usingWinRARorWinZiptool.

Runthefilesetup.exefile.ThiswillinstalltheSDcardinstalleronyourcomputer.

Nowrun the filenamed‘installer’ (locatedon the topof thescreenshot).Thiswill thenopentheSDcardwriter.

RaspbmcInstaller

InsertyourSDcardinyourSDHCslot;makesureitdoesnotcontainanyimportantdata.Selectitasyourwritablemedia(choosethecorrectpathorelseyouwillloseyourdata).Nowtickthe‘Iacceptthelicenseagreement’checkboxandhit the‘Install’button.Waitwhile it is installedonyourcomputer.Thiswill initiatesetupofyourSDcardwiththeRaspBMCinstaller.Nowwaittillitfinishesinstalling;speedwillvarydependingonyourhostPCconfiguration.Oncecompleted,followingwindowwillappear.

Remove theSDcard fromyourSDHCport,andwecannowuse theRaspBMConourRaspberryPi.

SettingupRaspBMContheRaspberryPi

Beforeyoubegin,ensurethatyourRaspberryPiisconnectedviaEthernettotheInternetorelseitwillnotwork.

Addamouse,keyboard,andmonitor;plugSDcardintheSDHCportofyourRaspberryPi;andconnectapowersupplytoyourRaspberryPi.

Therewillbeasplashscreenthatwillappearforafewsecondsonyourmonitor,andthentherestofthesetupwillstartautomatically.Theentireprocessshouldnottakemorethan15minutes todownloadand install (speeddependsuponyourLANconnection). ItwillrestartanumberoftimesbeforeXMBCGUIisinstalled,sowaitpatiently.

SpendsometimeinfamiliarizingyourselfwithXBMC.

Let’snowsetupFLIRC.

SettinguptheFLIRCsoftware

NowgetbacktoyourPC(laptopordesktop);donotunplugyourPi.

DownloadthelatestFLIRCversionforyourOSfromhttp://flirc.tv/downloads/

WeshallbeusingWindowstocompletethissetup;ifyouareusingLinuxorMacOS,theprocessisquitesimilar.

Afterthesoftwareisdownloaded,runthesetupandinstalltheFLIRCsetupsoftwarethe

samewayyoudowithanyotherWindowsprograms.

Oncecompleted,runtheFLIRCsoftwareandyoushouldseethefollowinginputscreen:

Thisiscurrentlydisconnected

PlugyourFLIRCmodule(RaspberryPi) intothePCusingtheUSBconnector.Waitforsometime;itwill installautomaticallyonyourcomputer.Nowstatuswillbeupdatedto‘connected’.

Thisiscurrentlydisconnected

XBMChasmany commands, but in this section,wewill startwith someof thebasics.Thiswillincludecommandslike‘Navigation’,‘Enter’,and‘Back’.

Nextstepistosetuptheremotecontrol.Getaremotecontrol;thiscanbeanyIRremote—beitTV,CD,DVD,satellite,oruniversalremote,oranything.Onceyouarereadywithyourremotecontrol,hitthe‘go!’button.

It’stimetosyncyourremotecontrolwithournewlyinstalledFLIRCsoftware.

Thevirtualbuttonswillthenflashindividually.Hitthebuttonontheremotetoassociateakeyboardstrokewithcorrespondingkeyontheremote.

Asanexample,whenthe‘down’navigationontheFLIRCsoftwareflashesonyourscreenandyouhitthe‘down’buttonontheremote,itwillgetassociatedwithFLIRC.

Aftersettingupallofthekeys,yourbasicXBMCwillbereadyforuse.

Onceyouhavecompletedthesetup,quittheprogramonyourPCandremovetheFLIRCmodule(RaspberryPi)fromyourPC.

PuttingEverythingtogether

GetbackontotheRaspberryPi.

StartbyremovingthemouseandkeyboardandreplacingitwiththeFLIRCUSBmodule.

Next,switchtheFLIRCUSBmoduleon.Aftergivingitafewmomentstobootup,youcancontrolyourRaspberryPimediacenterusingyourremotecontrol!

Ifyouneedmoreinformation,youcanbrowse http://forums.flirc.tv/

MorecomplexkeyboardtoremoteSetups

LearnaboutmoreoftheXBMCbuiltincommands.StandardXBMCkeyboardnavigationcontrolscanbefoundbelow:

http://wiki.xbmc.org/index.php?title=Keyboard

Keymappingyourentirekeyboardtoyourremotecontrolispossible.Inthenextsection,pleasetakealookatsomeofthevariouscommands.

Key Global Videoplayback Musicvisualization

A Audiodelay

BLiveTV:Schedulerecordingtimers LiveTV:Schedulerecordingtimers

C Contextualmenu Playlist

D

E LiveTVEPG/TVguide LiveTVEPG/TVguide

F Fast-forward Fast-forward Fast-forward

H LiveTVchannelswindow LiveTVchannelswindow

I Info Info Info

JLiveTV:Radiochannelswindow LiveTV:Radiochannelswindow

K LiveTVrecordingswindow LiveTVrecordingswindow

L Nextsubtitle Lockpreset

M Playercontrols(OSD) Playercontrols(OSD) Playercontrols(OSD)

N ‘Nowplaying’playlist

ODisplaysCPUusageandvideodiagnosticinfo Codec/visualizationinfo

P Play Play Visualizationpresetlist

Q Queue

R Rewind Rewind Rewind

S Shutdownmenu Showpreset

T Togglesubtitlesonandoff

U Moveup

V Teletext Visualizationsettings

W Markedaswatched/unwatched

X Stop Stop Stop

Z Zoom/aspectratio

Space Pause/play Pause/play Pause/play

← LeftStepback30s(videos)

Previouschannelgroup(liveTV)

Previous

→ RightStepforward30s(videos)

Nextchannelgroup(liveTV)

Next

↑ UpStepforward10minornextchapter(videos)

Channelup(liveTV)Increaserating

↓ DownStepback10minorpreviouschapter(videos) Decreaserating

Channeldown(liveTV)

PageUp Pageup

PageDown Pagedown

↵ Ente r return Select Playercontrols(OSD) Playercontrols(OSD)

←Backspace Back

Esc Previousmenuorhomescreen Exitfullscreen

. period Skipforward Stepforward30s Skipforward

, comma Skipbackward Stepbackward30s Skipbackward

‘ quote Smallstepbackwards7s

Tab ⇆ Full-screenmode Full-screenmode Full-screenmode

PrintSrc Screenshot Screenshot Screenshot

- minus Volumedown Volumedown Volumedown

+ plus Volumeup Volumeup Volumeup

= equals Volumeup Volumeup Volumeup

\ backslash Toggleapplicationwindowedmode Toggleapplicationwindowedmode Toggleapplication

windowedmode

[ leftbracket Stepforward10minornextchapter

] rightbracket Stepbackward10minorpreviouschapter

ENDExitXBMC(onlyonhomescreen)v.11Eden

CTRL + ENDExitXBMC(onlyonhomescreen)v.12Frodo

DEL Deletefile Removefromplaylist Removefromplaylist

[numbers]then Return

Jumptothattimeinplayback.E.g.,1234+returnwilljumpto12minand34s.

⇧ Shif t + LETTER Jumptothatletterinalist

Nowonce you have synced your remote control, you can use it to operate yourmediacenter.ConnectyourUSBmodulewithmonitorandspeakersusingHDMIandaddsongstoyourXBMC;useyourremotecontrolandFLIRCtocontrolhowaudioandvideoswillplay.

Yourmediacenterisready.

In Chapter 11, we will learn about using Raspberry Pi for the purpose of time-lapsephotography.

Chapter11

UsingRaspberryPiforTime-LapsePhotography

RaspberryPicamera

RaspberryPimakesagreat,cheap,andquicksolutionfortime-lapsephotography;inthischapter,youwilllearnaboutsettingupyourRaspberryPifortime-lapsephotography.

Whatyou’llneed?

ARaspberryPi(eithermodel)

RaspberryPipowercharger

RaspberryPi5.0MPcameraModel-A

Mouseandkeyboard(wirelessorwired)

Battery(3,200mAh)

Universalremote(orspareone)

APC(desktoporlaptop)tocompletetheinitialsetup

ConfiguringRaspbian

InstallRaspbianonyourSDcard(seeChapter4).

Inorder toenable support for thecameraonRaspberryPi,weneed toadd two lines to/boot/config.txt:

start_file=start_x.elf

fixup_file=fixup_x.dat

Sincewe are going to use battery pack as the source of the power, to keep the power

consumptiondownandtominimum,weneedto‘underclock’thePibyadding:

arm_freq=300

Hardwaresetup

RaspberryPicamera

The Raspberry Pi camera is a 5 MP device and is connected to the CSI port of theRaspberryPiviaaflexibleflatcable.

Wewill be usingModel-A as it consumes less power and can be housed into a smallenclosure.OnceyouhaveinstalledRaspbianonyourSDcard,insertit intotheSDcardslot of your Raspberry Pi. Now connect your Pi with camera using CSI,monitor withHDMI,keyboardandmousewithUSB,andconnecttopowersupply.

AllowyourPitoboot.Wewillnowaddcapturescript.

Capturescript

Thecommand /opt/vc/bin/raspistill is used to capture still images.You need to put thissimplescript(scriptistakenfromDesignSpark)torunraspistillinaloop:

ROLL=$(cat/var/tlcam/series)

SAVEDIR=/var/tlcam/stills

while[true];do

filename=$ROLL-$(date-u+”%d%m%Y_%H%M-%S”).jpg

/opt/vc/bin/raspistill-o$SAVEDIR/$filename

sleep4;

done;

Every time the Pi boots, above script is executed and it captures an image every tenseconds(approx.).

Theimagefilenamecomprisesanumber,determinedbythevariable$ROLL,whichcan

beusedtoquicklydeterminewhichbootseriesitisfrom,anditwillalsoshowaccuratetimeanddateinthecaseofModel-B.

Powerconsumption

Inidlecondition,Pidraws117mA,anditrisestoabout286mAwhencamerabecomesactive.Soa3,200mAhbatterypackshouldeasilygive12hoursoperation.NextstepistoassemblePiandplaceitintoahandywindowsill.

Firstrun

Place the Raspberry Pi and the battery pack in a windowsill and properly attach thecamera to thewindowwith tape. Allow it to boot up.Wait for 12 hours, and after 12hours, itwillcontainat least5,518JPEGfiles.Remove it fromthePiandconnect it toyourPC.Youcannowbrowsethroughthecollectedphotographs.Thiswillfindgooduseincrimedetectionandhomesecurity.

InChapter12,weshalllearnaboutusingRaspberryPiasaFMtransmitter.

Chapter12

UsingRaspberryPiasFMTransmitter

It isveryeasy toconvertyourPi intoaFMtransmitter.Wehavealreadydonesomanyprojects;stepsaresame.

PreparingtheSDcard

First,downloadthisfilefromthegivenlink,andusingWinDisk32ManagerorPoweISO,unzip the file and then transfer the image to SD card:http://www.icrobotics.co.uk/wiki/images/c/c3/Pifm.tar.gz

BootingupthePi

BootupyourPiwithSDcardloadedwiththeimageandcompile

pifm.c

gcc-lm-std=c99pifm.c

Compilingandsettinguptransmission

Thiswillcreateacompiledprogramcalled‘a.out’.Now,runthefile.

Bydefault,WAVfileissetto16bit,22.5kHz,andmonomode.SetWAVfileto‘-’tousestdin.Supposeyouwant tobroadcasta song ‘sound.wav’at100.1MHz, thenenter thiscommand:

sudo./a.outsound.wav100.1

Thiscommandwilltell‘a.out’toplay‘sound.wav’andtransmititat100.1MHzFM.

Ifsuccessful,thecommandpromptwillnotdisplayanything;itwillremainidleforsometimeandwillappeartohangtillitfinishesplayingtheWAVfile.YoucanalwaysexitbypressingCTRL+C.Whenfinishedplaying,theprogramwillreturn‘exiting’.

Gettingabetterrange

Connect awire to theGPIOoutput pin (GPIOpin4bydefault).Thispinwill transmitsignalonlyabout20cm(inabovecase).Whilea20-cmwireconnectedtoaPiwillgiveyouabout10–50meterrange.

UsethisdiagramtolocateGPIOpin4onyourPi.

GPIOschema

Selecta song inasimilarwayand tuneyour radio in10–50meter range, thenyouwillhearwhateveryouaretransmitting.

RaspberryPiasFMtransmitter

That’sallweneedtolearnatthismoment.RaspberryPiisaveryusefulproduct;ifyouhaveideas,youcanturnitintorealitywithRaspberryPi.

©2013DogwoodApps