100% found this document useful (1 vote)
407 views

Raspberry Pi For Beginners 7th Edition 2021

raspberry pi-for beginners

Uploaded by

Feras Mansour
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
100% found this document useful (1 vote)
407 views

Raspberry Pi For Beginners 7th Edition 2021

raspberry pi-for beginners

Uploaded by

Feras Mansour
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 100
com Raspberry Pi For Beginners Allyou need to get started with Raspberry Pi @ Jargon-free Tips & Advice @ Step-by-step Tutorials @ Clear Full Colour Guides Photoshop fF) Android Mac Black & White For Beginners For Beginners For Beginners Forbes i] C++ & Python For Beginners Cloud | Python | Coding Computing For Beginners For Beginners For Beginners i BS Photography | FRITZ!Box | Google | GoPro For Beginners | For Beginners | For Beginners | For Beginners Instagram iPad iPhone Landscape For Beginners For Beginners For Beginners Photography S For Beginners Raspberry Pi For Beginners pe Te ere Saar ane en ec ee oe cca eM eka ede Colt AUR CoN ta Lael) have no-one at hand to help. Conversely as the complexity of our eM mee yA eM erm ee eae} TEU Re eg Am een Rete 1) Puree ana elt La Mee R Nn D Pann alae ar rte ee RUUD Ad OTE CL Crek- elem Wa UMelelRucP ol col neleraema NAc ecu a LL DVS came arela CON n= Un melon ae Coh CT eaee A\y rime Vane ea Aeon CRE Cok ern ee fortunately for you we are here to stand beside you at every stage. ONL cues teat RRL ore naga PRL tego etc Cael CUCU ott gy of the box! We will guide you step-by-step through using all aspects Comer R enue Menta eae dy cee) ce ne Elec Ome gh (olee ee Dn Rel D oN |e Vel mcrae) A Tate eee RUA RE Mel ener Keele (“1118 and experienced user. (OMe ule ellis Ua aes Rell Ce MECN OUR a el ay TCM LeU as) a Vel Mean Contents 6 Raspberry Pi is Good For You! ES dak aa Ere es eat Oe SRL a CS Pa Nolen ey Operating System ENVerer) ED ieman in acme MTSE ee Kory ERmCoeo maean ors ae ee ee ON OR ON Ey eure SetitUp age A OS On PM akan eer acl Pelee ay ea oan EY weet ts Ri had Py Meee ae aio tS ea Ga yee gelesen NN CAEN EOS C2 CoN 50 Explore Raspbian 7 Cae 7 ee a aR 7s eu hake nea ny BCU ea Pern era men huciac cerca exe Tae eck 58 Connecting to the Pi Remotely 60 Using APT to Install and Cuetec Cecio) 68 Python on the Pi 70 Starting Python for the First Time asa J E Ze eee ee ae 76 Executing Code from the (eeu ue ea LM see usc 80 Using Comments 82 Working with Variables Caan Emeritus os 88 Conditions and Loops Careers Caren CMT ae 96 Glossary of Terms “Thanks to the Raspberry Pi’s unique setup; operating system and amazing community of imagineers, this little computer has become one of the mostimportant pieces of educational technology in the world. It’s helped people learn how computers, coding and electronics work, as well as helping science and engineering, EE ee Raia em yen ie ke ke) Aol eee Rae You will learn and discover how the Pi works, what you can do. with it and where to take your Pi adventures.” tee ¢ Eo ee teeters Scobie A Raspberry Pi is Good For You! = Raspberry Pi is Good For You! NoMa TAN RU WaLr eM ea meen mle Say hello to the Raspberry Pi; learn how it works, what kind of ES CUM Cle EL eR Oke Mi Mt eRe) and much more. This is your first step into the world of the eT) PRUE ol im ele Re eo ROU UCL Cm ath) 0k aa such a fabulous little computer and project board. There are in-depth guides to the hardware, operating system, what you'll need to begin with and enjoying the software the Pi has to offer from your computer's desktop. Now let's see what this amazing ee mR ORC ea BB Raspberry Piis Good For You! Seta eee see poe eee nT eee Perea rte rea tere ae fuentes Ua ate i fee eect Complicating matters slightly isthe existence of a Raspberry Pi Model rar Sree ee) ieee a etal type you own then type cat /proc/cpunfo atthe command li reso aan The Raspberry Pi 3 Model B+ was launched on 14 March REE eae et eee tea Poa nee tse romana re eer emat erty ‘The Raspberry Pisa British builtlow cost computer that enables everybody to learn computing, start programming and explore basicelectronics. I's the size oF credit card but capable of running afull operating system and doing everything a desktop does. More importantly, with the Raspberry Piyou install your own operating system, connect all ‘your devices and create your own programs Using languages like Scratch and Python, “There's no case so you can hook up electronic circutsto the pins and control them to get input and output, so you can hack together electronic projects at home. Setting up a Raspberry Pis pretty simple, and throughout this book well take you step bysstep from unboxing your Raspberry Pito settingit up and getting started. “There are many different models oF Raspberry Pi available and each has sightly different Features (see opposite. ‘The Fundamentals of each Raspbery Piare similar though. Each models lightweight ee introduc aero ray [ Say Hello to Raspberry Pi ‘computer on asingle board that’s roughly the size ofa credit card, Each Raspberry Pi board features a processor made by ARM, whichis similar to the models you Findina ‘mobile phone. The ARM processors fast {and lightweight butt runs a different set of software than you might be used to. There ‘are many different operating systems (05) ‘vallable, but For most ofthis book well Focus on one called Raspberry F105, which isthe OS recommended by the Raspberry Pi Foundation There'sno hard drive on the Raspberry Fi, instead the operating systems installed ‘onan SD Card (the cards typically usedin cameras). The operating system is installed ‘onto the SD Card by copying the Files to the SSD Card using a computer. We'llshow you hhow to set up the Raspberry Pi OS using a ‘Mac or Windows computer. ‘Once youhave an OS installed on the SD Card you can set up your Raspberry Pi The Raspberry Piis connected to 8 monitor via a HDMI socket whilst a keyboard and mouse is Era teeter ney Perera neces pe Perea may recent eee eerie oan ceed pies There reas soias po ‘of on boord memory. Subsequent a eerores eee cece eee ec ia ne ent ie was Ceoeatd eee Piece ate attached to the USB socket. A smaller Micro USB connection is used to provide powerto the device. Most Raspberry Pirmodels Feature ‘an thernet connection, and an Ethernet, cable is connected from your Raspberry Pito asocket on your modem router. Both the Raspberry Pi 3 and 4 models have builtin wireless networking and Bluetooth, ‘making it easy to get online. You can attach USB Wii dongle or Ethernet adaptor to older models. First it wil help to know which Raspberry Pi youare using. This can be tricky as there have been several distinct madels so far. The layouts opposite wllhelp you determine which Raspberry Pi you have. This book covers athe different models, and they offer largely similar Features, although newer models offer adaltional extras. Once yyou know which Raspberry Pi you own, you can gett up and running. eastern. Bram onto eta ety eee eae ey cease erat wna vices. The ports are smaller than you pies eres eeaers Peri iee eine ten nee nee a micro-USB adaptor to connect ered Ei Pa teat Le) ered BB Raspberry Piis Good For You! Get to Know the Raspberry Pi While the Raspberry Pi 4 is the newest model, the Pi 3 models are the most popular among the community. They're cheaper, more compatible with current hardware and software, and still pack a significant performance punch. Here's what powers the fantastic Pi 3. Get to Know the Raspberry Pi i 8 Raspberry Pi is Good For You! J Up Close with the Raspberry Pi 4 Model B FASTER AND CONNECTED ‘There’sa lotto lke about the Raspberry Pi 4: Up to 8GB of on-board memory aster quad-core CPU, support For dual 4K displays via a pair of micro-HOMI ports, and more, Let's take alook at the Pi 4, and see what t's got underthe hood. PRICING Sa ene ics Se ute eee etd Cece ee Let Ce ee eee Se uu ee re ‘£44, while the top-end, 4GB memory version will set you ‘backin the region oF €54, Together with the cost ofthe Pi Peet ene cen eta cre ‘ables (depending on whether you want to connect one or Sennen ints ts Up Close with the Raspberry Pi 4 Model B QI USB.3.0 aeons CER excellent choice. The ee rene cig eR econ ere ate ci ‘write that data, both to eas Cae peas Connectivity Perna Mace Ser Ph eee as Sra Perea cect) Sanu) Deere Wie} Cems Dea you're able to have more applicati ST ere Cn aceic ts a: Raspberry Pi is Good For You! The Pi 400 — Up Close The Raspberry Pi 400 is an " a all-in-one keyboard Pi that was i released in November 2020, Es offering the user a different approach to their Pi lifestyle. This compact and powerful Pi is ze = ‘the flagship of a new kind of Pi, and one well hope to see more of in the future. Inside the Pi 400s a modified Raspberry Pi4. I's longer, spanning the width ofthe keyboard, with alarge hheatsinkto dissipate enough heat for the overclocked ‘pracessor. The P's communication ports are spaced ‘along the back ofthe P1400 keyboard, minusa second {USB 20 port anda 3.5mm audio jack. 40-Pin GPIO The slightly recessed GPIO port Bere ett Eee ee tev Sete rec) Cie ea ce) Be eet h) Pee ee etl microSD Card Slot The microSD Card Slot is where you'llinsert Bee ees etter cer en Drees ee ced micro-HDMI Ports Beira ne ete of up to 4K at 60 Fram Peed eet! The 400 - Up Close TECH SPECS The Pi400has aslight advantage over the ee eee eee ead Dee eet es Ce eae et Pere een reas eee reer ay Pere rete meee ay pee een rae eca) Cenc Dense rl See ae eee eee) ‘microSD card pre-programmed withthe atest Pei USB-C Power The Pi 400 is powered by the 2x USB 3.0 Ports Sees ERT Peer ar peel eng aes Cc Ly jons: UK, US, ony Ser Perot) rere) wondering, where the Se cet Pen e a) eee See OS Brant era eens Cece Ens PaO need hardwired as an internal Coen eae acu CT Cun eee) DeSean Eien) een Prec) as Raspberry Pi is Good For You! Pi 400: Return of the 80s Home Computer aE) considered the golden era of the home computer, a time when computing components were small enough to fit inside the living room of a house, and versatile rte Eee wee ence BC CRUcaCo Eun Toe Oo Releasedin November 2020, and while the UK and most ofthe world was stil in Lockdown, the Raspberry Pi 400 came ata time when we ‘were beginning to feel ike there was no end to the pandemic and the restrctionsit brought Initial thoughts were that the Pi 400 was a new smalt-board computer, ina similar vein tothe Pi 4and its predecessors. However, we were quite wrong, “The Pi400isa very different beast to that ofits siblings. Rather than the naked board we've seen inthe pas, the Pi 400 came as a complete keyboard package, with the P's Familiar ports lined up along the backplate ofthe keyboard. This \F was remarkably reminiscent ofthe home icrocomputers of the 80s, the prime examples being the ZX Spectrum and the Commodore 64, Indeed, the nostalgia was strong with this one, andi brought a smile to more than oneretro Fan's Face THE REINVENTION OF THE MICROCOMPUTER les more than sheer aesthetics that makes the P 400 hark back to a simplerage of computing. Inside the keyboards Raspberry Pi4, albeit one that's had a Facelift and some hardware alterations The Pi4’sports, which are the twin micro HOM and USB 30 ports, USB. 20, Gigabit Ethemet and microSD card sot, take up the rear ofthe keyboard together witha port that connects directly tothe 40 GPIO pins ~and resembling an older style communications port fromthe tear of an XT or earlier machine. In terme of hardware the Pi inside the Pi 400 has been expanded to Fit most of the width ofthe keyboard. The processor isthe same ARM, ‘V8 Cortex-A72.as Found in the bare Raspberry Piboard, but inthis instancei’s been overclocked to 1.8GHz; 300Mbuz Faster than the bare board. There's also 4G8 of LPDDR& RAM installed, but sadly no sign oF an 8GB version vihich the Pi abare model has on offer. “The keyboarditselFis available in different language layouts: UK, US, Germany, France, Raly and Spain. Essentially it's the same keyboard thatthe PiFoundation has been selling for some tie, except ths time there's an actual Raspberry Plinside oft as opposed tot simply being multiport USB hub. ‘The overclockis thanks tothe inclusion ofa large, internal aluminium heatsink, that spreads across the entire internal space ofthe keyboard. Ths, and thanks toa couple of ar vents con the bottom of the keyboard, are what allows the Pi 400 to be overclocked to the default 1.8GHz n fact, we even took the Pi 400 toanimpressive 2.2GHz, and it remained stable and cool enough For continual operation “The heat dissipation From the large heatsinks a great ideaand one that was previously seen in the Commodore 64 There'salso. thermal sticky pad on the top ofthe heatsink, thats attached to the Pi 400's processor and helps toi as much heat.as possible from the CPU. IF ‘you getinside, youl also see why the Pi 400 s missing aUSB 20 port; since t only Features asingle 2.0 port over the Pi 4's dual USB 2.0 ports. (One of the Pi 400's USB 2.0 ports has been used as ahard-wired ribbon connector to the keyboard section ofthe unit. Again, those of you Familiar withthe internal ofan 80s home computer will recall ribbons being attached to keyboard membranes. P1400 DESKTOP COMPUTING ‘One oF the prime benefits of having the Pi 400 keyboard setup is the Fact that it can be quickly plugged intoa monitor and working from the moment you hit the power key. The Pi ‘4bare board, for example, requires a separate keyboard and mouse, and, let's be honest here, nt many folk want to see bare dcult board on their desk. True, there are some great ‘design Pi 4 cases around these days, but the Pi 400 already comes ina neat package, ‘The extra overclock brings a decent amount of oomph to the 1 400, and as such t's perfectly reasonable to use the Pi 400, asa standard desktop computer. However, there comes with itsome negatives inthis respect. hile a great device, the Pi 400i alittle too small for comfort, spedfcaly atypical working day's use. e's roughly the same size as a laptop keyboard, but the keys dont feel a5 good abit too squishy for ourtastes. But, as with most things, we'll probably get used to it over time. ‘Another caveat that's worth mentioning, is that the Pi 400 lacks 3.5mm audio port. Where the Pi4 model had one, this doesrit, instead opting to output sound via the HDMI port). While thisisrita deal-breaker For most, it does mean that For personal listening you'll need to hook upa set of headphones toyour monitor, or Find another solution. The builtin Bluetooth will connect to headphones with that technology, Pi 400: Return of the 80s aa but you're mited to wired models, then you could be looking to buy upgrades However, with that in mind, the Pi 400is anather step closerto becoming the only computer you'lever need. THE ZX PI 64 ‘There'sa good Feeling of nostalgia when pluggingin Pi 400to amonitor or TV. t's like you're back to being 10 years old again and plugging in the Spectrum or the C64 Fora spot of gaming or homework before having to unplug tall when your Mum calls, through that dinners ready. ‘Thankfully, these days I's easy to save where you were and the entire thing doesn't crash when the kettle is switched on! ‘Overall the Pi 400 sa great addition tothe Foundations stable, and one that we're sure you'l come toloveand use daily 8 Raspberry Pi is Good For You! Ten Pi 400 Projects and Ideas You may think that a Raspberry Pi 4 inside a keyboard would create some limitations, en muons ee Mm enter sone ku ee Ui n ce geen way as a standard Pi 4, but there's a lot you can get to grips with. EVERYONE LOVES PI We've put together ten possible projects that you could use your Pi 400 with that will entertain and keep you busy while helping you learn ‘more about coding, the Piand computing, STD Wee Rebcroveniirio PATRI see eve retnsthe XSpacton ori ar eases ING that of the great home computers of ee) that we include the other great &-bit home computer the Ds we thought we'dstarethese ideas vith simple revothamed fomthe 0s, the Commodore The Pluses program caled project. Fuse isa Zx Spectrum emulator that'savalable for the c6é-rasp for C64 emulation, and cn be installed via https// Raspberry Pi. Instalit, and you can enjoy some of the greatest games _c&4emulator.111mb.de/index phpste=pp_ ever created. raspilang-enBaroup=>>. Now, enter the Following: print "Hello, world!”) Users of Python wil undoubtedly recognise the syntax, butf you've never coded with Python before, then lets explain what's going on in this simple tine. “The print command, as you probably assume, I used to print, oF display, something tothe screen For the user to read. you want to'say something tothe user, then you'll need to enclose your text inside a par of brackets and quotation marks, nthis example, we're displaying the words Hel16,, world, When the MicroPython interpreter reads the Print command it ill naturally assume that ‘somethings being displayed, and look or anumber of acceptable ‘outcomes. The first bracket and opening quotation mark means there's going tobe some tex, so the interpreter willlookFor a closing set of quotation marks and bracket. Press Enter and the words Heo, WoELA will appear inthe Shell section of Thonry. \What you've just done is communicate directy wth the Pico, and through MicroPython onthe Pico, it's recognised the command youve entered andactedonit, Just for fun enter the command again, but this time intentionally ‘miss out the last bracket. You' notice that the Shell doesn’ want to.continue without the bracket, so therefore it's an error. While Using MicroPython, or most other programming languages, you'll need to be careful what you type. The slightest mistake can have dire consequences to your code ~ or, more than likely, just stop IeFrom working, For the next example, dlickthe upper part of Thonry, where the number “tis. Now enter the Hello, world code again. When you hit Enter this time, youl notice that instead of running the code through the Pico, “Thonny has created a second line ands waiting or more input. Wile using the Shells great, t's not o good For creating multHine code. Thisis where the upper section comesin.To execute the code in the upper section youl need todo the Following: Click the Run button; this opens anew window asking Fora save location (This computer or the Raspberry Pi Pico) This is because any code that's been entered in the upper section of Thonny needs tobe saved first, asa.py file, beforeit can be executed, SelectthePicoas the save location, then when asked, create a name For they fle—in this case callitHelloWorldpy~and clk the OK button ‘Assoon as you've saved the file, it will automatically runand you'l see the output from the code displayedin the Shell box ‘Alternatively, you can open a browser and navigate to https//www. raspberrypi.ora/documentation/pico/getting-started/.Scroll down, untilyou get to the Getting started with MicroPython section, and follow the onscreen instructions. lickon the Download UFZ file button--at the bottom ofthe Getting Started info box. ‘Once the UF2 file has been downloaded, lcateit in the Downloads Folder on your computer, and click and drag t into the Pico storage

You might also like