更新时间:2021-07-02 23:49:20
封面
版权信息
Credits
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Getting Started with Python and the Raspberry Pi Zero
Let's get started!
Things needed for this book
Buying the Raspberry Pi Zero
Introduction to the Raspberry Pi Zero
The features of the Raspberry Pi Zero
The setup of the Raspberry Pi Zero
Soldering the GPIO headers
Enclosure for the Raspberry Pi Zero
OS setup for the Raspberry Pi
micro SD card preparation
Let's learn Python!
The Hello World example
Setting up your Raspberry Pi Zero for Python programming
IDLE's interactive tool
The text editor approach
Launching the Python interpreter via the Linux Terminal
Executing Python scripts using the Linux Terminal
The print() function
The help() function
Summary
Arithmetic Operations Loops and Blinky Lights
Hardware required for this chapter
Arithmetic operations
Bitwise operators in Python
Logical operators
Data types and variables in Python
Reading inputs from the user
The formatted string output
The str.format() method
An exercise for the reader
Another exercise for the reader
Concatenating strings
Loops in Python
A for loop
Indentation
Nested loops
A while loop
Raspberry Pi's GPIO
Blinky lights
Code
The applications of GPIO control
Conditional Statements Functions and Lists
Conditional statements
An if-else statement
if-elif-else statement
Breaking out of loops
The applications of conditional statements: executing tasks using GPIO
Breaking out a loop by counting button presses
Functions in Python
Passing arguments to a function:
Returning values from a function
The scope of variables in a function
GPIO callback functions
DC motor control in Python
Some mini-project challenges for the reader
Communication Interfaces
UART - serial port
Raspberry Pi Zero's UART port
Setting up the Raspberry Pi Zero serial port
Example 1 - interfacing a carbon dioxide sensor to the Raspberry Pi
Python code for serial port communication
I2C communication
Example 2 - PiGlow
Installing libraries
Example
Example 3 - Sensorian add-on hardware for the Raspberry Pi
I2C drivers for the lux sensor
Challenge
The SPI interface
Example 4 - writing to external memory chip
Challenge to the reader
Data Types and Object-Oriented Programming in Python
Lists
Operations that could be performed on a list
Append element to list:
Remove element from list:
Retrieving the index of an element