We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 66
Raspberry Pi
For Beginners
Get started with exciting coding projects
Tips & Hints
inside
w fj Jargon- -free w Step-by-step w Clear Full
Tips & Advice Tutorials Colour Guides
S
100% INDEPENDENT PapercutFREE Software! Great Games! Essential Hardware!
192 anazins
ms & cance, INSIDE!
a {—
-
Head over to your web
browser and follow these
simple instructions...
1/ Enter the following URL: www.pelpublications.com/exclusives
2] Sign up/in and from the listings of our exclusive customer
downloads, highlight the Tech Shopper Magazine option.
3/ Enter your unique download code (Listed below) in the “Enter
password to download” bar.
4] Click the Download Now! Button and your digital magazine will
automatically download
5] Your file is a high resolution POF file, which is compatible with
the majority of customer devices/platforms.
PCL37862RE
NOTE: This is a limited reader offer running from Ist June 2024 to Ist September 2024,
TTexms and conditions apply and can be found at waw,pelpublications.comRaspberry Pi
For Beginners
Y
Raspberry Pi For Beginners is the first and
only choice if you want to learn everything
about the Pi from the ground up - where the
only limitation is your imagination. Learn
how to build some amazing projects from
a retro gaming console to a home
entertainment system. The possibilities of
the Raspberry Pi are endless and the best
place to start is right here.
Papercut
www.pclpublications.com6 Get Started With The Raspberry Pi
Bane eco ieee Meee ee ce
SOMES 0 Agi) Eels
ae ey ucaicc) Emenee ese
Gad Emcee nc
meee an Ee oS OSa
Raspberry Pi 3 Cause che see
Le Co a ae me Le om ce
mf 42. Kit Youll Need and How to
SM Yael) eat)
PTO oR a eT enc TS)
ruetecu ties Parts
PMR aloe Ce es nr)
Peele Xe Mirena
26 Pico Power: the Tiny
Microcontroller
(ool ena es}
Come eaotanance Ces ees conn)
Pe ean Terminal App
ces Ra os
rosy mean a ne
56_ Connecting to the Pi Remotely
Eater scan]
Penta icla“With our Raspberry Pi guide in your corner, you willlearn and
discover how the Pi works, what you can dowith itand where to
take your Pi adventures.
It's helped people learn how computers,.coding.and electronics
work, as well as helping science and engineering, astronauts and
technicians, young and old, teachers and students.”(etlesie-luncte} Sec ERd
Get Started
with the
Raspberry Pi
SOT TO ANUSARA enon UD
Raspberry Pi; learn how it works, what kind of operating system it has, what
you need to get it up and running and much more. This is your first step into
the world of the Raspberry Pi.
In this section, you'll discover what makes the Raspberry Pi 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 me Oke
eee
|
7& Get Started with Raspberry Pi
Seca eta
Barnes ah eet rs
Poteet
Seer
Peers
omplicatng matters slighty isthe ex ate
eri ara Ete
ase etna
Pitan mead settee preter ota
Soran encer anne er a ea
Prrecewey cirtrsteet ser
eee
8 ww pelpubeatinscom
See eet eee
International Pt day 2018. This san improved version with 3
SaE Hel tre ctey tere econ eer
CoM eacbeen ieee et mena ieee
Leena at‘The Raspberry Pisa British built low cost
computer that enables everybody to learn
‘computing, start programming and explore
basic electronics. t's the size ofa credit
card but capable of running a full operating
system and doing everything a desktop does.
‘More importantly, withthe Raspberry Pi you
install your own operating system, connectall
your devices and create your own programs.
Using languages ike Scratch and Python.
There's no case so you can hook up electronic
enthusiasts control and utilise connected appliances
and electronics projects. From displaying an LCD to
controlling LEDs, using MicroPython and C+.
The Pi Pico may be small but it packs adecent punch. With t you can
expand your electronics projects, and incorporate a whole new level
of functionality that you weren't able to before with the traditional
Raspberry Pi units
micro-USB Port
Dee ce
Reuse iy
Rau ase
to upload programs and projects on to your Pico,
24 ww plpubeatinscomThe Pi Pico - Up Close 8
wecipubetionscom 25& Get Started with Raspberry Pi
Pico Power:
The Tiny Microcontroller
‘The Pico is something entirely different From the Raspberry Pi Foundation's usual releases. Whereasthe Raspberry P, now on version 4, isa
‘small computer, and even the Compute Module and the Pi 400 are stilljust computers, the Pico is actually a microcontroller.
‘Amicrocontrollr is a processing nit thats designed to work with programmable peripherals, and has input and output modules alongside
‘small amount of memory and storage capabilites. The processors are often scaled down, compared to the processor on a Raspberry Pi, or
‘even inside your desktop computer, but powerful enough to complete basic tasks.
Examples of a microcontroller in action canbe Found inside a washing
machine, or traffic lights. A washing machine has no need fora quad-core
processor, 8GB of memory, andthe ability to output to a 4K monitor.
Instead, ithas aset of microcontrollers, that are connected to various parts
‘ofthe washing machine -such asthe pump, or motor. When a signals sent
toaninputon the washing machine's microcontroller, it knows through
‘some clever programming stored nits limited memory -thatit needs to
send signal output tothe valves to allow ina certain amount oF water,
then activate the motor For the drum and soon,
‘The same canbe applied inthe traffic light example. A powerful computer
isnt necessary, 50. microcontroller will activate te red, amber and green
lights in sequence, or switch to redto stop traffic when someone presses the
‘Walkbutton
hile t would probably be interesting to have a powerful computer inside
your washing machine's overkill A microcontroller takes up less space,
uses less energy, andisnt prone tothe kind of cashes orin need ofthe
Frequent updates that a traditional computer
requires. They simply sit there, act on inputs
that come their way, process that data, and
‘output whatever is required depending on the
input actions.
Power use is the main reason why
microcontrollers are inaction everywhere we
look. There's often limited supply to devices, or
situations. A microcontroller can work effectively
with the Uimited amount of energy drawn From
_asmallsolarcell-evenin the most overcast
‘oF northern dimes. For example, on-board the
Intemational Space Station there are thousands
‘of microcontrollers in action: monitoring ar
quality, monitoring radiation levels, distributing
power and keeping track on the crew. IF each oF
these units were a more powerful computing
device, the power draw onthe SS would be
immense; so microcontrollers are the way forward
~atleast until we work out how tobuilda warp
‘core with near unimited energy, thats,
26 wwpelpubeationscomPico Power: The Tiny Microcontroller a
The Raspberry Pico GP
PROGRAMMABLE PICO
“The main difference between the microcontrollers inside your
everyday appliances and the Pico, isthat where the microcontrollers
within your washing machine are pre-programmed with thelr
instructions, the Pio isnt and can be programmed by you.
‘This means that you can use the Pic's USB port to connect toa
computer, write some code to control something, upload the code to
the Pio's RP2040 microcontroller, and watch asit does what youve
askedit do,
‘The 26 multi-function GPIO pins located down the long sides of the
Pico, can be used to solder electronics projects to. And with some
lever coding, you're able to contol the input and output of devices,
depending on ther state va the Pico microcontroller.
Each ofthe Pico's GPIO pins have specific uses, as you cansee From,
the pinout chart. This means that certain electronic components
soldered tothe pins, can be programmed using the Pico's primary
microcontroller language, MicroPython (or C+)
REMEMBER, IT'S NOT A PI
I's worth mentioning that the Raspberty Pico isn't designed the
same.as, or can replace, a Raspberry Pi. Thisisa diferent type
of device altogether. Where you'lluse your Fito browse the
Internet, play agame, do some coding and soon, the Pico can't do
that. Its designed For use with physical components and projects,
suchas lighting LEDs or responding to a button push, controlling
‘motorsand the ike.
Ifyou want more versatility For your projects, then the Raspberry
Pils tillthe perfect device to use. Fyou've got something
specificin mind, and you want to expandinto electronics and
microcontrollers, then the Pico wil i the bill Bu, ou'Lalso|
need a computer, of Raspberry Pin order to program the Picoto
begin with.
mmpcpublationscom — 278 Get Started with Raspberry Pi |
The Pico and
MicroPython
Deen gee ee cau accu Rca ies ne
installed code or routines. This allows you to program the Pico to whatever tasks or projects
rani
planned for it. But first, you'll need to set it up and get it ready to use Mi
ire
‘The Pico uses MicroPython or C/C++ code in order to communicate
with the devices willbe attached to. The code will when
‘uploaded to the Pico, runa specifi set of instructions depending
onthe electronics that are soldered to the Pico. For example, in
‘MicroPython, with an LED attached to the Pico, you would initalise
‘and import the Pin and Timer modules tel the Pico which GPIO
the LED is attached to, then setup a routine that wil use the Timer
Function to send a signal tothe LED let's say every couple of
seconds. The end result would bea blinking LED, which goes on and
off every two seconds.
Naturally, the more complex the electronics attached tothe Picoare,
then the more complex the MicroPython code willbe to make them
workin the way you want.
‘MicroPython is probably the best language to begin with when it
‘comes to programming the Pico. Like Python, it’s abit easier to get
yourhead around - when compared to C or C++ -and it's probably
slightly easierto getup and running, There's also the added
‘advantage of there being more examples of itonline, so you can dip
into the various sites around the Internet and take the code snippets
youneed to make certain devices and peripherals work
cnn sed wih ony
mecctn e
28 ww pelpubeatinscom
MICROPYTHON
'MicroPython is Python 3-based coding language thats designed to
be executed onthe RP2040 microcontroller the one thats powering
the Pi Pico. t's hight efficient language, and thanksto the co's
larger than average memory and capacity~for a microcontroller
It's the deal language to start learning. If you already have some
‘experience with Python 3, then MicroPython should be relatively
‘easy to follow; since they're essentially the same. If youve never used
Python before, then we'd recommend you take alookaat one of our
coding titles at, https: odmpubliations. com.
Before you can use MicroPython, though, youl need to flash the
Pico with the latest version of MiroPython. This means downloading
the latest version of MicroPython and uploading tonto the Pico. The
processis remarkably easy, however
Start by connecting one end of a USB cable tothe Pico. Then press
‘and hold the BOOTSEL button on the Pico, while atthe same time
plugging the other end ofthe USB cable into your computer, oF a
Raspberry Pi. Count to five, then let go ofthe BOOTSEL button
\within a few seconds the computer, or Raspberry Pi, will display a
notification that an external or removable, drive has been attached
inthe same fashion as when you plugin a USB Flash drive.
IF you open your File Manager or Explorer window, and navigate to
the newiy installed Pico storage, youll see two Files present: INDEX.
HTMand INFO_UF2.XT,
‘The INFO_UF2.TXT file contain information regarding your Peo,
{and the INDEXHTM is a web-based page that contains al the
information you'll ned to getthe Pico connected and installed with
MicroPython,‘Alternatively you can open a browser and navigate to http://www.
raspberryp.org/documentation/pico/getting started. Scroll down
Until you get to the Getting started with MicroPython section, and
Follow the on-screen instructions, Click on the Download UFZ file
button-at the bottom of the Getting Started infobox.
Once the UF? ile has been downloaded, locate tin the Downloads
Folder on your computer, and click and dragit into the Pico storage
>>'.Now, enter the Following:
print ("Hello, world!”)
Users of Python will undoubtedly recognise the syntax, butf you've
ever coded with Python before then let's explain what's going onin
thissimple line.
“The print command, as you probably assume, is used to print oF
isplay, something to the screen forthe user to read. IFyou want
tosay something to the user, then you'll need to enclose your text
inside a pair of brackets and quotation marks. n this example, we're
displaying the words Hele, worl. When the MicroPython
interpreter reads the Prine command twill naturally assume that
somethings being displayed, and look For a numberof acceptable
‘outcomes. The ist bracket and opening quotation mark means
there's going tobe some text, sothe interpreter wll look Fora closing
set of quotation marks and bracket.
Press Enter, and the words Helle, wex2A| will appearin the Shell
sedtion of Thonny.
\What you've just done is communicate directly with the Pico, and
through MicroPython on the Pico, i's recognised the command you've
‘entered and acted onit.
Just for Fun, enter the command again, but this time intentionally
miss out the lat bracket. You'l notice thatthe Shell doesn’t want
tocontinue 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 i'l just stop
itfrom working
Forthe next example, click the upper part of Thonn, where the number
“1's Now enter the Hello, world code again. When youbit Enter this
time, youll notice that instead of running the code through the Pico,
‘Thonny has created a second ne and is waiting For more input.
‘While using the Shelis grat, t's nt so good for creating multHtine
‘ode. 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 a new window asking Fora save location (This computer or
the Raspberry Pi Pico). Thisis because any code that's en entered
inthe upper section of Thonny needstobe saved First, as apy ile,
beforeit canbe executed.
30 ww pelpubeatinscom‘Selectthe Picoas the save location, then when asked, create aname for
the.py file-inthiscase calit HeloWord py and cick the OK button,
‘As soon as youve saved the file, twill automatically run and you'l'see
the output From the code displayedin the Shellbox.
‘Alternatively you can open a browser and navigate to http://www.
raspberryp.ora/documentation/pico/aetting started. Scroll down
Until you get to the Getting started with MicroPython section, and
follow the on-screen instructions. Click onthe Download UFZ ile
button~at the bottom of the Gettin Started info box.
Once the UF? ile has been downloaded, locate tin the Downloads
Folder on your computer, and click and dragit into the Pico storage
drawing, presentation and spreadsheet program,
auinme
acaeeaag
Themopastntane wefan ‘awe reer ober
ESE scirotacctntecestcing GRMMANGED S655 onan tone
anehasbayFigomitapistcner session. Alton and ire Saeco poe
= aye pean ween Sessa lay
moc
&)
50 ww plpubeatinscomPVTSNTaetiretsy posible to remove and additems tothe
Application Menu using the Main Menu Editor.
Choose Menu > Preferences > Main Menu Editor, then add or remove
ticks next to programs and sections you want to inlude\exclude. Use
‘Move Up and Move Down to rearrange items inthe Menu.
Te
@Pogannng |v @rogenning ew te
Gewaion | YG edcaun
% ofce % Borer
@ ret % @ rene
BD sounasvideo | % Qf sound video
& ccshics % & caphes
de canes % hanes
hover Blom
iF synods | wR SptenTes
Brceos | ofan
CUSTOMISE THE DESKTOP
STEIN aly Choose Menu > Preferences > Appearance
‘Settings to open the Appearance Settings
window. There are four sections: Desktop, Menu Bar, System, and
Defaults. You can use these to adjust the various options For your
system, such as colours, layout, and so on.
foe
Desktop | Menu Bar | System | Defaults
Layout Fill screen with image
Picture temple jpg
Colour
Text Colour
Documents % Wastebasket [41 Mounted Disks
Cancel 0K
PERC “erotonmoncensestetor
(BIER a the desktop wallpaper, or desktop
backoround The deautiscaled Temple’ hwever by cckingon
‘temple inthe Picture section ofthe Appearance Settings, you
hhave other images available. Naturally, you can opt For your own
System
Desaop | ers 8er efaute
Large (2212),
‘Aswith any other operating system desktop, you're able to customise the
EI {t's important that you switch off your Raspberry
Pisafely. When you are finshed with your
Raspberry Pisession click Menu > Shutdown, Three options appear:
‘Shutdown, Reboot, and Logout. lick Shutdown. Always wat For the
‘screen to go blank before removing the USB power.
rea
Raspberry P's PIXEL interface, mak
it mor personal and moreyou
The secondtabinthe Appearance Settings window
Pen UEY allows you to adjust the menu bar that runs along
the top ofthe desktop. You can change is sz, cour and events
location from the top to the bottom ofthe screen.
a more
Desktop [Menu Bar| System | Defaults
Layout Fil srean with image
Pitae foxjog
Colo
Tent Colo
Documents ¥ Wastbasket_¥ Mounted Diske
cancel OK
iw “The System tab in the Appearance Settings window will
tenable youto change the core system font, as wellas the
‘mouse cursor sie. There are numerous Fontsto choose from and, IF
‘you want, you can even install your own.
Dap
wwaipcpubleationscom 51
Take a Tour of PIXEL 6