Contents
What They’re Saying. .................................................................................................. vii
Preface. .......................................................................................................................... ix
1/Getting Up and Running ............................................................................................1
A Tour of the Boards ..........................................................................................................2
The Proper Peripherals .....................................................................................................8
The Case ..........................................................................................................................13
Choose Your Distribution ................................................................................................15
Flash the SD Card............................................................................................................15
For Advanced Users: Create Your Own Disk Image ................................................16
Booting Up .......................................................................................................................17
Configuring Your Pi ..........................................................................................................17
Getting Online ..................................................................................................................22
Shutting Down .................................................................................................................24
Running Headless ....................................................................................................24
Troubleshooting...............................................................................................................25
Going Further ...................................................................................................................26
2/Getting Around Linux on the Raspberry Pi. ..........................................................27
Using the Command Line ...............................................................................................31
Files and the File system ..........................................................................................32
More Linux Commands ..................................................................................................37
Processes ..................................................................................................................39
Sudo and Permissions .............................................................................................41
The Network .............................................................................................................43
/etc ...................................................................................................................................44
Setting the Date and Time ..............................................................................................44
Installing New Software ..................................................................................................45
Sound in Linux .................................................................................................................46
Upgrading Your Firmware ...............................................................................................46
Going Further ...................................................................................................................47
iv Contents
GSW_RASPI_4ED_FIN.indd 4GSW_RASPI_4ED_FIN.indd 4 10/28/21 10:53 AM10/28/21 10:53 AM
3/Other Operating Systems and Linux Distributions. .............................................49
Distributions for Home Theater .....................................................................................50
Distributions for Music ...................................................................................................52
Retro Computing and Retro Gaming .............................................................................53
Internet of Things ............................................................................................................53
Other Useful Distributions ..............................................................................................54
Going Further ...................................................................................................................55
4/Python on the Pi ........................................................................................................57
Hello, Python....................................................................................................................58
A Bit More Python ...........................................................................................................60
Objects and Modules ......................................................................................................63
Even More Modules .........................................................................................................67
Launching Other Programs from Python ......................................................................70
Troubleshooting Errors ...................................................................................................72
Going Further ...................................................................................................................73
5/Arduino and the Pi ....................................................................................................75
Installing Arduino on the Raspberry Pi OS ....................................................................78
Finding the Serial Port .............................................................................................79
Talking in Serial ................................................................................................................80
Using Firmata ..................................................................................................................84
Going Further ...................................................................................................................86
6/Basic Input and Output. ............................................................................................87
Using Inputs and Outputs ...............................................................................................90
Digital Output: Lighting Up an LED .........................................................................92
Digital Input: Reading a Button ...............................................................................97
Project: Cron Lamp Timer ............................................................................................100
Scripting Commands .............................................................................................100
Connecting a Lamp ................................................................................................102
Scheduling Commands with Cron ........................................................................103
Going Further .................................................................................................................106
7/Programming Inputs and Outputs with Python .................................................107
Installation .....................................................................................................................107
Testing GPIO in Python .................................................................................................109
Blinking an LED .............................................................................................................110
Reading a Button ...........................................................................................................112
Project: Simple Soundboard ........................................................................................114
Going Further .................................................................................................................119
Contents v
GSW_RASPI_4ED_FIN.indd 5GSW_RASPI_4ED_FIN.indd 5 10/28/21 10:53 AM10/28/21 10:53 AM
8/Analog Input and Output .......................................................................................121
Output: Converting Digital to Analog ...........................................................................122
Test-Driving PWM ...................................................................................................124
Taking PWM Further ...............................................................................................125
Input: Converting Analog to Digital ..............................................................................126
Variable Resistors ...................................................................................................132
Going Further .................................................................................................................136
9/Working with Cameras. ..........................................................................................137
Connecting and Testing the Camera Module ..............................................................141
Project: Making a GIF .............................................................................................144
Capturing Video ......................................................................................................144
Testing USB Webcams ..................................................................................................145
Installing and Testing Open CV .....................................................................................146
Additional Step for the Raspberry Pi Camera Module ........................................148
Displaying an Image ......................................................................................................148
Modifying an Image .......................................................................................................151
Accessing the Camera ..................................................................................................153
Face Detection ...............................................................................................................156
Project: Raspberry Pi Photobooth ...............................................................................158
Going Further .................................................................................................................163
10/Python and the Internet. ...................................................................................... 165
Download Data from a Web Server ..............................................................................165
Fetching the Weather Forecast ..............................................................................167
Serving Pi (Be a Web Server)........................................................................................176
Flask Basics ............................................................................................................176
Connecting the Web to the Real World ........................................................................180
Project: Web Lamp ........................................................................................................183
Going Further .................................................................................................................188
A/Writing an SD Card Image ....................................................................................189
B/The Raspberry Pi Pico ............................................................................................197
C/Another Raspberry Pi?! .........................................................................................210
Index ............................................................................................................................214
GSW_RASPI_4ED_FIN.indd 6GSW_RASPI_4ED_FIN.indd 6 10/28/21 10:53 AM10/28/21 10:53 AM
What They’re Saying
...about
Getting Started with Raspberry Pi, 4th Edition
An exceptional introduction to the Raspberry Pi, accessible to
a beginner and with in-depth references for experienced
makers.
—Tim Wright, Aerospace Engineer
“I’m a kid from New York City. I thought the book was really
helpful with the command line. I wanted to do some stuff with
a project, but I was quite intimidated. Now that I read this
book, I can set off!”
—Kenji D., age 11.
vii
GSW_RASPI_4ED_FIN.indd 7GSW_RASPI_4ED_FIN.indd 7 10/28/21 10:53 AM10/28/21 10:53 AM
GSW_RASPI_4ED_FIN.indd 8GSW_RASPI_4ED_FIN.indd 8 10/28/21 10:53 AM10/28/21 10:53 AM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset