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

Programming the Raspberry Pi, Third Edition: Getting Started with Python Simon Monk - eBook PDF download

The document is an overview of the book 'Programming the Raspberry Pi, Third Edition' by Simon Monk, which teaches readers how to program the Raspberry Pi using Python. It covers various topics including Python basics, graphical user interfaces, game programming, and interfacing with hardware through GPIO. The book also includes practical projects and resources for further learning, emphasizing the versatility and affordability of the Raspberry Pi as a computing platform.

Uploaded by

readolokara7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
17 views

Programming the Raspberry Pi, Third Edition: Getting Started with Python Simon Monk - eBook PDF download

The document is an overview of the book 'Programming the Raspberry Pi, Third Edition' by Simon Monk, which teaches readers how to program the Raspberry Pi using Python. It covers various topics including Python basics, graphical user interfaces, game programming, and interfacing with hardware through GPIO. The book also includes practical projects and resources for further learning, emphasizing the versatility and affordability of the Raspberry Pi as a computing platform.

Uploaded by

readolokara7
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Programming the Raspberry Pi, Third Edition:

Getting Started with Python Simon Monk - eBook


PDF install download

https://ebookluna.com/download/programming-the-raspberry-pi-
third-edition-getting-started-with-python-ebook-pdf/

Download more ebook from https://ebookluna.com


Instant digital products (PDF, ePub, MOBI) ready for you
Download now and discover formats that fit your needs...

Programming Arduino: Getting Started with Sketches 3rd


Edition Simon Monk - eBook PDF

https://ebookluna.com/download/programming-arduino-getting-started-
with-sketches-ebook-pdf/

ebookluna.com

Hacking Electronics: Learning Electronics with Arduino and


Raspberry Pi, 2nd Edition Simon Monk - eBook PDF

https://ebookluna.com/download/hacking-electronics-learning-
electronics-with-arduino-and-raspberry-pi-2nd-edition-ebook-pdf/

ebookluna.com

Programming Arduino: Getting Started with Sketches 2nd


Edition - eBook PDF

https://ebookluna.com/download/programming-arduino-getting-started-
with-sketches-tab-ebook-pdf/

ebookluna.com

Programming With STM32: Getting Started With the Nucleo


Board and C/C++ - eBook PDF

https://ebookluna.com/download/programming-with-stm32-getting-started-
with-the-nucleo-board-and-c-c-ebook-pdf/

ebookluna.com
Programming the Photon: Getting Started with the Internet
of Things 1st edition - eBook PDF

https://ebookluna.com/download/programming-the-photon-getting-started-
with-the-internet-of-things-ebook-pdf/

ebookluna.com

Programming the Photon: Getting Started with the Internet


of Things (Tab) 1st Edition - eBook PDF

https://ebookluna.com/download/programming-the-photon-getting-started-
with-the-internet-of-things-tab-ebook-pdf/

ebookluna.com

Programming the Intel Galileo: Getting Started with the


Arduino - Compatible Development Board 1st Edition - eBook
PDF
https://ebookluna.com/download/programming-the-intel-galileo-getting-
started-with-the-arduino-compatible-development-board-ebook-pdf/

ebookluna.com

Programming Arduino Next Steps: Going Further with


Sketches 2nd Edition Simon Monk - eBook PDF

https://ebookluna.com/download/programming-arduino-next-steps-going-
further-with-sketches-ebook-pdf/

ebookluna.com

Raspberry Pi Electronics Projects for the Evil Genius 1st


Edition Norris - eBook PDF

https://ebookluna.com/download/raspberry-pi-electronics-projects-for-
the-evil-genius-ebook-pdf/

ebookluna.com
About the Author
Dr. Simon Monk has a bachelor’s degree in cybernetics and computer
science and a Ph.D. in software engineering. He is now a full-time writer and
has authored numerous books, including Programming Arduino, 30 Arduino
Projects for the Evil Genius, Hacking Electronics, and Raspberry Pi
Cookbook. Dr. Monk also designs products for MonkMakes.com. You can
follow him on Twitter, where he is @simonmonk2.
Copyright © 2021, 2016, 2013 by McGraw Hill. All rights reserved. Except
as permitted under the United States Copyright Act of 1976, no part of this
publication may be reproduced or distributed in any form or by any means, or
stored in a database or retrieval system, without the prior written permission
of the publisher, with the exception that the program listings may be entered,
stored, and executed in a computer system, but they may not be reproduced
for publication.

ISBN: 978-1-26-425736-2
MHID: 1-26-425736-8

The material in this eBook also appears in the print version of this title:
ISBN: 978-1-26-425735-5, MHID: 1-26-425735-X.

eBook conversion by codeMantra


Version 1.0

All trademarks are trademarks of their respective owners. Rather than put a
trademark symbol after every occurrence of a trademarked name, we use
names in an editorial fashion only, and to the benefit of the trademark owner,
with no intention of infringement of the trademark. Where such designations
appear in this book, they have been printed with initial caps.

McGraw-Hill Education eBooks are available at special quantity discounts to


use as premiums and sales promotions or for use in corporate training
programs. To contact a representative, please visit the Contact Us page at
www.mhprofessional.com.

Information has been obtained by McGraw Hill from sources believed to be


reliable. However, because of the possibility of human or mechanical error by
our sources, McGraw Hill, or others, McGraw Hill does not guarantee the
accuracy, adequacy, or completeness of any information and is not
responsible for any errors or omissions or the results obtained from the use of
such information.

TERMS OF USE
This is a copyrighted work and McGraw-Hill Education and its licensors
reserve all rights in and to the work. Use of this work is subject to these
terms. Except as permitted under the Copyright Act of 1976 and the right to
store and retrieve one copy of the work, you may not decompile, disassemble,
reverse engineer, reproduce, modify, create derivative works based upon,
transmit, distribute, disseminate, sell, publish or sublicense the work or any
part of it without McGraw-Hill Education’s prior consent. You may use the
work for your own noncommercial and personal use; any other use of the
work is strictly prohibited. Your right to use the work may be terminated if
you fail to comply with these terms.

THE WORK IS PROVIDED “AS IS.” McGRAW-HILL EDUCATION


AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES
AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR
RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING
ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE
WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY
DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO IMPLIED WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
McGraw-Hill Education and its licensors do not warrant or guarantee that the
functions contained in the work will meet your requirements or that its
operation will be uninterrupted or error free. Neither McGraw-Hill Education
nor its licensors shall be liable to you or anyone else for any inaccuracy, error
or omission, regardless of cause, in the work or for any damages resulting
therefrom. McGraw-Hill Education has no responsibility for the content of
any information accessed through the work. Under no circumstances shall
McGraw-Hill Education and/or its licensors be liable for any indirect,
incidental, special, punitive, consequential or similar damages that result
from the use of or inability to use the work, even if any of them has been
advised of the possibility of such damages. This limitation of liability shall
apply to any claim or cause whatsoever whether such claim or cause arises in
contract, tort or otherwise.
To my brothers, Andrew and Tim Monk, for their love and wisdom.
CONTENTS AT A GLANCE
1 Introduction

2 Getting Started

3 Python Basics

4 Strings, Lists, and Dictionaries

5 Modules, Classes, and Methods

6 Files and the Internet

7 Graphical User Interfaces

8 Games Programming

9 Interfacing Hardware

10 LED Fader Project

11 Prototyping Project (Clock)

12 Raspberry Pi Robot

13 What Next

Index
CONTENTS
Preface
Acknowledgments
Introduction

1 Introduction
What Is the Raspberry Pi?
What Can You Do with a Raspberry Pi?
A Tour of the Raspberry Pi
Setting Up Your Raspberry Pi
Buying What You Need
Connecting Everything Together
Booting Up
Summary

2 Getting Started
Linux
The Desktop
The Command Line
Navigating with the Terminal
sudo
Applications
Internet Resources
Summary

3 Python Basics
Mu
Python Versions
Python Shell
Editor
Numbers
Variables
For Loops
Simulating Dice
If
Comparisons
Being Logical
Else
While
The Python Shell from the Terminal
Summary

4 Strings, Lists, and Dictionaries


String Theory
Lists
Functions
Hangman
Dictionaries
Tuples
Multiple Assignment
Multiple Return Values
Exceptions
Summary of Functions
Numbers
Strings
Lists
Dictionaries
Type Conversions
Summary
5 Modules, Classes, and Methods
Modules
Using Modules
Useful Python Libraries
Object Orientation
Defining Classes
Inheritance
Summary

6 Files and the Internet


Files
Reading Files
Reading Big Files
Writing Files
The File System
Pickling
JSON
Internet
Summary

7 Graphical User Interfaces


guizero
Hello World
Temperature Converter
Other GUI Widgets
Pop-Ups
Menus
Summary

8 Games Programming
What Is Pygame?
Coordinates
Hello Pygame
A Raspberry Game
Following the Mouse
One Raspberry
Catch Detection and Scoring
Timing
Lots of Raspberries
Summary

9 Interfacing Hardware
GPIO Pin Connections
Pin Functions
Serial Interface Pins
Power Pins
Hat Pins
Breadboarding with Jumper Wires
Digital Outputs
Step 1. Put the Resistor on the Breadboard
Step 2. Put the LED on the Breadboard
Step 3. Connect the Breadboard to the GPIO Pins
Analog Outputs
Digital Inputs
Analog Inputs
Hardware
The Software
HATs
Summary

10 LED Fader Project


What You Need
Hardware Assembly
Software
Summary
11 Prototyping Project (Clock)
What You Need
Hardware Assembly
Software
Phase Two
Summary

12 Raspberry Pi Robot
Set Up the Raspberry Pi Zero W
Web-Controlled Rover
What You Need
Hardware
Software
Autonomous Rover
What You Need
Hardware
Software
Summary

13 What Next
Linux Resources
Python Resources
Raspberry Pi Resources
Programming Languages
Scratch
C
Other Languages
Applications and Projects
Media Center (Kodi)
Home Automation
Summary

Index
PREFACE
The Raspberry Pi™ is rapidly becoming a worldwide phenomenon. People
are waking up to the possibility of a $35 (U.S.) computer that can be put to
use in all sorts of settings—from a desktop workstation to a media center to a
controller for a home automation system.
This book explains in simple terms, to both nonprogrammers and
programmers new to the Raspberry Pi, how to start writing programs for the
Pi in the popular Python programming language. It then goes on to give you
the basics of creating graphical user interfaces and simple games using the
pygame module.
The software in the book uses Python 3, and the Mu editor. The Raspberry
Pi OS distribution recommended by the Raspberry Pi Foundation is used
throughout the book.
The book starts with an introduction to the Raspberry Pi and covers the
topics of buying the necessary accessories and setting everything up. You
then get an introduction to programming while you gradually work your way
through the next few chapters. Concepts are illustrated with sample
applications that will get you started programming your Raspberry Pi.
Four chapters are devoted to programming and using the Raspberry Pi’s
GPIO connector, which allows the device to be attached to external
electronics. These chapters include three sample projects—a LED lighting
controller, a LED clock, and a Raspberry Pi–controlled robot, complete with
ultrasonic rangefinder.
Here are the key topics covered in the book:

Python numbers, variables, and other basic concepts


Strings, lists, dictionaries, and other Python data structures
Modules and object orientation
Files and the Internet
Graphical user interfaces using guizero
Game programming using pygame
Interfacing with hardware via the GPIO connector
Sample hardware projects

All the code listings in the book are available for download from the
book’s repository on Github at https://github.com/simonmonk/prog_pi_ed3,
where you can also find other useful material relating to the book, including
errata.

Simon Monk
ACKNOWLEDGMENTS
As always, I thank Linda for her patience and support.
At TAB/McGraw Hill, my thanks go out to my editor Lara Zoble, and I
also thank Jyoti Shaw of MPS Limited. As always, it was a pleasure working
with such a great team.
INTRODUCTION
Since the first Raspberry Pi™ model B revision 1 was released in 2012, there
have been a number of upgrades to the original hardware. The Raspberry Pi 4
has increased the processing power and memory of the Raspberry Pi and the
Pi Zero provides a very low cost option, while the Raspberry Pi 400 is
actually built into a keyboard. These new versions of the Raspberry Pi have
been largely compatible with the original device, but there are a few changes
to both the hardware and the standard Raspberry Pi OS distribution that
warrant a new edition of this book.
In particular, I have changed all the user interface code from Tkinter to the
much easier to use guizero and I have also changed the code examples that
used RPi.GPIO to gpiozero.

The Raspberry Pi Zero.


Much of this book is concerned with learning Python, the most common
programming language used with the Raspberry Pi, and this remains largely
unchanged. However, Chapter 7 has been rewritten to use guizero, and
Chapters 9 to 11, which deal with hardware, have been updated to use the
gpiozero library.
Although, at the time of writing this book, the current model of Raspberry
Pi is the Raspberry Pi 4, for simplicity I will just use the term Raspberry Pi to
refer to all models of Raspberry Pi unless the situation needs a distinction to
be drawn.
1
Introduction

The Raspberry Pi™ went on general sale at the end of February 2012 and
immediately crashed the websites of the suppliers chosen to take orders for it.
Since then a number of new models culminating in the Raspberry Pi 4 (at
the time of writing) have been released. So what was so special about this
little device and why has it created so much interest?

What Is the Raspberry Pi?


The Raspberry Pi 4, shown in Figure 1-1, is a computer that runs the Linux
operating system. It has USB sockets you can plug a keyboard and mouse
into and no less than two HDMI (High-Definition Multimedia Interface)
video outputs you can connect a TV or monitor into. Many monitors only
have a VGA connector, and Raspberry Pi will not work with this. However,
if your monitor has a DVI connector, cheap HDMI-to-DVI adapters are
available.
Figure 1-1 The Raspberry Pi 4.

When Raspberry Pi boots up, you get the Linux desktop shown in Figure
1-2. This really is a proper computer, able to run an office suite, video
playback capabilities, games, and the lot. It’s not Microsoft Windows;
instead, it is Windows’ open source rival Linux (Debian Linux), and the
windowing environment is called Pixel.
Figure 1-2 The Raspberry Pi Pixel desktop.

It’s small (the size of a credit card) and extremely affordable (starting at
$30). Part of the reason for this low cost is that some components are not
included with the board or are optional extras. For instance, it does not come
in a case to protect it—it is just a bare board. Nor does it come with a power
supply, so you will need to find yourself a 5V USB-C power supply, much
like you would use to charge a phone (the power supply capable of supplying
2A and 3A is recommended). Note that previous models of Raspberry Pi use
a micro-USB connector for power rather than USB-C. They also use less
current.

What Can You Do with a Raspberry Pi?


You can do pretty much anything on a Raspberry Pi that you can on any other
Linux desktop computer, with a few limitations. The Raspberry Pi uses a
micro-SD card in place of a hard disk. The older Raspberry Pi models A and
B use a full-size SD card, although you can plug in a USB hard disk. You can
edit office documents, browse the Internet, and play games (even games with
quite intensive graphics, such as Quake).
The low price of the Raspberry Pi means that it is also a prime candidate
for use as a media center. It can play on two screens at 4k resolution.

A Tour of the Raspberry Pi


Figure 1-3 labels the various parts of a Raspberry Pi. This figure takes you on
a tour of the Raspberry Pi 4.

Figure 1-3 The anatomy of a Raspberry Pi 4.

The RJ-45 Ethernet connector is shown in the top-right corner of the


figure. If your home hub is handy, you can plug your Raspberry Pi directly
into your local network. The Raspberry Pi 4 and even earlier models like the
Raspberry Pi 3 have built-in Wi-Fi that is usually a more convenient way of
connecting to your network and the Internet.
Immediately below the Ethernet socket you’ll find two pairs of USB
sockets. You can plug a keyboard, mouse, or external hard disks into the
board.
In the bottom-center of the figure you’ll find an audio socket that provides
a stereo analog signal for headphones or powered speakers. This socket also
provides a composite video signal. The HDMI connector is also sound
capable.
You are unlikely to use the composite video feature of the audio/AV
socket connector unless you are using your Raspberry Pi with an older TV.
You are far more likely to use one of the HDMI connectors. HDMI is higher
quality, includes sound, and can be connected to DVI-equipped monitors
with a cheap adapter.
At the top of the Pi are two rows of pins. These are called GPIO (General
Purpose Input/Output) pins, and they allow the Raspberry Pi to be connected
to custom electronics. Users of the Arduino and other microcontroller boards
will be used to the idea of GPIO pins. Later, in Chapter 12, we will use these
pins to enable our Raspberry Pi to be the “brain” of a little roving robot by
controlling its motors. In Chapter 11, we will use the Raspberry Pi to make
an LED clock.
The Raspberry Pi 2 has a micro-SD card slot underneath the board. This
SD card needs to be at least 8GB in size. It contains the computer’s operating
system as well as the file system in which you can store any documents you
create, so it’s a good idea to get a bigger SD card than the minimum. 32GB is
a good size. The SD card is an optional extra when buying your Raspberry Pi.
Preparing your own SD card is a little unusual, and suppliers such as SK
Pang, Farnell, and RS Components all sell already-prepared micro-SD cards.
Because no disk is built into your Raspberry Pi, this card is effectively your
computer, so you could take it out and put it in a different Raspberry Pi and
all your stuff would be there.
Below the micro-SD card is a USB-C (micro-USB on older Raspberry Pis)
socket. This is used to supply power to the Raspberry Pi. Therefore, you will
need a power supply with a USB-C on the end. This is the same type of
connector used by many mobile phones, including most Android phones. Do,
however, check that it is capable of supplying at least 2.5A; otherwise, your
Raspberry Pi may behave erratically.
For those interested in technical specs, the big square chip in the center of
the board is where all the action occurs. This is Broadcom’s “System on a
Chip” and includes 1, 4, or 8GB (depending on your Pi 4) of memory as well
as the graphics and general-purpose processors that drive the Raspberry Pi 4.
You may also have noticed flat cable connectors on the Pi 4. The
connector on the far left is for an LCD display and the connector bottom-
center is for the special Raspberry Pi Camera Module.
Setting Up Your Raspberry Pi
You can make your life easier by buying a prepared micro-SD card and
power supply when you buy your Raspberry Pi, and for that matter you may
as well get a USB keyboard and mouse (unless you have them lurking around
the house somewhere). Let’s start the setup process by looking at what you
will need and where to get it from.

Buying What You Need


Table 1-1 shows what you will need for a fully functioning Raspberry Pi 4
system. The Raspberry Pi itself is sold through two worldwide distributors
based in the United Kingdom: Farnell (and the related U.S. company
Newark) and RS Components, as well as many online hobby electronics
companies like Adafruit and Sparkfun.

Table 1-1 A Raspberry Pi Kit

Power Supply
Figure 1-4 shows a typical USB power supply.

Figure 1-4 USB power supply.

You may be able to use a power supply from an old phone or the like, as
long as it is 5V and can supply enough current. It is important not to overload
the power supply because it could get hot and fail (or even be a fire hazard).
Therefore, the power supply should be able to supply at least 2.5A, but 3A
would give the Raspberry Pi a little extra when it comes to powering the
devices attached to its USB ports. If you have an older model B Pi 2 or 3,
then a 1.5A micro-USB power adapter will be sufficient.
If you look closely at the specs written on the power supply, you should be
able to determine its current supply capabilities. Sometimes its power-
handling capabilities will be expressed in watts (W); if that’s the case, it
should be 15W, this is equivalent to 3A.

Keyboard and Mouse


The Raspberry Pi will work with pretty much any USB keyboard and mouse.
You can also use most wireless USB keyboards and mice—the kind that
Other documents randomly have
different content
“Take my picture,” cried a stout
little girl, and then threw the
basket over her head and struck
an attitude.

“All right,” was my reply.

“Oh!” she said, “I want my cat


in,” and raced off to the house
to secure it.
ONE OF THE HUMBLER HOUSES

She was no sooner back and in


position than she
found a new trouble.
She had on a little
cap with a very
narrow visor, and as
the sun had now
come out, its bright
light made her eyes
wink. Suddenly she
spoke up and said
the little cap made
A DESERTED HOME her cry, and wanted
to get a hat, if I
would let her. When
she returned I made haste to snap the camera before any other
ideas could occur to her. We were pretty well acquainted by the time
I finished, and she wanted to know how much I charged for my
picture, and said she guessed she would get one if I came that way
again.

The town of Sunderland lay a little beyond. It is a typical valley


town, with a long, wide street lined by elms and maples, thickset on
either side by the white houses of its people. Everything looked
thrifty and well kept. The wind blew gustily, and sometimes would
start the leaves which had just begun to strew the ground beneath
and send windrows of them scurrying along the road like live armies
on a charge.

I was in the village in the late


afternoon, when school let
out. It was interesting to note
the way the boys came down
the street slamming about,
shouting, and tripping each
other up. It seemed to me
GETTING A LOAD OF SAWDUST BACK OF THE SAW-MILL
there was one sort of
youngster who had need to
reform. You find this variety in every village where half a dozen boys
can get together. He talks in a loud voice when any witnesses or a
stranger is about, is rude to his fellows, jostles them and orders
them about, cracks crude jokes, either exceedingly pointless, or else
of great age and worn threadbare, at which he himself has to do a
good share of the laughing. He is, in short, showing off, and the
show is a very poor one. He makes himself both disagreeable and
ridiculous to most, and can only win admiration from a few weak-
minded companions or overawed small boys. He is apt to grow into
something of a bully among those weaker than himself, and to
become, when older, a young man with a swagger.

It was October, the days were short, and I had early to seek a
stopping-place for the night. It still lacked something of supper-time
when I put my horse out at one of the farm-houses, and I took the
opportunity for a walk on the village street. The damp gloom of
evening had settled down. There were lights in the windows and
movements at the barns, and a team or two was jogging homeward
along the road. Westward, in plain sight across the river, was the
heavy spur of a mountain, dark against the evening sky. A single
little light was trembling on the summit of the crag. This came from
a building known as “the prospect house.” The proprietor lives there
the year around, and from Sunderland’s snug street, on cold winter
nights, the light is still to
be seen sending out
shivering rays into the
frosty darkness.

A MEADOW STREAM

A HOME UNDER THE ELMS

I returned presently to the house and had supper. That finished, the
small boy of the family brought a cup of boiled chestnuts, and while
we munched them, explained how he had picked up eighty-one
quarts of nuts so far that year. In his pocket the boy had other
treasures. He pulled forth a handful of horse-chestnuts, and told me
they grew on a little tree down by the burying-ground.
“The boys up at our school make men of ’em,” he said. “They take
one chestnut and cut a face on it like you do on a pumpkin for a
jack-o’-lantern. That’s the head. Then they take a bigger one and cut
two or three places in front for buttons, and make holes to stick in
toothpicks for legs, and they stick in more for arms, and with a little
short piece fasten the head on the body. Then they put ’em up on
the stove-pipe where the teacher can’t get ’em, and they stay there
all day. Sometimes they make caps for ’em.” He got out his jack-
knife and spent the rest of the evening manufacturing these queer
little men for my benefit.

A DOOR-STEP GROUP

The next morning I turned eastward and went along the quiet,
pleasant roads, now in the woods, now among pastures where the
wayside had grown up to an everchanging hedge of bushes and
trees. Much of the way was uphill, and I sometimes came out on
open slopes which gave far-away glimpses over the valley I had left
behind.

About noon I stopped to sketch one of the picturesque watering-


troughs of the region. There was a house close by, and a motherly
looking old lady peeked out at me from the door to discover what I
was up to. I asked if I might stay to dinner. She said I might if I
would be content with their fare, and I drove around to the barn. An
old gentleman and his hired man were pounding and prying at a big
rock which protruded above the surface right before the wagon-
shed. They had blasted it, and were now getting out the fragments.
By the time I had my horse put out, dinner was ready, and we all
went into the house. We had “a boiled dinner,”—potatoes, fat pork,
cabbage, beets, and squash all cooked together. The dish was new
to me, but I found it quite eatable.

I was again on the road, jogging comfortably along, when I noticed


two little people coming across a field close by. They walked hand in
hand, and each carried a tin pail of apples. The boy was a stout little
fellow, and the girl, a few sizes smaller, very fat and pudgy and
much bundled up. I told them I’d like to take their pictures. They
didn’t know what to make of that; but I got to work, and they stood
by the fence looking at me very seriously. I was nearly ready when a
woman from the doorway of a house a little ways back called out,
“Go right along, Georgie! Don’t stop!” I told her I wanted to make
their photographs—it wouldn’t take but a minute. She said they
ought to be dressed up more for that. But I said they looked very
nice as they were, and hastened to get my picture. Then the two
went toddling on. The boy told me there was a big pile of apples
back there; also, as I was starting away, that his father had just
bought a horse.

I took the sandy long hill way toward Shutesbury, a place famous for
miles about for its huckleberry crops. It is jokingly said that this is its
chief source of wealth, and the story goes that “One year the
huckleberry crop failed up in Shutesbury, and the people had nothin’
to live on and were all comin’ on to the
town, and the selectmen were so scared
at the responsibility, they all run away.”

The scattered houses began to dot the


way as I proceeded, and after a time I
saw the landmarks of the town centre—
the two churches, perched on the
highest, barest hilltop eastward. The sun
was getting low, and chilly evening was
settling down. Children were coming
home from school; men, who had been A ROADSIDE FRIEND
away, were returning to do up their work
about the house and barn before supper,
and a boy was driving his cows down the street. I hurried on over
the hill and trotted briskly down into the valley beyond, but it was
not long before the road again turned upward. The woods were all
about. In the pine groves, which grew in patches along the way, the
ground was carpeted with needles, and the wheels and horse’s hoofs
became almost noiseless. There were openings now and then
through the trunks and leafage, and I could look far away to the
north-east, and see across a wide valley the tree-covered ridges
patched with evergreens, and the ruddy oak foliage rolling away into
ranges of distant blue, and, beyond all, Mount Monadnock’s heavy
pyramid. The sun was behind the hill I was climbing, and threw a
massive purple shadow over the valley. Beyond, the ridges were
flooded with clear autumn sunlight. Far off could be seen houses,
and a church now and then—bits of white, toy-like, in the distance.
The eastward shadows lengthened, the light in the woods grew
cooler and grayer, and just as I was fearing darkness would close
down on me in the woods, I turned a corner and the hill was at an
end. There were houses close ahead, and off to the left two church
steeples.
BETTER THAN HOEING ON A HOT DAY

This was New Salem. The place had no tavern, but I was directed to
one of the farm-houses which was in the habit of keeping
“transients.” There was only a boy at home. His folks were away, and
he had built a fire in the kitchen and was fussing around, keeping an
eye on the window in expectation of the coming of the home team.
It arrived soon after, and in came his mother and sister, who had
been to one of the valley towns trading and visiting. The father was
over at “the other farm,” but he came in a little later. Mrs. Cogswell
told of the day’s happenings, and how she had found a knife by the
roadside. It was “kind of stuck up,” and she said she would bet some
old tobacco-chewer owned it. However, Mr. Cogswell, having smelt
of it, guessed not.
JULY

His wife now brought in a blanket she had bought at the “Boston
Store,” and we all examined it, felt of it, and guessed what it was
worth. Then she told what she paid, and how cheap she could get
various other things, and what apples would bring.
THE PET OF THE FARM

As we sat chatting after supper, Mr. Cogswell took out his watch and
began to wind it. It was of the Waterbury variety, and winding took a
long time, and gave him a chance to discourse of watches in
general, and of this kind in particular. Frank had such a watch, he
said, and he took it to pieces and it was about all spring.

“You never saw such a thing,” said Mrs. Cogswell. “Why, it sprung
out as long as this table.”

“Ho, as long as this table!” said Mr. Cogswell; “it would reach ’way
across the room.” He said his own watch kept very good time as a
general thing, only it needed winding twice a day.
A RAINY DAY

I was out early the next morning. The east still held some soft rose
tints, streaks of fog lingered in the valley, and the frost still whitened
the grass. After breakfast I went northward, down through the
woods and pastures, into Miller’s valley. I followed a winding ravine
in which a mountain brook went roaring over its uneven bed toward
the lowland. I came into the open again at the little village of
Wendell Depot. It was a barren little clearing, I found, wooded hills
all about, a railroad running through, several bridges, and a dam
with its rush and roar of water; a broad pond lay above, and below,
the water foamed and struggled and slid away beneath the arches of
a mossy stone bridge, and hurried on to pursue its winding way to
the Connecticut. There was a wooden mill by the stream-side. It was
a big, square structure with dirty walls and staring rows of windows.
No trees were about, only the ruins of a burned paper-mill, whose
sentinel chimney still stood, a blackened monument of the fire.
There were a few of the plain houses built by the mill for its help, a
hotel, some sand-banks, a foreign population, a dark, hurrying river,
the roar of a dam, long lines of freight-cars moving through, and
grim hills reaching away toward the sky.

From here I went westward, and in the early afternoon crossed the
Connecticut River and began to follow up the valley of the Deerfield.
I had to go over a big mountain ridge, but after that had
comparatively level travelling. I went on till long after sunset, and
presently inquired of a man I met walking if there were houses on
ahead. He said Solomon Hobbs owned the nearest place, and lived
up a big hill a ways off the main road. A little after I met a team,
and concluded to make more definite inquiry. “Can you tell me
where Mr. Hobbs lives?” I asked.

“Who, John?” he questioned as he pulled in his horse.

“No, Solomon,” I replied.

“Oh, er, Solly! He lives right up the hill here. Turn off the next road
and go to the first house.”

A HAMLET AMONG THE HILLS

It was quite dark now, and when I came to the steep, rough rise of
the hill I got out and walked and led the horse. In time I saw a light
on ahead, and I drove into the steep yard. I had my doubts about
stopping there when I saw how small the house and barn were. A
man responded to my knock on the door and acknowledged to the
name of Solomon Hobbs. He was a tall, broad-shouldered, long-
bearded farmer, apparently about fifty years of age. He had on
heavy boots and was in his checked shirt-sleeves. He didn’t know
about keeping me overnight, but their supper was just ready, and I
might stay to that if I wanted to. He directed me to hitch my horse
to a post of the piazza and come in. On a low table was spread a
scanty meal. Codfish was the most prominent dish on the board.
After eating, I was ushered into the little parlor, for they had certain
pictures of the scenery thereabout they wished me to see. Mr. Hobbs
brought along his lantern and set it on the mantel-piece. It remained
there though Mrs. Hobbs came in and lit a gaudy hanging-lamp. She
was a straight little woman with short hair, rather curly and brushed
up, wore earrings, did not speak readily, and acted as if her head did
not work first-rate. The little boy, who was the third member of the
family, came in also. There was an iron, open fireplace with charred
sticks, ashes, and rubbish in it. The carpet on the floor seemed not
to be tacked down, and it gathered itself up in bunches and folds.
The sofa and marble-topped centre-table and many of the chairs
were filled with papers, books, boxes, and odds and ends.

SUMMER SUNLIGHT IN A “GORGE ROAD”


There was some doubt as to where the pictures were, and it
required considerable hunting in books and albums and cupboards
and boxes and top-shelves to produce them. I did not notice that
they put up any of the things they pulled down. Mr. Hobbs said of
his wife that she had been in poor health for a year past, and hadn’t
been able to keep things in order. When I had examined the pictures
I got ready to start on. Mr. Hobbs said there was a hotel a mile up
the road. I unhitched my horse, and the little boy, with a lantern, ran
before me and guided me through the gateway.

ONE OF THE LITTLE RIVERS

At the hotel, when I had made the horse comfortable in the barn I
betook myself to the bar-room, where a brisk open fire was burning.
A number of men were loafing there, most of them smoking. One
was a tall, stout-figured man who was always ready to back his
opinion with a bet of a certain number of dollars, and quoted
knowledge gained a year when he was selectman to prove
statements about the worth of farms.
The proprietor of the place was a young man, with small eyes rather
red with smoke or something else, a prominent beaklike nose, a
mustache, and receding chin. He had an old, straight, short coat on,
and he had thin legs, and looked very much like some sort of a large
bird. He had a very sure way of speaking, and emphasized this
sureness by the manner in which he would withdraw his cigar, half
close his little eyes, and puff forth a thin stream of tobacco smoke.

In the morning I was out just as the sun looked over some cloud
layers at the eastern horizon and brightened up the misty landscape.
I left the hotel, and soon was on my way up the Deerfield River into
the mountains. It was a fine day, clear at first, and with many gray
clouds sailing later. I jogged on up and down the little hills on the
road which kept along the winding course of the river. All the way
was hemmed in by great wooded ridges which kept falling behind,
their places to be filled by new ones at every turn. The stream made
its noisy way over its rough bed, and every now and then a freight
train would go panting up the grade toward the Hoosac Tunnel, or a
passenger train in swifter flight would sweep around the curve and
hurry away to the world beyond.

THE VILLAGE GROCERYMAN


A little off the road in one place was a log house, a sight so unusual
in old Massachusetts that such rare ones as one may come across
always have a special air of romance and interest about them. This
had a pleasant situation on a level, scooped out by nature from the
lofty ridge which over-shadowed it. It was made of straight, small
logs, laid up cob-fashion, chinked with pieces of boards and made
snugger with plaster on the inside. It had a steep roof of overlapping
boards, through which a length of rusty stove-pipe reached upwards
and smoked furiously. There was a spring before the door, which
sent quite a little stream of water through a V-shaped trough into an
old flour-barrel. There were some straggling apple-trees about, and
behind the house a little slab barn. Inside was a bare room, floored
with unplaned boards. There was a bed in one corner, a pine table in
another, and a rude ladder led to a hole in the upper flooring, where
was a second room. The only occupant then about was cooking
dinner on the rusty stove. Light found its way through two square
windows and through certain cracks and crevices in the wall.

I followed the rapid river, on, up among the wild tumble of


mountains which raised their gloomy rock-ribbed forms on every
side. The regions seemed made by Titans, and for the home of rude
giants, not of men. Presently a meadow opened before me, and
across it lay the little village of Hoosac. The great hills swept up
skyward from the level, and here and there in the cleared places you
could see bits of houses perched on the dizzy slope, and seeming as
if they might get loose and come sliding down into the valley almost
any day.
AN OUTLYING VILLAGE

At the tunnel was a high railroad bridge spanning the river, a long
freight train waiting, a round signal station, a few houses, and the
lines of iron rails running into the gloomy aperture in the side of the
hill. This was in a sort of ravine, and so somewhat secluded and
holding little suggestion of its enormous length of over four miles.
Some sheep were feeding on a grassy hillside just across the track,
and looking back upon them they made a very pretty contrast to the
wild scenery. The hills mounded up all about; the sun in the west
silvered the water of the rapid river; a train waiting below the iron
span of the bridge sent up its wavering white plume of smoke; and
here on the near grassy slope were the sheep quietly feeding.

The road wound on through the same romantic wildness; now a


mountain would shoot up a peak steeper and higher than those
surrounding; but none of them seemed to have names. As one of
the inhabitants expressed it, “They are too common round here to
make any fuss over.”
A VILLAGE VIEW IN A HALF-WOODED DELL

In the late afternoon, after a hard climb up the long hills, I passed
Monroe Bridge, where in the deep ravine was a large paper-mill. The
road beyond was muddy and badly cut up by teams, and progress
was slow. I expected to spend the night at Monroe Church, which I
understood was three miles farther up, but I got off the direct route
and on to one of the side roads. The sun had disappeared behind
the hills and a gray gloom was settling down. The road kept getting
worse. It was full of ruts and bog-holes. Like most of the roads of
the region, the way followed up a hollow, and had a brook by its
side choked up with great boulders. I came upon bits of snow, and
thought there were places where I could scrape up a very
respectable snowball.
THE OLD WELL-SWEEP

After a time I met a team and stopped to inquire the way to the
church, and the distance. The fellow hailed had a grocery wagon,
and no doubt had been delivering goods. He seemed greatly pleased
by my question; in fact, was not a little overcome, showed a white
row of teeth beneath his mustache, and he quite doubled up in his
amusement. He said he did not know where the church was; and he
guessed I wasn’t much acquainted up in these parts; said he wasn’t
either. He stopped to laugh between every sentence. He apparently
thought he was the only man from the outside world who ever
visited these regions, and now was tickled to death to find another
fellow had blundered into his district. There was no church about
there, he said; I must be pretty badly mixed up; this was South
Readsboro’, Vermont. “This is the end of the earth,” he said. He kept
on laughing as he contemplated me, and I got away up the road as
soon as I could, while he, still chuckling to himself, drove down.

The snow patches become larger and more numerous, and soon I
came into an open and saw a village up the hill. This was October,
and the sight ahead was strange and weird. The roofs of the
buildings were white with snow; there were scattered patches of it
all about, and a high pasture southward was completely covered. It
seemed as if I had left realities behind; as if in some way I was an
explorer in the regions of the far north; as if here was a little town
taken complete possession of by the frost; as if no life could remain,
and I would find the houses deserted or the inhabitants all frozen
and dead. There was a little saw-mill here and some big piles of
boards; everywhere marks of former life; but the premature frost
seemed to have settled down like a shroud on all about. I entered
the village and found a man working beside a house, and learned
from him that I had still three miles to travel before I came to the
church.

IN HAYING TIME

I took a steep southward road and led the horse, with frequent
rests, up the hills. Darkness had been fast gathering, the sunset
colors had faded, one bright star glowed in the west, and at its right
a gloomy cloud mass reached up from the horizon. The neighboring
fields got more and more snow-covered, until the black ribbon of the
muddy road was about the only thing which marred their whiteness.
There were rocky pastures about, intermitting with patches of
woodland. Here and there were stiff dark lines of spruce along the
hilltops, and these, with the white pastures, made the country seem
like a bit of Norway. Snow clung to the evergreen arms of the
spruces and whitened the upper fence-rails, and the muddy trail of
the road ceased in the crisp whiteness.

I was going through a piece of woods when I saw a house ahead


with a glow of light in a window. I went past the friendly light. The
dreary road still stretched on. No church was in sight, and I drew up
and ran back to the house. A man came to the back door with a
lamp. He said it was still two miles to the church, and I asked if I
might stay overnight. Soon I had my horse in the yard and was
comfortably settled by the kitchen fire. The kitchen was large, but
the long table, the stove, a bed, and the other furniture made it
rather cramped when the whole family were indoors. There were
grandpa, and grandma, and “Hen” and his wife, and “Bucky,” and
“Sherm,” and “Sis,” and Dan, and little Harry, not to mention a big
dog and several cats. After supper, grandma fell to knitting with
some yarn of her own spinning; grandpa smoked his pipe and told
bear stories; “Hen” mended a broken ramrod so that his gun might
be ready for a coon hunt he was planning; Mrs. “Hen” sewed;
“Sherm” and “Bucky” were in a corner trying to swap hats, neckties,
etc., and “Sis” was helping them; Dan ran some bullets which he
made out of old lead-pipe melted in the kitchen fire; and Harry
circulated all about, and put the cats through a hole cut for them in
the cellar door, and climbed on the chairs along the walls, and picked
away the plastering at sundry places where the lath was beginning
to show through.
THE STREAM AND THE ELMS IN THE MEADOW

Bedtime came at nine and I was given a little room partitioned off in
the unfinished second story. In the first gray of the next morning a
loud squawking commenced outside of so harsh and sudden a
nature as to be quite alarming to the unaccustomed ear. Later I
learned this was the flock of ducks and geese which had gathered
about the house to give a morning salute. The wind was whistling
about, and came in rather freely at the missing panes in my window.
As soon as I heard movements below I hastened downstairs. The
two fellows in the bed in the unfinished part adjoining my room were
still snoozing, and there were scattered heaps of clothing about the
floor.

There was no one in the kitchen, and though the stove lid was off,
no fire had yet been started. I heard old Mr. Yokes out in the back
room.

UNDER THE OLD SYCAMORE


“’Bout time ye was gettin’ up,” he called to me.

“Yes,” I said, “I heard you stirring, and thought it must be about


time to turn out.”

“Oh, it’s you, is it? I thought ’twas one of the boys. They didn’t bring
in no kindlings last night.”

AUGUST

He sat down by the stove and went to whittling some shavings. He


had not yet got on either shoes or stockings. One by one the rest of
the family straggled in, and the fire began to glow and the heat to
drive out the frostiness of the kitchen atmosphere. Outdoors the
weather was threatening, and there were little drives of sleet borne
down on the wings of the wind. After breakfast I concluded to leave
this land of winter and followed down one of the steep roads into
the autumn region of the Deerfield valley. By brisk travelling I
succeeded by close of day in getting to the quiet meadows along the
Connecticut. It had been a five days’ journey. I saw only a little
patch of New England, and the description is necessarily
fragmentary; but at least there is presented characteristic phases of
its nature and life as the traveller on a leisurely journey may see
them.

ONE OF THE OLD VILLAGE STREETS


PART IV
CAMPING AMONG THE NEW ENGLAND HILLS

I T was a warm night of midsummer. In a secluded hollow of the


Green Mountain ranges of lower Vermont was pitched a small
white tent. A half-moon was shining softly through the light cloud-
hazes overhead, and had you been there, you could have made out
the near surroundings without much difficulty. Tall woods were all
about, but here was a little open where grasses and ferns and low
bushes grew in abundance, and on a chance level of the steep,
uneven hillside the campers had pitched their tent. In the deep,
tree-filled ravine close below was a stream, whence came the sound
of its fretting among the rocks, and from a little farther up the
solemn pounding of a waterfall. From the other direction came a
different sound. It was the gentle clinking of a hammer on an anvil.
On the farther side of the narrow strip of woods, which shut it from
sight, was a farmhouse, and it was thence came the sound of
hammering.
THE HOUSE WITH THE BARN ACROSS THE ROAD

A WARM SUMMER DAY

The tent has two occupants. They are both young fellows, who had
on the day previous started from their Boston homes for a vacation
trip to the woods. In the city they were clerks,—one in a store, the
other in a bank. The chance that brought them to this particular spot
for their vacation was this: a school friend of theirs, who was
blessed (or perhaps otherwise) with more wealth than they, and who
was next year to be a senior in Harvard, had informed them a few
weeks previous that his folks were going to the Groveland House for
the summer. This, he said, was in the centre of one of the prettiest
and most delightful regions of all New England, and he urged his
friends, Clayton and Holmes, to by all means go along too. He
expatiated on the beauties of the place with such an eloquence
(whether natural or acquired at Harvard, I know not) that these two
gave up the idea of a trip they had been planning down the coast
and turned their thoughts inland.

But when they came to study the hotel circular that Alliston gave
them, and noted the cost of board per week, this ardor received a
dampener.

“Phew!” said Holmes, “we can’t stand that. I don’t own our bank
yet.”

“No, we can’t, that’s a fact,” said Clayton. “I’d want more of a raise
in my pay than I expect to get for years before I could afford that
sum. The dickens! I thought these country places were cheap always
—and here’s a little place we’ve never heard of that charges more
than half our big hotels here in Boston.”
AT WORK IN HER OWN STRAWBERRY PATCH

“Well, we’ve got to give up that idea, then,” Holmes said. “I suppose,
though, we might find a place at some farmhouse that wouldn’t
charge too high.”

“The trouble is,” Clayton responded, “that I don’t like to go poking


off into a region where we don’t know a soul, and take our chances
of finding a comfortable stopping-place at the right price. Then, you
see, it’s going to cost like anything getting there—just the fare on
the railroad. I don’t know as we ought to have considered the thing
at all.”
SEPTEMBER

“I hate to give it up,” said Holmes. “We’ve seen a good deal of the
shore, but have had hardly a sight of the country. It would be a
great thing, for a change, to take that trip to Vermont. Now, why
couldn’t we try camping out? That’s what the youngsters do in all
the small boys’ books I’ve ever read. We’re rather older than the
boys who were in the habit of doing that sort of thing in the books.
But then, you know, that may be a good thing. It may have given us
a chance to accumulate wisdom sufficient to avoid those hairbreadth
adventures the youngsters were always having. They are good
enough to read about, but deliver me from the experience.”

“Harry,” said Clayton, “I believe that’s a good idea.”

The conversation and thinkings necessary to settle the details were


many and lengthy, and I forbear repeating them. The long and short
of it is that on Monday, August 14, in the earliest gray of the
morning, they were on the train
that was to carry them to the
Vermont paradise they had in
mind.

John Clayton, as luck would


have it, worked in a dry-goods
EVENING
house, and therefore in planning
a tent he was enabled to get the
cloth for its makeup at a trifle above cost. He and Harry made
numerous visits to the public library on spare evenings and
consulted a variety of volumes devoted more or less directly to the
science of camping out. The amount of information they got on the
subject was rather bewildering, but they simplified it down to a few
things absolutely necessary to think of beforehand, and concluded to
trust to commonsense for solving further problems.

“Sufficient unto the day is the evil thereof,” said Harry, who attended
Sunday-school regularly.

The cloth used for the tent was cotton drilling. John’s mother sewed
the strips together under his direction, and their landlady allowed
him to set it up in the little paved square of yard back of the block,
and there he and Harry gave it a coat of paint to make it waterproof.
The whole thing did not cost three dollars, and, as the boys said,
“It’ll last us a good many seasons.” Aside from their tent they
purchased a small hatchet, a ball of stout twine, a few nails, a
lantern, and some tin pails, cups, and plates, and several knives,
forks, and spoons.

It had been a question just where their camping-place should be.


“We can’t very well pitch our tent in the hotel yard,” said Harry.
“That high-priced proprietor wouldn’t allow it, I’m sure; and,
besides, we shouldn’t want to.”
Another perusal of the
summering-place circular
disclosed the fact that it
gave a list of the
attractions of the region
about, with certain
comments thereon. Among
the rest was noted a
waterfall seventy feet high.
It was amid surroundings,
so the circular said,
exceedingly beautiful and
romantic (whatever that
A LOAD OF WOOD ON THE WAY UP TO THE VILLAGE may be). The boys thought
that style of place would
suit them to a T, and
Harry, who carried the circular about in his pocket, got it out at the
bank the next day after this decision was arrived at and underscored
this waterfall with red ink.

In the late afternoon of August 14th the two were set down, “bag
and baggage,” at the forlorn little station which was the railroad
terminus of their journey. To the left was a high sand bluff, half cut
away, crowned with a group of tall pines. A little up the tracks was a
deep, stony ravine where a little river sent up a low murmur from
the depths. This was spanned by a high railroad trestle, and when
the train rumbled away across it and disappeared around the curve
of a wooded slope, the boys watched the curls of smoke fade into
thin air and felt a bit homesick. Beyond was a small freight-house,
but no other buildings were in sight. It was a little clearing in the
midst of the woods. The only path leading away was the road, which
made a turn about the near sand bluff, and then was lost to sight. At
the rear of the depot was a smart stage-coach, into which a group of
people were being helped by a slick footman. This coach was an
attachment of the Groveland House. “Were the young gentlemen
bound for the hotel?”

You might also like