100% found this document useful (2 votes)
28 views

Full Download Programming the Raspberry Pi: Getting Started with Python (Third Edition) Simon Monk PDF DOCX

The document promotes the ebook 'Programming the Raspberry Pi: Getting Started with Python (Third Edition)' by Simon Monk, available for download at ebookmeta.com. It also lists additional recommended ebooks related to programming and Raspberry Pi projects. The author, Dr. Simon Monk, has extensive experience in cybernetics and software engineering, and the book covers various programming concepts and projects using Python and Raspberry Pi.

Uploaded by

eisennaing2i
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
28 views

Full Download Programming the Raspberry Pi: Getting Started with Python (Third Edition) Simon Monk PDF DOCX

The document promotes the ebook 'Programming the Raspberry Pi: Getting Started with Python (Third Edition)' by Simon Monk, available for download at ebookmeta.com. It also lists additional recommended ebooks related to programming and Raspberry Pi projects. The author, Dr. Simon Monk, has extensive experience in cybernetics and software engineering, and the book covers various programming concepts and projects using Python and Raspberry Pi.

Uploaded by

eisennaing2i
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Get the full ebook with Bonus Features for a Better Reading Experience on ebookmeta.

com

Programming the Raspberry Pi: Getting Started with


Python (Third Edition) Simon Monk

https://ebookmeta.com/product/programming-the-raspberry-pi-
getting-started-with-python-third-edition-simon-monk/

OR CLICK HERE

DOWLOAD NOW

Download more ebook instantly today at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Programming Arduino: Getting Started with Sketches, Third


Edition Simon Monk

https://ebookmeta.com/product/programming-arduino-getting-started-
with-sketches-third-edition-simon-monk/

ebookmeta.com

Raspberry Pi Cookbook, 4th Edition (Second Early Release)


Simon Monk

https://ebookmeta.com/product/raspberry-pi-cookbook-4th-edition-
second-early-release-simon-monk/

ebookmeta.com

Learn Raspberry Pi Programming with Python 1st Edition


Wolfram Donat

https://ebookmeta.com/product/learn-raspberry-pi-programming-with-
python-1st-edition-wolfram-donat/

ebookmeta.com

Graphs Orders Infinites and Philosophy 1st Edition Daniel


Parrochia

https://ebookmeta.com/product/graphs-orders-infinites-and-
philosophy-1st-edition-daniel-parrochia/

ebookmeta.com
EcoGothic Gardens in the Long Nineteenth Century Phantoms
Fantasy and Uncanny Flowers 1st Edition Sue Edney

https://ebookmeta.com/product/ecogothic-gardens-in-the-long-
nineteenth-century-phantoms-fantasy-and-uncanny-flowers-1st-edition-
sue-edney/
ebookmeta.com

Seaside Knitters Society 14 0 A Murderous Tangle Sally


Goldenbaum

https://ebookmeta.com/product/seaside-knitters-
society-14-0-a-murderous-tangle-sally-goldenbaum/

ebookmeta.com

Cambridge IELTS 16 - Academic 1st Edition Cambridge Esol

https://ebookmeta.com/product/cambridge-ielts-16-academic-1st-edition-
cambridge-esol/

ebookmeta.com

Beginner's Guide to Streamlit with Python: Build Web-Based


Data and Machine Learning Applications 1st Edition Sujay
Raghavendra
https://ebookmeta.com/product/beginners-guide-to-streamlit-with-
python-build-web-based-data-and-machine-learning-applications-1st-
edition-sujay-raghavendra/
ebookmeta.com

Pack Origin The Blissful Omegaverse 1 1st Edition Kate


King Jessa Wilder

https://ebookmeta.com/product/pack-origin-the-blissful-
omegaverse-1-1st-edition-kate-king-jessa-wilder/

ebookmeta.com
I Die by This Country 2nd Edition Zouari

https://ebookmeta.com/product/i-die-by-this-country-2nd-edition-
zouari/

ebookmeta.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
Exploring the Variety of Random
Documents with Different Content
species of force, six pieces form a battery, then called a brigade:
each gun is dragged by four or six horses; by four, if the brigade be
intended to act with infantry—by six, if it belong to what is called the
horse-artillery. In the former case, eight gunners march on foot
beside each field-piece, two riding à la postilion; in the latter, the
gunners are all mounted and accoutred like yeomanry cavalry. Then
the tumbrils and ammunition-waggons, with their train of horses and
attendants, follow in rear of the guns; and the whole procession
covers, perhaps, as much ground as is covered by two moderately
strong battalions in marching order.
The greater part of the infantry attached to the left column had
passed when brigade after brigade of guns wound through our
village. These, halting just after they had cleared the street, diverged
into some open fields on the right and left of the road, where the
whole park, amounting to perhaps thirty pieces, was established. In
another green field at the opposite side of Bidart four heavy
eighteen-pounders took their station, to be in readiness, in case of
need, to be transported to Fort Charlotte. Last of all came the
cavalry, consisting of the 12th and 16th Light Dragoons, and of two
regiments of heavy Germans; nor could we avoid remarking that,
though the 12th and 16th Dragoons are both of them distinguished
corps, the horses of the foreigners were, nevertheless, in far better
order than those of our countrymen. The fact I believe to be, that an
Englishman, greatly as he piques himself on his skill as a groom,
never acquires that attachment to his horse which a German trooper
experiences. The latter dreams not under any circumstances of
attending to his own comfort till after he has provided for the comfort
of his steed. He will frequently sleep beside it, through choice; and
the noble animal seldom fails to return the affection of his master,
whose voice he knows, and whom he will generally follow like a dog.
There was another striking difference in the two brigades of cavalry
which I remarked. The English rode on, many of them silent, some
chatting of a thousand things, others humming or whistling those
tuneless airs in which the lower orders of our countrymen delight.
The Germans, on the contrary, sang, and sang beautifully, a wild
chorus—a hymn, as I afterwards learned—different persons taking
different parts, and producing altogether the most exquisite harmony.
So great an impression did this music make upon me that I caught
the air, and would write it down for the benefit of my reader were I
sufficiently master of the art of notation; but as this happens not to
be the case, he must wait till we become personally acquainted,
when I promise to play it for him in my very best style upon the flute.
Nor was it only on the left that warlike movements occurred. The
whole army took the field; and that a serious campaign was already
commenced the sound of firing at the extreme right of the line gave
notice. I had wandered abroad with my gun on the morning of the
18th—not, indeed, venturing to proceed far from home, but trying the
neighbouring copses for a hare or a woodcock—when my farther
progress was arrested by the report of several cannon in the
direction of Lord Hill's division. These were succeeded by a short,
sharp discharge of musketry; and my sport was immediately
abandoned: but I found on my return that no alarm was excited, and
that every description of force which I had left in a state of inaction
continued still inactive.
The same degree of suspense prevailed amongst us during the 19th
and 20th. On the latter of these days my mind at least was kept busy
by a journey to the harbour, for the purpose of bringing up a fresh
supply of corn for the horses; though it was a species of employment
with which I would have readily dispensed, inasmuch as the day
chanced to be particularly cold, with snow. But our anxiety was
destined not to be of long continuance, an order reaching us that
night at a late hour to be accoutred and in line of march by three
o'clock on the following morning. Now then at length we applied
ourselves to the task of packing the baggage. The tents were once
more summoned into use; their condition closely examined; such
rents as appeared in the canvas were hastily repaired, and every
deficiency in pegs and strings made good. Then the ordinary supply
of provend, as Major Dalgetty would call it, being put up, we threw
ourselves down in our clothes, and fell asleep.
It was still dark as pitch when the well-known sound of troops
hurrying to their stations roused me from my slumber. As I had little
to do in the way of accoutring, except to buckle on my sabre and to
stick my pistols in a black leathern haversack, which on such
occasions usually hung at my back, abundance of time was given for
the consumption of as much breakfast as at that early hour I felt
disposed to eat; after which I took post beside my men. The reader
will have doubtless noted that, like the good soldier already named, I
never set out upon any military expedition without having in the first
place laid in a foundation of stamina to work upon. And here I would
recommend to all young warriors, who may be gathering laurels
when nothing of me shall remain except these Memoirs, invariably to
follow my example. They may depend upon it that an empty
stomach, so far from being a provocative, is a serious antidote to
valour; and that a man who has eaten nothing previous to either an
advance or a retreat runs no little risk of finding his strength fail at
the very moment when its continuance is of vital importance to him.
No, no; your hot-brained youth, who is too impatient to eat, is like
your over-anxious hunter, which refuses its corn because the hounds
pass the stable. Neither the one nor the other will go through a hard
day's work.
The troops being formed in marching order, the word was given, and
we advanced in the direction, now so familiar to us, of the mayor's
house. As we passed the park of artillery, we heard rather than saw
the drivers limbering up, and preparations busily making for service.
The tramp of many feet, too, could be discerned, as well as the
clattering of horses' hoofs, the jingling of steel scabbards, and the
rattle of canteens and cartouch-boxes; but it was not till these
various sounds had become faint and distant that daylight began to
break upon us. We had, however, been conscious of having struck
into a sort of by-lane, and of having proceeded for some time in a
direction towards the right; and hence, when objects became visible,
we were not surprised to find that we had passed even the village of
Arcanques, and that all the country hitherto traversed by us was left
behind. As may be guessed, this circumstance alone excited
pleasurable emotions; for we were weary of the eternal mayor's
house and Fort Charlotte, and anxious to reach some other field on
which to prove our courage.
The point towards which our steps were turned was a lofty
eminence, distant about a quarter of a mile from the banks of the
Nive, and commanding an extensive view of a country extremely
beautiful. The height had been occupied during the preceding day by
a part of the fifth division, which now resigned the charge to us, and
descending into the plain, crossed the river and pushed off in a
direction to the right. For ourselves, we were commanded to halt
here; and as neither the tents nor baggage had arrived—as indeed
we soon learned that they were not to follow—we sedulously set
about lighting fires, and prepared to bivouac. These were early days
as yet, however, for bivouacking; and hence arrangements were
made for getting us under cover during the night; in accordance with
which we descended soon after sunset to a large chateau, close
beside the advanced sentries, where ample accommodation was
found for all of us. There the night was passed, not altogether free
from apprehension, seeing that no pickets—only a chain of sentinels
—were between us and the enemy; but as everything remained
quiet, without any attempt being made to molest us, no evil
consequences resulted from the adoption of a plan agreeable
enough, it is true, but savouring perhaps of rashness rather than
excess of wisdom.
As soon as the morrow's early parade was dismissed, and I
perceived that no indication was given of farther movements, I took
my gun and set off to the woods, where I hoped to find game enough
to furnish out a comfortable repast in the evening. Nor was I
disappointed. Hares and woodcocks abounded here; there were,
moreover, numerous flocks of golden plovers; and of these I
contrived to bring home a sufficient number to satisfy my own wants
and the wants of others. But it was not alone because I chanced to
be particularly successful in shooting that the day's excursion gave
me pleasure; the country round was more romantic and striking than
any which I had yet seen, and came nearer to a realisation of my
previously-conceived notions respecting scenery in the south of
France. All was hill and dale, sweeping groves and green meadows,
with here and there a vineyard, already beginning to give signs of
vegetation, and to put forth its delicate fibres, like our hop-plant in
the month of May. The proximity of the Nive, too, added not a little to
the beauty of the prospect, as it flowed gently and quietly on, winding
for a while between sloping grass fields, and then eluding the eye
amid the thick groves which overhung its banks. It would have been
altogether as sweet and pastoral a landscape as the imagination can
very well picture, but for the remote view of the intrenched camp
which from various points might be obtained, and the nearer glimpse
of numerous watch-fires, round which groups of armed men were
swarming. But to me these were of course precisely the most
interesting objects in the panorama.
The game which the sporting members of the corps contrived this
day to pick up was so abundant that we resolved to admit the whole
of our brother officers to a participation in it, and to spend an evening
together after the fashion of a reunion at home. For this purpose all
the culinary utensils within reach were put in requisition, and all the
individuals skilled in the gastronomic art were invited to give proof of
their abilities. Beef—lean beef—that everlasting and insipid food of
soldiers—was disguised in every imaginable form; hares were
melted down into soup, woodcocks stewed, golden plovers roasted,
and sundry rabbits curried. In a word, we sat down, in number about
five-and-twenty, at six o'clock, to a dinner which would have done no
discredit in point of cookery to the favourite disciple of Dr Kitchener,
and which Sir William Curtis himself would not have deemed
unworthy of his notice. Good cheer, moreover, is generally the parent
of good-humour, and good-humour is the source of benevolence; nor
would it be easy to point out in this selfish world of ours five-and-
twenty persons whose hearts overflow more richly with the milk of
human kindness than did ours as we took our seats by the well-filled
board. Fervently did we wish that every corps in the British army—
ay, and in the French army too—could that day fare as well; while we
proceeded to prove, in the most satisfactory of all manners, that
delicate viands were not thrown away, at least upon us.
These praiseworthy expressions had hardly ceased, and we had just
begun to pay our addresses to the well-boiled soup, when the tread
of horses' hoofs attracted our notice. It would have been a positive
sin had the enemy come on at such a moment as this; and I verily
believe we in our wrath would have given him no quarter.
Nevertheless, sins are daily committed; nor were we by any means
at ease touching this important matter, till the cause of the alarm
appeared. It was a wounded officer, who had been shot in a skirmish
this morning, and was now slowly travelling to the rear, being with
difficulty held on his horse by a couple of attendants. Our dinner was
instantly abandoned, and we all ran to offer such assistance as our
means enabled us to offer. But the poor fellow was too seriously hurt
to accept of our invitations to eat. The surgeon accordingly took him
in charge, and having amputated the arm which one ball had broken,
and striven in vain to extract another from his side, he left him to the
care of his servant. The man was dead before morning.
It is impossible to describe the chilling effect of this adventure upon
all of us. Steeled as men necessarily become in a continued state of
warfare against the milder and more gentle feelings of our nature,
they must be hardened indeed if they can behold a dying fellow-
creature arrive among them in an hour of jollity and mirth without
viewing the contrast in so strong a light as to damp, if it be unable
utterly to destroy, their hilarity. For our own parts, we returned indeed
to table, and chatted, or endeavoured to chat, as if no such guest
had come among us. But it would not do. Our party, which we had
designed to keep together till dawn, broke up soon after ten o'clock;
and we lay down to sleep with minds more full of our suffering
brother in arms than of our own joviality.
The wounded officer belonged to a regiment of the fifth division. He
had acted with a small party as one of the flank patrol during an
oblique movement of his brigade along the front of the enemy's line,
and falling in with a body of their skirmishers, had been wounded in
a wood, where the rapid advance of the column left him. His servant
and another man, having procured a horse from one of his friends,
returned to his assistance. But before they could discover him the
division was too far on its way to be overtaken; consequently they
took with him a direction to the rear, which brought them to our
house. He had received his wounds at an early hour in the day, and
had been preserved from bleeding to death only by the cold; but the
long period which elapsed ere the hurts could be dressed rendered
them doubly severe. Our surgeon indeed assured us, that no care,
however speedily bestowed, could have saved him; and therefore it
was perhaps as well that the absence of medical assistance
shortened his misery by protecting him from the torture necessarily
attendant upon useless dressings.
We had just begun to drop into a forgetfulness of all causes both of
joy and sorrow when a dragoon arrived with orders for the
commanding officer, by which it appeared that we were to be under
arms at three o'clock next morning, and to follow where the bearer—
a soldier of the corps of guides—should lead. Something, too, was
whispered about a general attack upon the enemy's lines—of
passing the Adour—and investing Bayonne; but these were mere
surmises, naturally following upon such vague directions. For myself,
I permitted them not to occupy much of my attention, or to keep their
places long in my mind; but philosophically concluding that I had no
choice submitted to me, and that I must go wherever I should be
sent, and act exactly as I should be desired, I once more threw
myself on the floor and closed my eyes. Sleep was not long a
stranger to them.
CHAPTER XX.
Of the appearance of the country through which we marched on the
morning of the 23d February I can say but little, the greater part of
the journey having been performed in the dark. When day dawned,
however, we perceived that we had been defiling by a new road
towards the left; and at eight o'clock we found ourselves in a green
field about a musket-shot from the highroad, and within three miles
of the works in front of Bayonne. At the other end of the field was a
picket of the enemy, which instantly turned out and lined the ditches;
whilst we contented ourselves with forming into column, and then
piling arms, we stood still till farther instructions should arrive. In the
meanwhile I was not unemployed. By the help of my telescope I took
as accurate a survey of the stupendous fortifications before me as
circumstances would permit; and the following is as nearly as I can
recollect the aspect which they presented:—
The position which Marshal Soult had taken up, and which has long
been justly regarded as one of the most formidable in the south of
France, ran parallel, or nearly so, for about four miles with the Adour.
Its right rested upon the strong and extensive fortifications of
Bayonne; its left upon the small river Joyeuse and the formidable
post of Hilletre. When I describe this as being the position of Marshal
Soult, I mean to say that such was the line which his army occupied
previous to the renewal of hostilities on our part. Towards his right no
change had indeed taken place; but on his left he had been driven
back, first from Hilletre upon St Martin, and then through St Palais,
as far as the village of Arriverente. From this again he was dislodged
on the 17th by the 92d Regiment, under the command of Colonel
Cameron; till, finally, falling back from post to post, the strength of his
force became divided. The intrenched camp near St Jean Pied de
Port was abandoned; and Soult, after defending as long as he could
his strongholds, principally at Hastingues and Oyergave, retired with
his extreme left within the tête-de-pont at Payerchourade. When I
glanced my eye, therefore, along the intrenchments this morning, I
was able to take in only so much of the formidable line as extended
from the city to the hamlet of Villeneuve, on the Gave d'Oleron; and
of the last mentioned of these places I obtained a view so indistinct,
that had I not previously known that it formed one key of the position,
I should not have been aware of its vast importance.
It is not my design to attempt an accurate detail of the eventful
operations of this and the following day. On the left of the centre (the
point where I chanced to be stationed), comparatively little fighting
took place. We made, indeed, from time to time, demonstrations of
attack, drove in a few pickets, and sent out occasionally a body of
skirmishers, just by way of keeping the attention of the enemy
awake; but it was on the right of our line that the most important
proceedings occurred. Lord Wellington's plan was to cut off the army
of Soult entirely from Bayonne, and to draw him if possible from the
works which he had erected; and in the execution of his plan our
leader was as successful as he generally proved to be in all his
schemes. Whilst, therefore, we were thus amusing ourselves on the
heights above Bayonne, Sir Rowland Hill, with the light, the second,
and a Portuguese division, passed the Gave d'Oleron at Villeneuve;
Sir Henry Clinton crossed at the head of the sixth division between
Montfort and Laas; and Sir Thomas Picton, with his own favourite
third division, threatened the bridge of Sauveterre, and obliged the
enemy to blow it up. The effect of these several attacks was to break
the line which Soult had formed in no less than three points, and to
oblige him to draw off the main body of his army from his intrenched
camp, and to establish himself on the heights above Orthes.
Meanwhile the first division on the extreme left was not inactive. It
formed a part, and a prominent part, in this stupendous plan of
operations to take possession of both banks of the Adour, as well
below as above the city, and to place Bayonne in a state of blockade
at the very moment when the army which covered it should be driven
from its position. To render that scheme effectual, it was necessary
to push a detachment of infantry across the Adour on rafts, for the
purpose of protecting the formation of a bridge which Lord
Wellington had resolved to erect. This was effected at a point three
miles distant from the sea, where the river is full eight hundred yards
wide; and so little was the movement anticipated, that six hundred
men, under the command of Major-General Stopford, were actually
ferried over before the enemy exhibited any symptom of alarm, or
seemed to be aware that an attempt of the kind was in progress.
The bridge by which the Adour was to be spanned it was proposed
to construct with chasse-marées—small vessels, or decked boats—
which, being arranged with bows up the stream, at an interval of
perhaps twelve yards apart, were to be connected with strong
cables, on which deals were to be laid transversely. These vessels
had been collected for some time, and now lay in the harbour of
Secoa, waiting only for a fair wind to aid them in effecting their
entrance into the Adour. Nor is that an easy matter, even for a craft
of forty or fifty tons burthen. At the mouth of the Adour is a bar or
bank of sand quite impassable at low water, and which, during
common full tides, is so little covered that nothing larger than a large
fishing-boat can float. When the spring-tides come, I believe that
ships of a considerable size may enter; but nothing approximating to
a ship can hope to cross at any other season.
When the army broke up from winter quarters it was not the season
of spring-tide; neither could military operations be delayed till it
came. It was accordingly determined by Rear-Admiral Penrose, who
commanded the squadron cruising off the coast, to force his way up
the stream at all hazards as soon as a breeze should serve; and the
command of the boats dedicated to this perilous service was
intrusted to a gallant officer from the sister isle, by name O'Reily. No
man could be better cut out for such an enterprise. Brave,
impetuous, perhaps somewhat rash, Captain O'Reily was not a little
galled when he found his progress delayed during the whole of the
23d by a dead calm. He did not, however, let the interval go to seed.
Perceiving that nothing was to be done on his own element, he came
ashore, and was very serviceable in helping to construct the rafts,
and putting the soldiers in proper order for crossing.
It was about ten in the morning when the posts which the enemy
occupied in and near Anglete, as well as among the sand-hills on the
left bank of the Adour, being carried, General Stopford's little corps
began to pass the river. To facilitate this operation, or rather to hinder
the enemy from observing it, our brigade, which had hitherto
remained idle upon the brow of the same rising ground where, after
the action of the 9th of the preceding November, we had halted, was
directed to execute various manœuvres. We first deployed into line,
then extended our files into skirmishing order, next threw out half-a-
dozen companies, who rushed forward at double-quick time and with
loud shouts, as if an assault were seriously intended. Nor were our
movements unnoticed. In less than five minutes several batteries
and breastworks in our immediate front, which had previously
remained almost empty of defenders, were crowded with soldiers;
whilst three pieces of light artillery came galloping from the right and
took post in a field across which our route, had we pursued it, must
have lain.
To meet the detached companies, a body of tirailleurs advanced, and
a very entertaining skirmish began. For myself, I was during the
entire day in a place of perfect safety, out of reach even of the light
cannon which were turned against us; and hence I had every
opportunity of observing with an easy mind the progress of those
about me. Immediately on our left was a division of Spanish infantry,
which, occupying the village of Anglete, kept up the communication
between us and the Guards. On our right, again, was a Portuguese
corps; and it is curious enough that while the French were satisfied
with watching us, and with giving proof that they were determined to
oppose any attack on our part, they made several spirited assaults
upon our allies. By the Portuguese they were met with much
gallantry, and in excellent order. Towards the close of the war,
indeed, the Portuguese infantry had become a very efficient force;
but the Spaniards proved less troublesome to them. Indeed it was
very evident that, but for the presence of our brigade on one flank,
and a brigade of Guards upon the other, the French would have
disposed of that portion of the line pretty much as they pleased. As
matters stood, they were content from time to time to drive the poor
Spaniards out of the village; after which, when they saw the red-
jackets moving, they fell back again leisurely to their own position.
It was a positive relief to avert one's eyes from the operations of the
Spanish corps, and to turn them towards the Portuguese. The latter
consisted of one battalion of caçadores and two of heavy infantry, of
which the caçadores alone could in strict propriety of speech be said
to be engaged. Covering the front of the others, and communicating
with our skirmishers, they spread themselves in extended order over
the fields, and kept up a steady, cool, and well-directed fire upon the
cloud of tirailleurs which vainly endeavoured to drive them back upon
their reserve. In looking at such a scene as this, you generally fix
your eye upon one or two individuals, whose progress you watch so
long that you become at last as much interested in their safety as if
they were personal acquaintances of your own. One Portuguese
soldier in particular attracted my notice that day. He seemed, if I
might judge from his proceedings, to be animated with a more than
ordinary degree of hatred towards the French—that is to say, he
looked neither to his right nor to his left; paid no attention either to
the momentary retrogression or advance of his comrades; but
steadily kept his ground, or varied it only for the purpose of obtaining
a better aim. He had posted himself considerably in advance of his
own line behind a large furze bush, or rather in the middle of a furze
bower, from which I saw him deliberately pick off three Frenchmen
one after another. At length he was noticed by the enemy, and six or
seven of them turned towards his place of ambuscade. Nothing
daunted, the Portuguese remained perfectly steady: he crouched
down indeed to load, but the moment his rifle was charged he leant
over the bush and fired. One of his assailants fell; whilst the rest,
pointing their pieces to the spot from whence the smoke issued,
gave him a volley: but it was harmless; he had darted to the other
side of the bush, and every shot missed. He knelt down and loaded
again; the enemy were now within twenty yards of him; he fired, and
an officer who accompanied them walked off the field grasping his
left arm in his right hand. The rest of his adversaries seemed to have
got enough of it, and retreated; and there he stayed till the close of
the affair, after which he returned to the ranks of his regiment
apparently unhurt. That man killed and wounded not fewer than eight
French soldiers during the day.
It was drawing towards evening when our attention was powerfully,
and somewhat painfully, attracted to the little corps which had
crossed the Adour upon rafts, and now occupied a position among
the sand-hills on the opposite bank. Hitherto they had been either
unnoticed or disregarded by the enemy. The only serious fighting,
indeed, which had as yet taken place on the extreme left of our line,
was a sort of struggle between a French corvette, assisted by two
gunboats, and a British battery of eighteen-pounders, well supplied
with red-hot shot. The result was, as may be anticipated, the
complete destruction of the gunboats and the compulsory retreat of
the ship; but to the passing of our infantry no regard seemed to have
been paid—at least no endeavour was made to cut them off, or to
hinder them from strengthening their post. At length, however, the
French general appeared to have discovered his error. A heavy
column of infantry, with several pieces of cannon, was accordingly
formed, and marched in firm array to the attack of only six hundred
soldiers of the British Guards, supported by a small detachment of
rockets.
The ground which General Stopford held was, happily for him,
extremely favourable. It was full of inequalities, each of which
formed, as it were, a natural parapet, behind which troops could
shelter themselves. Perceiving the approach of his assailants, the
general formed his people to the best advantage in rear of the sand-
hills; and causing them to lie down so as to be completely
concealed, he waited till the head of the attacking column had
arrived within twenty yards of him. Then the word was given to start
up; and the rocket-men throwing in their diabolical engines with
extraordinary precision, simultaneously with a well-directed volley
from the infantry, the confusion created in the ranks of the enemy
beggars all description. I saw and conversed with a French sergeant
who was taken in this affair. He assured me that he had been
personally engaged in twenty battles, and that he had never known
the sensation of fear till that day. But a rocket, it appeared, had
passed harmlessly through his knapsack; and such was the violence
with which it flew, that he fell upon his face, not stunned, but
stupefied—so frightful in his ears was the hissing sound which the
missile sends forth in its progress. Nor is it the least appalling
incident in a rocket's eccentricities that you see it coming yet know
not how to avoid it. It skips and starts about from place to place in so
strange a manner, that the chances are, when you are running to the
right or left to get out of the way, that you run directly against it; and
hence the absolute rout which a fire of ten or twelve rockets can
create, provided they take effect. But it is a very uncertain weapon. It
may indeed spread havoc among the enemy, but it may also turn
back upon the people who use it, causing, like the elephant of other
days, the defeat of those whom it was designed to protect. On the
present occasion, however, it proved materially serviceable, as every
man can testify who witnessed the result of the fire.
Having thus briefly detailed the issue of the engagement, it may
appear almost superfluous to state how we were affected by the
anticipation of its occurrence. We knew well that a mere handful of
our fellow-soldiers were unavoidably thrown into such a position that,
let their case be what it might, no succour could be afforded them.
We saw, by the dense and lengthened mass which was moving
down, and by the guns and horses which accompanied it, that this
little corps was about to sustain an assault from a force capable of
overwhelming it by their bodily weight; and feeling that we could
render no other aid than that which empty wishes supply, we cast no
imputation upon the bravery of our comrades when we trembled for
their safety. All eyes were directed to the sand-hills; scarce a word
was spoken by the spectators; and the greater number held their
breath till the shock was given.
The battery of eighteen-pounders, of which I have already spoken,
failed not to salute the enemy's column as it passed. The range was
a long one; but our gunners were skilful, and it was consolatory to
see, from the occasional checks and disorders in various parts of the
advancing corps, that its salute was more than honorary. But what
was become of our own people? They had all disappeared; and it
seemed as if the French troops might march without molestation to
the margin of the sea. The problem was speedily solved; and the first
discharge, given as I have described above, decided the business. It
was followed, as such a fire generally is in the British service, by a
charge with the bayonet; and we who, but a moment before, had
been breathless with apprehension, now shouted in triumph, as we
beheld the mass, of late so formidable, scattered and put to flight by
a single battalion.
Darkness was by this time setting in, and with the approach of night
came the gradual cessation of military movements on both sides.
One more attack upon the Spanish and Portuguese posts, supported
as heretofore by demonstrations of which we were the objects,
wound up for that day the warlike operations of the enemy. It
succeeded, as others had done, to a certain extent; but no results
arose out of it. The enemy did not try to keep the ground which they
had taken; but, falling back within their proper line, left us to establish
our pickets where directions had already been given to plant them.
Meanwhile the corps to which I was attached lay down to rest upon
the brow of the hill which it had maintained throughout the day.
There, after nightfall, a Spanish corps arrived to relieve us;
whereupon we stood to our arms, and moved away, taking a
direction towards the extreme left of the Allied line, though inclining
all the while to the front, and so drawing nearer to the river and the
sand-hills that overlook it.
Whether it was the intention of Sir John Hope to carry us farther
towards his left this night, I cannot tell; but on arriving in rear of
Anglete, we were by no means displeased at being told that we were
destined to remain there till the morrow. The roads were all choked
up with tumbrils, ammunition-waggons, baggage, and troops filing to
different points, apparently not in the best possible order. Around the
village, in particular, a vast bivouac, chiefly of Spanish infantry and
muleteers, had been formed, insomuch that it was not without some
difficulty that we made our way into the street; and there the sounds
which saluted us as we passed—the Babel-like confounding of all
languages—the laugh, the cry, the oath, and here and there the low
moan or wild shriek of the wounded—formed altogether a species of
concert which certainly gave no evidence of strict discipline or
accurate arrangement. It was, however, a wild and striking scene;
and a sort of wavering and dull light, which the fires of the bivouac
shed over it, added not a little to its sublimity.
At length we reached the houses which were set apart for our
accommodation; and truly they were far from being over-
commodious. About three hundred men were ushered into a cottage
consisting of two apartments, or, as they say in the north, of "a but
and a ben;" and here, upon the earthen floor, we were fain to cast
ourselves down in order to obtain in sleep an escape from the
cravings of hunger, which for several hours past had been somewhat
urgent. We had eaten nothing since three o'clock in the morning, nor
had any supply of provisions arrived. The poor cottage was, as may
be imagined, wholly unfurnished with viands; indeed, we were as
much surprised as pleased when the peasant to whom it belonged,
and who had remained to keep possession, produced a bottle of
very bad brandy, called, in the language of the country, aquadente.
This we divided among us as far as it would go; and having wished
in vain for the arrival of the quartermaster and commissary, we
wrapped our cloaks about us and lay down. Sleep soon came to our
relief.
CHAPTER XXI.
The night of the 23d passed by in quiet; and long before dawn on the
24th we stood as usual in our ranks, and under arms. So passed
about half an hour, when orders were given to form into marching
order, and to file towards the left, in the direction of the Adour. We
were glad to be put in motion, and, after a journey of about a league,
halted upon a sandy plain, at the distance of perhaps a couple of
miles from the walls of Bayonne, and half that distance, or something
less, from the outworks. Though thus placed within easy range of the
enemy's advanced batteries, we were nevertheless well protected
from their fire; for a little sand-hill stood in our immediate front, of
height sufficient to shut out not only the soldiers, but the tops of the
tents, from the gaze of the besieged.
Though we reached our ground at an early hour in the morning, a
considerable space of time elapsed ere the baggage and provisions
came up. The reader will therefore imagine that the setting forth of a
substantial breakfast, which immediately ensued, proved a source of
no trifling gratification to men who had fasted for upwards of forty
hours, and whose appetite, though stifled by sleep, had revived of
late in a very troublesome degree. It consisted, I well recollect, of
slices of beef hastily and imperfectly broiled, with mouldy biscuit and
indifferent tea; but the coarsest viands are sweet to the hungry, and
we were in no humour that day to find fault with the quality of ours.
We were yet busy with our meal, and the baggage and tents, though
removed from the backs of the animals, lay packed and ready for
another move, when the intelligence, not at that moment
unacceptable, reached us, that for the present we were to remain
stationary, that our position in the line was taken up. Immediately the
camp was marked out in due form; sundry ruinous dwellings in its
vicinity were taken possession of, chiefly as stables for the horses;
guns, fishing-rods, and greyhounds were desired to be put in
serviceable order; and every disposition was made to secure
comfort. The sole subject of complaint, indeed, was found to be in
the unfavourable state of the weather, which had become since
yesterday boisterous, with heavy showers of rain and hail. But this
very circumstance, at which we were disposed to murmur, chanced
to be, of all others, the most favourable to the operations of the army.
By the help of these squalls, the boats and chasse-marées, which
had hovered about the mouth of the Adour for several days, were
enabled to pass the bar, and the groundwork of the floating bridge (if
such an Iricism be admissible) was laid.
As the passage of the bar was an operation of considerable difficulty,
and as I was fortunate enough to be an eyewitness of the daring
intrepidity and nautical skill of those who effected it, I shall take the
liberty of describing the occurrence more at length.
My friend and myself having seen a little to the comforts of our men,
and added in an important degree to our own by a change of
habiliments, walked forth with no other view than that of whiling away
certain hours, which might have otherwise hung heavy on our hands.
We took the direction of the river's mouth, because there a dark
pine-wood promised to shelter us from the blast, and because we
were anxious to see how far the engineers had proceeded in the
construction of the bridge. At this time we were quite in the dark as
to the sort of bridge which was about to be formed. We knew not so
much as that it was to consist of sailing vessels at all, but concluded
that pontoons would be anchored, as had been the case at the
Bidassoa. Our astonishment may therefore be conceived when, on
mounting an eminence, we beheld a squadron of some thirty craft
bearing down, with all sail set, towards the bar, over which the waves
were dashing in white foam, being driven inwards by a strong gale
from the north-east. But we were not the only anxious spectators of
this animating show. The bank of the river, and all the heights near,
were crowded with general and staff officers, conspicuous among
whom were Sir John Hope, and, if my memory fail me not, Lord
Wellington himself. The groups were, one and all of them,
speechless. The squadron and its manœuvres involving, as they did,
the lives of the gallant men who executed them, seemed to engross
the attention of the lookers-on, who all faced in the same direction,
and stood silent and motionless as statues.
Down came the boats before the breeze with amazing velocity. The
surf, however, ran so high, and there seemed to be so little water
upon the sands, that I for one felt as if a weight had been removed
from my heart, when I beheld them suddenly put up their helms and
tack about again. The prospect from the sea must have been
appalling; and even British sailors hesitated, for once in their lives,
whether they could face the danger. But the hesitation was not of
long continuance. A row-boat, Spanish built, but manned by
Lieutenant Cheyne and five seamen from the Woodlark, threw
herself with great judgment upon a wave. The swell bore her clear
across the shoal; and loud and reiterated were the shouts with which
she was greeted as she rushed proudly through the deep water. The
next which came was a prize—a large French fishing-lugger—
manned by seamen from a transport, closely followed by a gunboat,
under the command of Lieutenant Cheshire. They, too, were borne
across; but the fourth was less fortunate. It was a schooner-rigged
craft, full of people, and guided by Captain Elliot. I know not how it
came about, whether a sudden change of wind occurred, or a rope
unfortunately escaped from its fastening, but at the instant when the
schooner took the foam, the mainsail of her hinder mast flapped
round. In one second her broadside was to the surf, in another she
was upset, and her gallant captain, with several of his crew, perished
among the breakers. The rest were dashed by an eddy towards the
bank and happily saved.
Our horror at contemplating this event, though extreme, was
necessarily brief, because our attention was immediately attracted to
other vessels which, one after another, drew near. Of these, all
except one, a chasse-marée, succeeded in making good the
passage. It shared the fate of the schooner: it was upset upon the
curl of a wave, and went down with the whole crew. This last was
even a more awful spectacle than the former. The little vessel, after
being tossed round, rocked for a moment, as it were, upon the surf,
just long enough for us to see the despairing gestures of the sailors,
and to hear their shriek of consternation; and then a huge wave
striking her, she fell, not upon her broadside, but with bottom
upwards. Not a man escaped of all who had conducted her, and
several fine promising midshipmen were among them.
Five-and-twenty vessels having now entered the Adour, besides four
or five gunboats destined to protect them, no time was lost in running
the whole up to their proper stations, and in bringing them securely
to anchor at equal distances from one another. They were then
strongly bound together by cables, the ends of which were made fast
to winches prepared for the purpose on each bank, and which,
running both by the bows and sterns, kept the craft tolerably steady,
notwithstanding the violence of the current. I need not add that no
economy was exercised in the matter of anchors, of which two were
dropped from each bow, and a like number from each stern.
The boats being thus rendered sufficiently secure, half-a-dozen
strong ropes were extended along their centres, at equidistances of
about two feet from one another. These were so disposed as not to
bear any continuous weight upon the smaller vessels. They were
steadied, indeed, as they passed over each, by being fastened to
capstans, and so kept from swinging too widely; but it was upon four
or five of the largest class only that they were made to lean, the
intervals between being in reality so many hanging bridges. Across
these ropes were laid down planks, made fast by ties only; and the
whole was so nicely balanced that though the tread of a single
passenger caused it to swing backwards and forwards, an entire
army might pass with perfect safety. Such was the famous bridge of
boats across the Adour, which connected the two banks of the river,
where it measures eight hundred yards in width, and which, in itself,
including groundwork on both sides, covered a space little short of
nine hundred yards.
Ahead of the bridge, with their broadsides towards the town, were
moored five gunboats, each armed with six long twenty-four
pounders. These, in their turn, were in part defended by a slight
boom; whilst a boom infinitely stronger, capable of repelling any
substance which might be floated down by the tide, hung between
them and the bridge. A boom somewhat similar, but more in the
shape of a breakwater, was placed behind the bridge, to shelter it

You might also like