没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
Learn Raspberry Pi Programming with Python
Learn Raspberry Pi Programming with Python
www.apress.com
US $29.99
Shelve in Programming Languages/General
User level: Beginning–Intermediate
Also available:
Donat
SOURCE CODE ONLINE
Wolfram Donat
TECHNOLOGY IN ACTION
™
Learn
Raspberry Pi
Programming with
Python
LEARN TO PROGRAM ON THE WORLD’S
MOST POPULAR TINY COMPUTER.
L
earn Raspberry Pi Programming with Python shows you
how to program your nifty new $35 computer using Python
to make fun, hands-on projects, such as a web spider, a weather
station, a media server, and more.
Even if you’re completely new to programming in general, you’ll
discover how to create a home security system, a web bot, a cat toy,
an underwater photography system, a radio-controlled plane with a
camera, and even a near-space weather balloon with a camera.
You’ll also learn how to use the Pi with the Arduino as well
as the Gertboard, an expansion board with an onboard ATmega
microcontroller.
Learn Raspberry Pi Programming with Python teaches you the
following:
• Raspberry Pi and electronics basics
• Quick intro to Linux
• Python basics to get you started on a set of projects
• How to make a variety of Pi and Python projects,
including servers and gadgets with cameras
• How to use the Pi with the Arduino and the Gertboard
This book is for readers who want to learn Python on a fun platform
like the Pi and pick up some electronics skills along the way. No
programming or Linux skill is required, but a little experience with
Linux is helpful.
9781430264248
52999
ISBN 978-1-4302-6424-8
www.it-ebooks.info
v
Contents at a Glance
About the Author ���������������������������������������������������������������������������������������������������������������� xv
About the Technical Reviewer ������������������������������������������������������������������������������������������ xvii
Acknowledgments ������������������������������������������������������������������������������������������������������������� xix
Introduction ����������������������������������������������������������������������������������������������������������������������� xxi
Chapter 1: Introducing the Raspberry Pi ■ ���������������������������������������������������������������������������1
Chapter 2: Linux by the Seat of Your Pants ■ ���������������������������������������������������������������������15
Chapter 3: Introducing Python ■ ����������������������������������������������������������������������������������������31
Chapter 4: Electronics at 100 MPH ■ ����������������������������������������������������������������������������������51
Chapter 5: The Web Bot ■ ���������������������������������������������������������������������������������������������������67
Chapter 6: The Weather Station ■ ���������������������������������������������������������������������������������������81
Chapter 7: The Media Server ■ �����������������������������������������������������������������������������������������101
Chapter 8: The Home Security System ■ ��������������������������������������������������������������������������111
Chapter 9: The Cat Toy ■ ���������������������������������������������������������������������������������������������������127
Chapter 10: The Radio-Controlled Airplane ■ �������������������������������������������������������������������145
Chapter 11: The Weather Balloon ■ ����������������������������������������������������������������������������������161
Chapter 12: The Submersible ■ ����������������������������������������������������������������������������������������173
Chapter 13: The Gertboard ■ ��������������������������������������������������������������������������������������������201
Chapter 14: The Raspberry Pi and the Arduino ■ �������������������������������������������������������������215
Index ���������������������������������������������������������������������������������������������������������������������������������227
www.it-ebooks.info
xxi
Introduction
In 2006, when Eben Upton and the other founders of the Raspberry Pi Foundation looked at the state of Computer
Science (CS) programs in universities, they were dismayed. Computer science programs were being reduced to
“CS 101: How To Operate Microsoft Word” and “CS 203: Optimize Your Facebook Page.” Nobody, they realized, was
learning how to program any more, least of all before they entered college. So they hatched a plan—create a small,
cheap computer that kids could learn to program on, like the Amigas, Spectrums, and Commodore 64s of yesteryear.
ey put an ARM processor on a board, gave it (eventually) 512 MB of RAM and a VideoCore GPU, and allowed
users to interface with it using a USB keyboard, mouse, and an HDMI output port. To make it easy to program, they
designed it so that its main programming language would be Python—a powerful, easy-to-learn scripting language.
And thus the Raspberry Pi was born.
I wrote my rst program in BASIC on a Commodore VIC 20, lo these many years ago. At 5 KB of RAM, it had
less computing power than many of today’s microcontrollers, but I was still able to write a simple maze game on it,
saving my progress as I went on a cassette-tape drive. In the years since, I’ve traversed my way through the dierent
computing platforms, from Windows 3.1, to Macintosh OS 8, to a little bit of Linux. It had been a long time since I was
truly excited by a computer; the Pi was a breath of fresh air in a somewhat stale computing environment. Not only
was it small and cheap, but it was easy to get it to interact with the physical world—a real boon for anybody interested
in designing physical systems. So when I heard about its release, I signed up like about a trillion other hobbyists/
hackers/engineers and waited impatiently for mine to be delivered. en I started building stu with it and never
looked back.
If you bought a Pi but aren’t sure how to get started with it, this book is for you.
If you bought a Pi but aren’t sure what to do with it, this book is for you.
If you’re considering buying a Pi but haven’t yet because you keep thinking, “Why should I? It’s not like I can do
anything cool with it, right?”, then this book is denitely for you.
is book isn’t meant to be a textbook on Python, nor is it an exhaustive exploration of the Raspberry Pi and
everything it can do. But it is meant to be a fun, getting-started guide to this neat little computer. I hope that after you
work your way through the book, you’ll get a sense of all the things that are possible with the Pi when you combine it
with a little ingenuity and creativity on your part.
If you want to work through the projects here in order, feel free. If you’d rather skip around, doing those that
interest you, you’re welcome to do that as well. Along the way, I hope you’ll develop a familiarity with both Python
and the Pi that will enable you to continue on, building projects as you go, and perhaps inspiring others along the way.
Above all, I hope you enjoy the book and its projects. It was truly a blast to write.
Happy computing!
www.it-ebooks.info
1
Chapter 1
Introducing the Raspberry Pi
So you’ve got yourself a Raspberry Pi mini computer. Now what? Perhaps you’re familiar with the Pi and its
architecture, but you’re wondering what to do with it. Perhaps you have some experience with computers but aren’t
familiar with Linux or Raspbian, the Pi’s default operating system. Perhaps you’re already a Linux geek, but you
don’t know how to program in Python and thought it would be a good time to learn. Perhaps you have absolutely no
experience with computers beyond clicking the Start button, checking your email, and surfing the web, but you heard
about this “Raspberry Pie” thingamabob and decided to see what all the ruckus was about.
Whatever the case may be, welcome! You’re about to join a club—not a particularly exclusive one, I’m afraid,
since all it takes to join is about $35 US plus shipping—but a club nonetheless. As a member, you’ll be able to discuss
package managers, ARM11 processors, and dot config files intelligently with anyone who will listen. You’ll know about
drivers and APIs. You’ll become familiar with servos, LEDs, and cameras-on-a-chip. And, perhaps most importantly,
you’ll be able to connect to your new mini computer, program it in one of many different programming languages
(though this book deals exclusively with Python), build projects, and interface those projects with the Pi, enabling it to
interact with the physical world and do some very cool things.
With this book, I hereby induct you into this club. Your experience doesn’t matter because I’ll take you step
by step through the process of setting up your Pi so that you can work with it with a minimum of headaches. I’ll try
to give you a solid background in Linux so that you understand what’s going on behind the scenes, and I’ll devote
a long chapter on introducing you to Python, the scripting language that all the fashionable geeks are scripting in.
Google uses it, NASA uses it, and the Book of Faces uses it. Let’s face it, Perl is so yesterday. I will also devote a chapter
introducing you to the nuts and bolts of building electronics projects—something many technical and programming
books either gloss over or neglect completely. There are safety factors to consider (I very nearly had a small explosion
when I shorted out a battery pack, for instance) as well as just good building practice. For example, you’ll learn how to
make a good solder joint and how to avoid slicing your index finger off with an X-ACTO knife, as well as the difference
between a 40W and a 40KW resistor.
Of course, if you’re already familiar with all those things, feel free to skip ahead to the good stuff: the projects.
All of them can be constructed in a weekend or so (or a month or two, depending on your motivation level and length
of your honey-do list), and all are programmed in Python. I’ll give you a shopping list of parts at the beginning of each
project, with places to get the parts, and then we’ll dive right in. They don’t necessarily build on each other, nor are
they in any particular order of complexity; if you want to build the Cat Entertainer and skip the Home Media Server,
it’s perfectly all right.
What kind of projects can you do with a Pi? You’d be surprised: the Pi’s small size belies its impressive computing
power. It has been used for everything from web servers to car computers (carputers) to cluster computing, when
hooked up in large groups. I hope that after you finish this book you’ll have not only some more ideas, but the skills
necessary to put those ideas into practice.
Whatever your reason for picking up this book, your main objective should be to have fun and learn something!
I’ll do what I can to lead the way.
www.it-ebooks.info
剩余243页未读,继续阅读
资源评论
andylu5212121
- 粉丝: 14
- 资源: 92
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功