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

Programming Arduino Next Steps: Going Further with Sketches 2nd Edition Simon Monk all chapter instant download

Sketches

Uploaded by

bositokopio
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 (2 votes)
61 views

Programming Arduino Next Steps: Going Further with Sketches 2nd Edition Simon Monk all chapter instant download

Sketches

Uploaded by

bositokopio
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/ 65

Download the Full Version of textbook for Fast Typing at textbookfull.

com

Programming Arduino Next Steps: Going Further with


Sketches 2nd Edition Simon Monk

https://textbookfull.com/product/programming-arduino-next-
steps-going-further-with-sketches-2nd-edition-simon-monk/

OR CLICK BUTTON

DOWNLOAD NOW

Download More textbook Instantly Today - Get Yours Now at textbookfull.com


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

Hacking Electronics: Learning Electronics with Arduino and


Raspberry Pi, 2nd Edition Simon Monk

https://textbookfull.com/product/hacking-electronics-learning-
electronics-with-arduino-and-raspberry-pi-2nd-edition-simon-monk/

textboxfull.com

Electronics Cookbook Practical Electronic Recipes with


Arduino Raspberry Pi 1st Edition Simon Monk

https://textbookfull.com/product/electronics-cookbook-practical-
electronic-recipes-with-arduino-raspberry-pi-1st-edition-simon-monk/

textboxfull.com

Action movement light and sound with Arduino and Raspberry


Pi First Edition Monk

https://textbookfull.com/product/action-movement-light-and-sound-with-
arduino-and-raspberry-pi-first-edition-monk/

textboxfull.com

Raspberry Pi Cookbook Software and Hardware Problems and


Solutions 2nd Edition Simon Monk

https://textbookfull.com/product/raspberry-pi-cookbook-software-and-
hardware-problems-and-solutions-2nd-edition-simon-monk/

textboxfull.com
Teach Yourself Electricity and Electronics Simon Monk

https://textbookfull.com/product/teach-yourself-electricity-and-
electronics-simon-monk/

textboxfull.com

Arduino Programming with .NET and Sketch 1st Edition Agus


Kurniawan

https://textbookfull.com/product/arduino-programming-with-net-and-
sketch-1st-edition-agus-kurniawan/

textboxfull.com

Arduino Programming with .NET and Sketch 1st Edition Agus


Kurniawan

https://textbookfull.com/product/arduino-programming-with-net-and-
sketch-1st-edition-agus-kurniawan-2/

textboxfull.com

Practical Electronics for Inventors Fourth Edition Paul


Scherz Simon Monk

https://textbookfull.com/product/practical-electronics-for-inventors-
fourth-edition-paul-scherz-simon-monk/

textboxfull.com

Psychiatry P R N Principles Reality Next Steps 2nd Edition


Sarah Stringer Laurence Church Susan Davison

https://textbookfull.com/product/psychiatry-p-r-n-principles-reality-
next-steps-2nd-edition-sarah-stringer-laurence-church-susan-davison/

textboxfull.com
Programming
Arduino®

Next Steps

00_FM.indd 1 9/4/18 7:01 PM


About the Author
Simon Monk has a bachelor’s degree in cybernetics and computer science
and a Ph.D. in software engineering. He has authored more than 20 books,
including Programming Arduino: Getting Started with Sketches, Programming
the Raspberry Pi, Programming the BBC micro:bit, and Practical Electronics for
Inventors. Dr. Monk also runs the website monkmakes.com, which fea-
tures his own products.

00_FM.indd 2 9/4/18 7:01 PM


Programming
Arduino ®

Next Steps
Going Further with Sketches

Second Edition

Simon Monk

New York Chicago San Francisco Athens


London Madrid Mexico City Milan
New Delhi Singapore Sydney Toronto

00_FM.indd 3 9/4/18 7:01 PM


Copyright © 2019 by McGraw-Hill Education. 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 excep-
tion 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-25-958860-0
MHID: 1-25-958860-2

The material in this eBook also appears in the print version of this title: ISBN: 978-1-25-958859-4,
MHID: 1-25-958859-9.

eBook conversion by codeMantra


Version 1.0

All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occur-
rence 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 promo-
tions or for use in corporate training programs. To contact a representative, please visit the Contact Us page at
www.mhprofessional.com.

McGraw-Hill Education, the McGraw-Hill Education logo, TAB, and related trade dress are trademarks or reg-
istered trademarks of McGraw-Hill Education and/or its affiliates in the United States and other countries and
may not be used without written permission. All other trademarks are the property of their respective owners.
McGraw-Hill Education is not associated with any product or vendor mentioned in this book.

Information has been obtained by McGraw-Hill Education from sources believed to be reliable. However, because
of the possibility of human or mechanical error by our sources, McGraw-Hill Education, or others, McGraw-Hill
Education 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 licen-
sors 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.
CONTENTS AT A GLANCE

1 Programming Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2 Under the Hood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

3 When Is an Arduino Not an Arduino? . . . . . . . . . . . . . . . . 59

4 Interrupts and Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

5 Making Arduino Faster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

6 Low-Power Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

7 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

8 Interfacing with Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

9 Using I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

10 Interfacing with 1-Wire Devices . . . . . . . . . . . . . . . . . . . . . . 169

11 Interfacing with SPI Devices . . . . . . . . . . . . . . . . . . . . . . . . . 177

12 Serial UART Programming . . . . . . . . . . . . . . . . . . . . . . . . . . 187

13 USB Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

14 Network and Internet of Things Programming . . . . . . . . . 211

15 Digital Signal Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239

16 Managing with One Process . . . . . . . . . . . . . . . . . . . . . . . . . 259

17 Writing Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271

A Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

00_FM.indd 5 9/4/18 7:01 PM


00_FM.indd 6 9/4/18 7:01 PM
CONTENTS

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Acknowledgments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

1 Programming Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
What Is Arduino? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Installation and the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Installing the IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Blink . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
A Tour of Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Power Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Analog Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Digital Connections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Arduino Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Uno and Similar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Big Arduino Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Small Arduino Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Unofficial Arduinos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Programming Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Modifying the Blink Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
If . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Digital Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Digital Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
The Serial Monitor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Arrays and Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Analog Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

vii

00_FM.indd 7 9/4/18 7:01 PM


viii Contents

Analog Outputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Using Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Arduino Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Arduino Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

2 Under the Hood . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39


A Brief History of Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Anatomy of an Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
AVR Processors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
ATmega328 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
ATmega32u4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
ATmega2560 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
AT91SAM3X8E . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Arduino and Wiring . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
From Sketch to Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
AVR Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Installing a Bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Burning a Bootloader with AVR Studio
and a Programmer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Burning a Bootloader with the Arduino IDE
and a Second Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

3 When Is an Arduino Not an Arduino? . . . . . . . . . . . . . . . . 59


The Arduino IDE’s Extensible Architecture . . . . . . . . . . . . . . . 60
Adafruit Circuit Playground Express . . . . . . . . . . . . . . . . . . . . . 61
NodeMCU . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
ESP32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
ATtiny Microcontrollers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
ATtiny44 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Using an Arduino as a Programmer . . . . . . . . . . . . . . . . . . . 68
Installing ATtinyCore into the IDE . . . . . . . . . . . . . . . . . . . . 70
Clocks, Crystals, and Fuses . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Minimal Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

00_FM.indd 8 9/4/18 7:01 PM


Contents ix

4 Interrupts and Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73


Hardware Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Interrupt Pins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
Interrupt Modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Enabling Internal Pull-Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Interrupt Service Routines . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
Volatile Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
ISR Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Enabling and Disabling Interrupts . . . . . . . . . . . . . . . . . . . . . . . 80
Timer Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

5 Making Arduino Faster . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85


How Fast Is an Arduino? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
Comparing Arduino Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86
Speeding Up Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Do You Really Need to Use a Float? . . . . . . . . . . . . . . . . . . . 88
Lookup vs. Calculate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
Fast I/O . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Basic Code Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
Bytes and Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
ATmega328 Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Very Fast Digital Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Fast Digital Input . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
Speeding Up Analog Inputs . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

6 Low-Power Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101


Power Consumption of Arduino Boards . . . . . . . . . . . . . . . . . . 101
Current and Batteries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
Reducing the Clock Speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104
Turning Things Off . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
Sleeping ATmega-Based Arduinos . . . . . . . . . . . . . . . . . . . . . . . 108
Narcoleptic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
Waking ATmega-Based Arduinos on External Interrupts . 111
ESP8266 Sleeping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

00_FM.indd 9 9/4/18 7:01 PM


x Contents

ESP32 Sleeping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114


Use Digital Outputs to Control Power . . . . . . . . . . . . . . . . . . . . 116
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

7 Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Arduino Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
Minimizing RAM Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
Use the Right Data Structures . . . . . . . . . . . . . . . . . . . . . . . . 121
Store String Constants in Flash Memory . . . . . . . . . . . . . . . 122
Common Misconceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
Measure Free Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Minimizing Flash Usage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
Use Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Remove Unwanted Trace . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Bypass the Bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
Static vs. Dynamic Memory Allocation . . . . . . . . . . . . . . . . . . . 125
Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
C char Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
The Arduino String Object Library . . . . . . . . . . . . . . . . . . . . 130
Using EEPROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131
EEPROM Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
Using the avr/eeprom.h Library . . . . . . . . . . . . . . . . . . . . . . 135
EEPROM Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Using Flash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Using SD Card Storage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

8 Interfacing with Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141


Binary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
Arduino Types and Binary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142
Hexadecimal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
Masking Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145
Shifting Bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
Serial Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

00_FM.indd 10 9/4/18 7:01 PM


Contents xi

9 Using I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153


I2C Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
The I2C Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156
The Wire Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Initializing I2C . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Master Sending Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157
Master Receiving Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
I2C Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
TEA5767 FM Radio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Arduino-to-Arduino Communication . . . . . . . . . . . . . . . . . 161
LED Backpack Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164
DS1307 Real-Time Clock . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

10 Interfacing with 1-Wire Devices . . . . . . . . . . . . . . . . . . . . . . 169


1-Wire Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
The 1-Wire Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
The OneWire Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170
Initializing 1-Wire . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Scanning the Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Using the DS18B20 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

11 Interfacing with SPI Devices . . . . . . . . . . . . . . . . . . . . . . . . . 177


Bit Manipulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
SPI Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178
The SPI Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
The SPI Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
SPI Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185

12 Serial UART Programming . . . . . . . . . . . . . . . . . . . . . . . . . . 187


Serial Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
Serial Protocol . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
The Serial Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
The SoftwareSerial Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

00_FM.indd 11 9/4/18 7:01 PM


xii Contents

Serial Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194


Computer to Arduino over USB . . . . . . . . . . . . . . . . . . . . . . 194
Arduino to Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
GPS Module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

13 USB Programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203


Keyboard and Mouse Emulation . . . . . . . . . . . . . . . . . . . . . . . . 203
Keyboard Emulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 204
Keyboard Emulation Example . . . . . . . . . . . . . . . . . . . . . . . . 205
Mouse Emulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206
Mouse Emulation Example . . . . . . . . . . . . . . . . . . . . . . . . . . 206
USB Host on the Arduino Due . . . . . . . . . . . . . . . . . . . . . . . . 207
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210

14 Network and Internet of Things Programming . . . . . . . . . 211


Networking Hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Ethernet Shield . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
Arduino Ethernet/EtherTen . . . . . . . . . . . . . . . . . . . . . . . . . . 212
The Ethernet Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
Making a Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
Setting Up a Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
Making Requests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
Wired Ethernet Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Physical Web Server . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Using a JSON Web Service . . . . . . . . . . . . . . . . . . . . . . . . . . . 223
The Official Arduino WiFi Library . . . . . . . . . . . . . . . . . . . . . . . 227
Making a Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
WiFi-Specific Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 227
Arduino WiFi Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228
ESP8266/ESP32 WiFi Example . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Internet of Things . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 232
dweet.io . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
Programming the NodeMCU or Wemos D1 Mini . . . . . . . 234
Attaching the TMP36 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235

00_FM.indd 12 9/4/18 7:01 PM


Contents xiii

A Web Page to Display the Temperature . . . . . . . . . . . . . . . 236


Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237

15 Digital Signal Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239


Introducing Digital Signal Processing . . . . . . . . . . . . . . . . . . . . 239
Averaging Readings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
An Introduction to Filtering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243
Creating a Simple Low-Pass Filter . . . . . . . . . . . . . . . . . . . . . . . 243
Arduino Uno DSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 245
Arduino Due DSP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 247
Filter Code Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 249
The Fourier Transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 253
Spectrum Analyzer Example . . . . . . . . . . . . . . . . . . . . . . . . . 254
Frequency Measurement Example . . . . . . . . . . . . . . . . . . . . 256
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257

16 Managing with One Process . . . . . . . . . . . . . . . . . . . . . . . . . 259


Making the Transition from Big Programming . . . . . . . . . . . . . 259
Why You Don’t Need Threads . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Setup and Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
Sense Then Act . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
Pause Without Blocking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 262
The Timer Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
State Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 265
State Machines in Arduino . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269

17 Writing Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271


When to Make a Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271
Using Classes and Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 272
Library Example (TEA5767 Radio) . . . . . . . . . . . . . . . . . . . . . . . 272
Define the Library’s Interface . . . . . . . . . . . . . . . . . . . . . . . . . 274
Write the Header File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275
Write the Implementation File . . . . . . . . . . . . . . . . . . . . . . . . 276
Write the Keywords File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277
Make the Examples Folder . . . . . . . . . . . . . . . . . . . . . . . . . . . 278

00_FM.indd 13 9/4/18 7:01 PM


xiv Contents

Testing the Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278


Releasing the Library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
Publishing Your Library on GitHub . . . . . . . . . . . . . . . . . . . . . . 279
GitHub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 279
Creating a Repository . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280
Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 282

A Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Arduino Boards . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
Components and Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Suppliers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
Arduino Starter Kits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 287

00_FM.indd 14 9/4/18 7:01 PM


PREFACE

Since the first edition of this book was released in 2013, some things in
the world of Arduino have stayed surprisingly constant and others have
changed. The Arduino Uno is still most people’s idea of what an Arduino
should be and the Arduino IDE has kept its simple interface, while adding
some great new features such as the Library and Board Managers.
However, what has changed is that the word “Arduino” has come to
denote a way of programming boards as much as the boards themselves.
New Arduino-compatible boards provide a vast variety of hardware to
choose from, all of which can be programmed using the Arduino IDE.
The main changes to this edition include the addition of two new
chapters:
• Chapter 3, “When Is an Arduino Not an Arduino?” This chapter
shows you how to use the Arduino IDE with Arduino-compatible
boards such as the ESP8266 and ESP32 boards as well as ARM m0
boards such as the Adafruit Circuit Playground Express and Trinket
m0 boards.
• Chapter 8, “Interfacing with Arduino” This chapter explains the
theory behind interfacing with microcontrollers that you will need
to understand when working with I2C, SPI, and UART serial.
The “Network Programming” chapter from the first edition (now
Chapter 14, “Network and Internet of Things Programming”) has been
extensively revised to include both official Arduino network program-
ming and the more widely used ESP8266 and ESP32 WiFi programming.
The chapter has also been extended to look at parsing JSON web services
and use of the dweet.io IoT service.

xv

00_FM.indd 15 9/4/18 7:01 PM


xvi Preface

Chapter 16, “Managing with One Process,” has gained a new section on
designing programs using finite state machine diagrams.
The other chapters of the book have also been given a general update.

Simon Monk

00_FM.indd 16 9/4/18 7:01 PM


ACKNOWLEDGMENTS

Many thanks to all those at McGraw-Hill Education who have done such
a great job in producing this book. In particular, thanks to my editor Lara
Zoble and to Patricia Wallenburg, Elizabeth Houde, Lynn Messina, Stephen
Smith, and Claire Splan.
Thanks to Duncan Amos for his diligent technical review. This book is
greatly improved by his keen eye for detail and unerring ability to sniff
out waffle and vagueness.
I would also like to thank Adafruit, SparkFun, and CPC for supplying
many of the modules and components used in the preparation of this
book.
And last but not least, thanks once again to Linda, for her patience and
generosity in giving me space to do this.

xvii

00_FM.indd 17 9/17/18 9:42 AM


00_FM.indd 18 9/4/18 7:01 PM
INTRODUCTION

Arduino has become the standard microcontroller used by makers, art-


ists, and educators due to its ease of use, low cost, and plethora of interface
boards (shields). Plug-in shields can be attached to the basic board, extend-
ing the Arduino into the Internet, robotic, and home automation realms. As
well as official Arduino hardware, the many types of Arduino-compatible
boards that can be programmed from the Arduino IDE mean that you can
find a board that suits your project’s requirements and cost constraints.
Simple Arduino projects are easy to make. As soon as you start to stray
into territory not covered by the introductory texts, however, you’ll find
that things can rapidly become confusing and frustrating as complexity—
the enemy of all programmers—rears its ugly head.
This book is designed as a companion and sequel to the very successful
book Programming Arduino: Getting Started with Sketches. Although this book
includes a brief recap of basic Arduino programming, it leads the reader
through the more advanced aspects of Arduino programming. Specifically,
this book will help you with:
• Working effectively with minimal memory
• Doing more than one thing at a time, without the luxury of
multithreading
• Setting up the Arduino IDE to use “Arduino-compatible” boards
• Using hardware and timer interrupts
• Maximizing performance
• Minimizing power consumption
• Interfacing with different types of serial busses (I2C, 1-Wire, SPI,
and serial)
• USB programming
• Network programming
• Digital Signal Processing (DSP)
xix

00_FM.indd 19 9/4/18 7:01 PM


xx Introduction

Downloads
The book includes some 75 example sketches, which are all open source and
available from the book’s web page at http://simonmonk.org/nextsteps2.
Follow the link to the pages for this book where you will be able to down-
load the code as well as an up-to-date list of errata for the book.

What Will I Need?


This book is primarily about software. So, for most of the examples, all
you really need is an Arduino (or compatible board) and an LED or multi-
meter. Having said that, if you do have other Arduino shields, these will
come in handy. You will also need an Ethernet or WiFi shield for Chapter
12. Throughout the book, several different types of module are used to
illustrate different interfaces.
Although the book is mostly concerned with the Arduino Uno (the
most commonly used Arduino board), it also covers other special-purpose
Arduinos as well as some of the most popular Arduino-compatible boards.
The Appendix at the end of this book lists possible suppliers for these
parts.

Using This Book


Each of the chapters deals with a specific topic relating to Arduino program-
ming. Apart from Chapter 1, which is a recap and overview of Arduino
basics, the remaining chapters can be accessed pretty much in any order
you like.
Following is a description of each chapter:
1. “Programming Arduino” This chapter contains a summary of
Arduino programming. It is a primer for those needing to get up
to speed quickly with basic Arduino.
2. “Under the Hood” In this chapter, we take a peek under the
hood at how the Arduino software works and where it came from.

00_FM.indd 20 9/4/18 7:01 PM


Introduction xxi

3. “When Is an Arduino Not an Arduino?” The word “Arduino”


has come to mean a lot more than just the standard Arduino
boards. In this chapter you will learn how to use Arduino-
compatible boards with the Arduino IDE.
4. “Interrupts and Timers” Novices often steer clear of using
interrupts. They shouldn’t, however, as they can be handy on
occasion and are not difficult to code for. Although there are some
pitfalls, this chapter tells you what you need to be aware of.
5. “Making Arduino Faster” Arduinos have low-speed, low-power
processors and sometimes you need to squeeze every ounce of
juice out of them. For example, the built-in digitalWrite function
is safe and easy to use, but is not very efficient, especially when
setting multiple outputs at the same time. In this chapter, you
look at ways to exceed this performance and learn about other
techniques for writing time-efficient sketches.
6. “Low-Power Arduino” When you want to run your Arduino
on batteries or solar, then you need to look at minimizing power
consumption. In addition to optimizing the hardware design, you
can also set up the code to reduce the Arduino’s energy use.
7. “Memory” In this chapter, we look at minimizing memory usage
and the benefits and dangers associated with using memory
dynamically within your sketches.
8. “Interfacing with Arduino” This chapter explains the theory
behind interfacing with microcontrollers that you will need to
understand when working with I2C, SPI, and UART serial.
9. “Using I2C” The Arduino’s I2C interface can greatly simplify
talking to modules and components, reducing the number of
interface pins you need to use. This chapter describes how I2C
works and how to use it.
10. “Interfacing with 1-Wire Devices” This chapter focuses on
1-Wire bus devices such as Dallas Semiconductor’s range of
temperature sensors, which are extremely popular for use with
the Arduino. You learn how the bus works and how to use it.

00_FM.indd 21 9/4/18 7:01 PM


xxii Introduction

11. “Interfacing with SPI Devices” Yet another interface standard


used with the Arduino is SPI. This chapter explores how it works
and how to use it.
12. “Serial UART Programming” Serial communications, either
through USB or the Arduino’s Rx and Tx pins, provide a great
way to exchange data between peripherals and other Arduinos.
In this chapter, you learn how to use serial.
13. “USB Programming” This chapter looks at various aspects of
using the Arduino with USB. You’ll learn about the keyboard and
mouse emulation features provided by the Arduino Leonardo
and also the reverse process of allowing a USB keyboard or
mouse to be connected to a suitably equipped Arduino.
14. “Network and Internet of Things Programming” The Arduino
is a common component in the Internet of Things. In this chapter,
you’ll learn how to program Arduino and Arduino-compatibles
for use in network settings and for the Internet of Things.
15. “Digital Signal Processing” The Arduino is capable of fairly
rudimentary signal processing. This chapter discusses a variety
of techniques, from filtering a signal from an analog input using
software rather than external electronics to calculating the relative
magnitude of various frequencies in a signal using the Fast Fourier
Transform.
16. “Managing with One Process” Programmers coming to Arduino
from a background of programming large systems often signal the
lack of multithreading and concurrency in Arduino as some kind of
deficiency. In this chapter, I try to set the record straight and show
how to embrace the single-thread model of embedded systems.
17. “Writing Libraries” Sooner or later, you will make something
really good that you think other people could use. This is the time
to wrap up the code in a library and release it to the world. This
chapter shows you how.

00_FM.indd 22 9/4/18 7:01 PM


Introduction xxiii

Resources
This book is supported by a page on the author’s website (http://
simonmonk.org/nextsteps2/) and a GitHub repository containing all the
examples (https://github.com/simonmonk/nextsteps2). Follow the link
for this book, and you will find all the source code, as well as other
resources such as errata.

00_FM.indd 23 9/4/18 7:01 PM


00_FM.indd 24 9/4/18 7:01 PM
1
Programming Arduino

This chapter summarizes the basics of Arduino. If you are completely


new to Arduino, then you might find it useful to also read Programming
Arduino: Getting Started with Sketches (McGraw-Hill Professional, 2016).

What Is Arduino?
The term Arduino is used to describe both the physical Arduino board (of
which the most popular type is the Arduino Uno) and the Arduino system
as a whole. The system also includes the Arduino IDE software you need to
run on your computer (to program the board) and the peripheral shields
that you can plug into an Arduino board. Arduino has also come to mean a
whole array of third-party Arduino compatible boards that have nothing to
do with the Arduino organization, but that will work with the Arduino IDE.
To use an Arduino, you also need a “proper” computer. This can be a
Mac, Windows PC, Linux PC, or even something as humble as a Raspberry
Pi. The main reason that you need the computer is so you can install pro-
grams onto the Arduino board. Once installed on the Arduino, these pro-
grams can then run independently.
Figure 1-1 shows an Arduino Uno.
The Arduino can also communicate with your computer over USB.
While the computer is connected, you can send messages in both direc-
tions. Figure 1-2 shows the relationship between the Arduino and your
computer.

01_Ch01.indd 1 9/2/18 5:08 PM


2 Programming Arduino Next Steps

Figure 1-1 An Arduino Uno.

Sensors

Computer

Actuators

Figure 1-2 The Arduino and your computer.

01_Ch01.indd 2 9/2/18 5:08 PM


Chapter 1: Programming Arduino 3

An Arduino is unlike a conventional computer in that it has hardly any


memory, no operating system, and no keyboard mouse or screen interface.
Its purpose is to control things by interfacing with sensors and actuators.
So, for instance, you might attach a sensor to measure the temperature and
a relay to control the power to a heater.
Figure 1-3 shows some of the things that you can attach to an Arduino
board. There are many more types of devices that you can connect to an
Arduino.

Pressure
Temp Sensor Stress
Sensor Sensor

Ethernet
Shield Switches

WiFi Variable
Shield Resistor

Bluetooth Range
Shield Finder

USB PIR
Host Sensor

Graphic
Relay
Display

16x2 Motor
Display Controller
LED

Figure 1-3 Interfacing with an Arduino.

01_Ch01.indd 3 9/2/18 5:08 PM


4 Programming Arduino Next Steps

Here is a short selection of some of the amazing projects that have been
built using an Arduino:
• Bubblino—an Arduino linked to a bubble machine that blows
bubbles when you tweet it!
• 3D LED cubes
• Geiger counters
• Musical instruments
• Remote sensors
• Robots

Installation and the IDE


The software that you use to program the Arduino is called the Arduino
Integrated Development Environment (IDE). If you are a software developer
and accustomed to using complex IDEs like Eclipse or Visual Studio,
you’ll find the Arduino IDE very simple—and possibly find yourself
wishing for repository integration, command completion, and the like. If
you are relatively new to programming, you will love the Arduino’s sim-
plicity and ease of use.

Installing the IDE


The first step is to download the software for your type of computer from
the official Arduino website: http://arduino.cc/en/Main/Software.
Once you’ve downloaded the software, then you can find detailed
installation instructions for each platform here: http://arduino.cc/en/
Guide/HomePage.
The Arduino team has also produced an online IDE that runs in your
browser. This is not as comprehensive as the offline version and so it will
not be used in this book.
One of the nice things about the Arduino is that all you need to get
started is an Arduino, a computer, and a USB lead to connect the two. The
Arduino can even be powered over the USB connection to the computer.

01_Ch01.indd 4 9/2/18 5:08 PM


Exploring the Variety of Random
Documents with Different Content
"I shall have Chuckles to spend the day with me,"
announced Jockie. "He is quite charming!"

"He is a dear little boy," said Sidney, rather absently.

Her thoughts were straying to Austin and to Mrs.


Norman. She honestly did not want him to become engaged
to her, and yet it seemed to her that if that happened, she
would have no longer any anxiety about her uncle. She was,
as she said, torn two ways. And then she impulsively turned
to Jockie.

"I wish you were a man, Jockie—a good-looking,


wealthy man on the look-out for a wife, a man who would
be quick and successful in his wooing, and who would insist
upon a speedy marriage!"

Jockie stared at her.

"You don't want him for yourself, do you?"

"Rather not; but I know of someone who would make


him a very sweet bride."

Then she laughed.

"I am talking nonsense, Jockie. You must forget it."

"I'll try," said Jockie; but she knew she would not, and
she made a mental note of Sidney's strange speech, and
determined to keep her eyes open for the possible "sweet
bride."

They reached Thanning Towers. Mrs. de Cressiers


welcomed them cordially, but she looked careworn and
anxious. Mr. de Cressiers was not at all well, and in an
irritable frame of mind. Austin and he had been having a
difference of opinion, and Mrs. de Cressiers had been called
in to intervene. Austin came to lunch gloomy and self-
absorbed, but in Jockie's vicinity, it was impossible to
remain grave for long. She soon had him laughing, and
before the meal was over a happy easy camaraderie had
been established between them. He insisted upon taking
her out into the grounds, and Mrs. de Cressiers, with relief
in her face, swept off Sidney into the drawing-room.

"Oh, my dear, I am so troubled! George is getting quite


unfit to discuss business affairs, and he will insist upon
doing it! I don't know what we shall do. Austin has neither
patience nor tact. He expects his father to understand what
he cannot. He does not realise his brain power is failing. We
have had dreadful scenes this morning. And, of course,
Austin has been careless and negligent lately. I can hardly
ever get hold of him to have a quiet talk. He shuns being
with me. He is wrapped up in his hunting."

Mrs. de Cressiers had seldom spoken so freely to Sidney


as she did now. Her reserve and pride seemed to have been
crushed in her real anxiety about her husband and son.

Sidney's face was grave and sympathetic as she


listened.

Mrs. de Cressiers continued:

"I had got it into my head that Mrs. Norman was the
attraction in the hunting field, but she happened to call late
yesterday afternoon, and from what she said I see my fears
were quite unfounded. In fact, she assured me that Austin
was quite offended with her because she talked to him for
his good, and told him his duty was to stay at home and
help his father and me. You used to have influence with
him, Sidney dear; can't you exert it now? It's a bitter
confession for a mother to make, but it is true. My words
make no impression upon him. He will listen to a stranger
rather than to me."

"I think if Mrs. Norman cannot influence him in the right


direction, I cannot," said Sidney slowly.

"Well, something will have to be done. I cannot go


through such scenes as we had this morning. They are bad
for all of us, especially for my poor husband. I believe this
will be his last winter with us. Is it too much to ask of his
son that he should give up his hunting and help and comfort
us?"

"No," said Sidney firmly; "I think Austin ought to do it. I


will talk to him again, if I get a chance. But you must
forgive me for saying it—if you were to meet him half-way
and show him as much affection as you really feel for him,
Austin would respond at once."

Mrs. de Cressiers' head was instantly raised haughtily


and stiffly.

"I think, my dear Sidney, I do not require you to teach


me my duty as a mother."

"I am sorry."

Sidney spoke penitently, and then Mrs. de Cressiers said


in a different tone:

"That is a nice little girl you brought with you. Shall we


walk out into the garden and join them?"

They did so, but Sidney got no chance of a word alone


with Austin. He avoided her, and as soon as they had left
the house, he went to the stables and ordered his horse.
His mother did not see him again till dinner-time.

CHAPTER X
JOCKIE'S FRIEND

JOCKIE settled down at the Rectory in a surprisingly


quick time. She took a Sunday class of boys, and helped as
much as she was allowed in the parish. The Rector before
long began to trust her, and discovered that she was not the
flighty damsel that her words had led him to expect. She
was devoted to Sidney, and gave her a young girl's worship,
but she was of too energetic a nature to be satisfied with
her quiet life at the Rectory.

She marched up to Monica one day.

"I want work, Miss Pembroke. Miss Urquhart says you


can give me some. I can't fill my days. Cousin John has too
many servants. There is nothing to do. The gardener won't
let me touch the garden; the housekeeper orders the
house; when I'm not running about the village, I read; but I
know that my friend Gavine would say that if I take in, I
must give out. She is great on work. I had a letter from her
the other day. She implores me to make myself of use to
my fellow-creatures. What can I do?"

Monica looked at her thoughtfully.


"I believe you can help me," she said; "not by outdoor
work—I could give you a lot of that—but by taking Chuckles
in hand."

"Oh, how heavenly!" gasped Jockie. "Tell me quickly!"

"Could you give him steady teaching from nine to


twelve every morning, and then take him for an hour's
walk. I am not at all satisfied with his school. It is a small
private one in Pegborough, and the few boys who go to it
are tradesmen's sons. I don't mind that, but the teaching is
indifferent, and he is not improving in manners or
principles. I want to send him to a good boarding-school
next year, and I want him coached in Latin, as well as
French and English. Of course, if you take him, we must do
it on business terms. I should regard you as his governess."

Jockie's face was radiant.

"Miss Pembroke, you are a witch! Who told you of my


secret longings to earn something? You know, I arrived with
two shillings and twopence in my pocket. My father has not
sent me a penny as yet, and I can't go to Cousin John. I
was wondering what I should do. And then you offer me the
job that I should like above all others. I'm sure I know
enough Latin to satisfy you, and I assure you I'll be as stern
as you are in school-time. When can I start?"

"I think at once. This is the second time this term I


have had to have him home. They seem to have perpetual
epidemics at the school. Of course, I trust you to teach him
thoroughly, and have no games in school-hours. He is not
very strong, and he will be out of doors with me in the
afternoons."

Jockie could hardly express her gratitude. Terms were


arranged, and lessons were started in earnest the very next
day. Jockie was a clever girl and had a knack of teaching;
Chuckles was as good as gold, and everything went
smoothly.

One fine frosty afternoon Jockie came in upon Sidney


with her usual flow of spirits.

"I've been enjoying myself so much," she said. "I met


Mr. Austin, and we've actually climbed the Beacon together.
He was very grumpy at first, but he couldn't keep it up.
How hunting people hate frost. I'm rather glad I don't ride.
If I did, I think I should neglect everything else for it, like
Mr. Austin. He's great fun when you get him alone, isn't he?
And then, on the way home, we met his ladylove—Mrs.
Norman. I know all about it. He was singing her praises
most of the way. Well, she stopped and asked to be
introduced to me, and, Miss Urquhart, we only chatted
together for about ten minutes, but it's going to be war to
the knife between us!"

"My dear Jockie, don't say such things!"

"But I must. I tell you everything. And I made a most


astonishing discovery; that's why I have come to tell it to
you. But I'll give you our conversation first. She began by
commiserating Austin—I can't help calling him by his
Christian name to you—upon the frost, and then I spoke up.

"'It will keep him more at home, Mrs. Norman, and that
will be a good thing,' for Austin had been telling me a little
of his home affairs. She gave me a nasty gleam out of her
eye, and then, ignoring me, went on to talk about people in
the hunting field, whom, of course, I didn't know; and then,
looking at her, it suddenly flashed across me, and I said:
'I've seen you before, Mrs. Norman, and I know someone
whom you know.'
"She gave a little start, but smiled and said:

"'I'm afraid I don't remember you.'

"'But your daughter is my greatest friend,' I said, 'and I


saw you once when we travelled to town together, and you
told her that you could not have her with you for the
Christmas holidays. It was a blow to her, poor girl, for her
aunts were abroad, and you sent her to an old nurse who
kept lodgings in some fusty London square. Poor Gavine
had an awful Christmas; she wrote and told me all about it.'

"'Oh,' she said, 'do you really know my dear Gavine?


Yes, I remember, poor child. I don't know who felt it most,
she or I. That was a dreadful Christmas. And so you are one
of her schoolfellows! How delightful! You must come and
see me, and we will have great talks together.'

"'I'm going to get Cousin John to invite Gavine down


here,' I went on. 'She never has any pleasures with her
invalid aunts.'

"'I think when her aunts can spare her, she will come to
me,' she said, and she tried to speak very haughtily. So I
laughed and said:

"'But you never want her, do you? There's always some


reason why you can't have her.'

"And then she glared at me and went on talking very


fast to Austin, and presently I said good-bye and left them.
Now, isn't it funny that I did not connect her with Gavine
before, as, of course, it is the same name? And do you
know, Miss Urquhart, that her daughter doesn't know where
she is? She hardly ever writes to her, and Gavine thought
she was abroad."
Jockie paused for breath, and Sidney looked quite
mystified.

"How very strange! Then is the girl you talk so much


about Mrs. Norman's daughter?"

"Yes; and she has treated her abominably. She hardly


ever sends her any money, and always writes as if she is at
her last penny. Fancy! Since Gavine left school, she has only
been allowed twelve pounds a year! It's a kitchenmaid's
wages when she first goes out. Gavine has two aunts who
are not at all well off, and one of them is paralysed; but
they have given her a home until her mother can settle
down and have her. She has always said she would do it,
and now she has taken a cottage here, there's no reason
why Gavine should not come to her. Only if she lives with
her, I know she'll be perfectly miserable. I'll get her to come
to me; that will make her mother feel ashamed of herself."

"Oh, Jockie, dear, you must not talk so. She is her
mother. If your friend is a nice girl, she must feel attached
to her own mother."

"So she does. Gavine is an angel. But I know what her


life has been—continual disappointments. She's always
hoped and longed to live with her mother, and Mrs. Norman
won't have her. She likes to pose as a young woman; and
Gavine is much handsomer than she is, and wants to do
good, and Mrs. Norman hates good people. She hates you,
Miss Urquhart. She mentioned your name to Austin.

"I'll tell you what she said. 'Do come and deliver me
from that poor old Major. He has come down every day for
the last week. I feel so sorry for him. It is a great pity he
has such an unhappy home. I cannot understand Miss
Urquhart; but then I don't know her. She seems to me such
a pleasant girl to outsiders, but she does not show much
affection to her poor old uncle.'

"I flared up, of course. 'Miss Urquhart adores him, and


he adores her,' I said.

"And then Austin laughed. 'You have got hold of the pig
by the wrong ear, Mrs. Norman,' he said. 'The old Major is a
confounded bore, but his niece has always been most
awfully good to him. I've had the run of the house since I
was quite a small boy, so I know.'

"Now, don't you think that ought to have squashed her?


Not a bit. She looked quite perturbed and sorry. 'Oh, dear!
What a dreadful old humbug the Major is!' she said. 'He
gave me to understand quite the contrary. I suppose he was
wanting to get my pity. Old men love to have a grievance,
don't they?'

"It was then I said good-bye to them and walked on.


Yes, it is war to the knife between us, Miss Urquhart. I feel
it in my bones. And, of course, I understand why you want
another man to come upon the scene and carry her off. I
wish he would."

"You take my breath away, Jockie!" Sidney said with a


distressed look in her eyes. Jockie's recital had cut her to
the quick, and the girl perceived it. She flung her arms
round her and kissed her.

"Don't look like that! My tongue runs away with me. We


won't think any more about her. She isn't worth it. But I
shall write and tell Gavine where her mother is."

Jockie was as good as her word, and came to tell Sidney


the result.
"Gavine says she has just heard from her mother, and
she wants her down here at once. Isn't it exciting? I shall
love to have her. I want her to see you, and you are sure to
like her—everyone does—but keep a little bit of your heart
for me."

Sidney laughed at her.

"You won't want me when your friend comes."

"I've just met Mr. Austin," Jockie continued; "so I told


him the news. He didn't look best pleased. I think this frost
is making him very cross. When I told him that Gavine
ought to live with her mother always, he said curtly:

"'I don't see why she should.'

"So then I said an awful thing! I can't help my tongue,


Miss Urquhart. I wish I could. It is past my control entirely.
I said: 'I suppose you wouldn't care to have so old a
stepdaughter?'

"He looked as if he could bite my head off, and turned


bang round and walked off without saying good-bye, or
even raising his cap. He can be very rude when he likes. So
then my temper was up, and I called after him: 'You had
much better let the Major have his innings. His age is much
more suitable.' And, of course, you'll say I was rude and
vulgar. I thought I was myself when he had gone."

"I don't see why you should try to quarrel with Austin,"
said Sidney very quietly.

"He annoys me. He is so idiotically infatuated with Mrs.


Norman. And she is Gavine's mother, I never can forget
that."
Gavine Norman soon arrived, and Sidney went down to
Lovelace's Cottage with some curiosity, to see Jockie's
bosom friend. The frost still held. Sidney herself was
grateful to it. Austin was much more at home, and his
mother rejoiced accordingly. Mrs. Norman took long walks;
she did not hide her disappointment at the hunting ending
so soon. Major Urquhart wandered down to her cottage
about every other day. Sidney wondered as she walked if
her uncle were down there now. But she was overtaken by
Austin, whose steps were bound the same way.

They were both shown into the tiny drawing-room,


where mother and daughter were sitting. Mrs. Norman was
writing at her davenport; Gavine was sitting by the fire
reading. She looked up as they entered, and Sidney was
struck at once by her face. She was dressed in a dark red
gown. The colour suited her. She had a very white skin; her
soft, dusky black hair was parted in the middle, it fell away
in ripples over her ears, and a thick plait encircled her head.
Her eyes were dark blue, and a steady, rather sombre light
seemed to glow in their depths, whilst thick eyebrows and
very long curved lashes lent a touch of heaviness to her
otherwise fragile and delicate oval face. Her nose was
straight and sensitive, her lips had a wistful droop at the
corners, but her square, determined chin, and broad
intellectual brow showed that she had mental force and
ability.

Mrs. Norman was her usual gay charming self. She


greeted Sidney warmly, her eyes welcomed Austin.

"How kind of you, Miss Urquhart! Let me introduce my


big daughter. She quite frightens me by her size, but time
flies, and she has grown much since I last saw her. I must
get accustomed to take the back place when I have her with
me."
Gavine made no reply. She dropped her book, and sat
silently listening to the chatter around her. When talk got on
the frost, and the signs of it yielding, Sidney left Austin to
Mrs. Norman, and turned to the girl.

"I have heard so much about you from Jockie, that I


have longed to meet you," she said.

Gavine smiled, and when she smiled, her face was


beautiful.

"Jockie is a dear; she sees no fault in her friends."

"Have you seen her yet?"

"Yes; she came over yesterday. We are going to take a


long walk together to-morrow if fine."

"Do you hunt?"

"I have never been on horseback in my life."

"I was wondering if you would find it dull here. But I


expect you have resources."

"I never want to kill time," said Gavine, looking at


Sidney with glowing eyes; "it is too precious for that."

"I hear you are a great reader."

"I love it—as a relaxation."

Sidney began to wonder if she were priggish or in


deadly earnest.

Her mother turned round at that moment.


"Mr. de Cressiers is asking whether you skate, Gavine.
He says the ice is bearing."

"Yes," she said a little indifferently. "I have skated up in


the north."

Austin looked across at her with some eagerness.

"We are going to open our grounds to-morrow, for we


have some big fish-ponds which are in first-rate condition.
You will come, won't you? We'll adjourn to the house for
lunch."

"I don't think she has any skates with her," said Mrs.
Norman slowly.

"That doesn't matter, we will turn out ours. I know we


have a lot of odd pairs. And you'll come too, and if you don't
know how to skate, I will teach you."

He turned an adoring eye upon the young widow.


Gavine regarded him gravely for a minute, then she said to
Sidney:

"Will you be there, Miss Urquhart?"

"I—I hope so, and Jockie must come too."

"I thought Jockie taught in the morning."

"Oh, I dare say Miss Pembroke will give Chuckles a


holiday."

"I should hope she won't, for Jockie's sake," Gavine said
earnestly. "When she does undertake a thing, she ought to
stick to it. That was her great fault at school, she was
brilliantly clever, but would never persevere."
"And perseverance comes easily to you?" Sidney asked
with a smile.

"Yes, I lack in initiative. I can't start things, but when


once started I'm all right. Jockie is a very good starter."

Sidney was interested in the girl; not so much in what


she said, but in the smouldering fires which shone in her
deep blue eyes, and in the changing expression of her face.
She said to her:

"You take life earnestly, Miss Norman."

"Who wouldn't? Oh, Miss Urquhart, it is a tremendous


thing, isn't it? There is so much to gain, and so much to
lose."

Her lips quivered. She touched the volume she had


been reading.

"These are some essays by Carlyle, and Macaulay, and


Emerson. I am only dipping into them, but they make you
think, don't they? And they make me long to work. I have
had so much time to think and to read. I am simply
yearning to do—"

"You must come and see me, and we will have a good
talk together," said Sidney, being almost startled by the
vehemence in the girl's tone.

Mrs. Norman had caught a bit of the conversation.

"Ah, Miss Urquhart," she said, laughing. "It is the young


people who teach us in the present day. They are so wise,
so full of enthusiasm, so intense in what they feel and hope
for. When I listen to my girl, it reminds me of my hot-
headed youth, and I pray she may not be awakened so
quickly as I was."

Gavine looked at her mother.

"How were you awakened?" she asked gravely.

"My dear child. You will know how later on. Life has
hardly touched you yet. You are only on the threshold."

"You talk as if you were Methuselah!" said Austin. "How


can you be so absurd?"

"Am I absurd!"

Mrs. Norman lowered her voice and turned her head


away from Sidney and her daughter. "My dear boy, Gavine
makes me feel a frivolous doll; she is the essence of lead.
Her heaviness and stolid matter-of-fact sense have a most
depressing effect upon me. I feel bound with chains when
she is in the room. And when we go about together, I have
the awful desire to shock her. Isn't it dreadful of me? For
she's such a good earnest girl, and her good worthy aunts
are so much more to her than her own mother is. She is
never happy till she gets away from me. And I assure you
she would be scandalised if she saw me tumbling about on
the ice to-morrow. She thinks I ought to be dressed up in a
lace cap and spectacles and sit over the fire knitting shawls
for the poor. That is her ideal mother!"

Austin laughed. He could not help it; but he felt a little


uncomfortable. Gavine's good looks impressed him. He was
inclined to talk to her, and when presently her laugh rang
out at one of Sidney's speeches, he moved across the room
and joined them.

"What is the joke?"


"I was only describing some of our characters here,"
said Sidney, and then she rose to go.

Austin stayed behind. He did not offer to accompany


her, but she was accustomed to that now. She went home
wondering what kind of intercourse there was between
mother and daughter.

"I don't know which I pity most," she said to herself.


"The girl wants more gaiety in her, the mother less. But I
like the looks of Gavine, and hope I shall see something of
her."

There was no skating the next day. A sudden thaw set


in. Sidney did not see either of the girls for some time, as
her father was in bed with a slight attack of bronchitis, and
she hardly left the house. The Major was in very low spirits
as he watched Mrs. Norman riding off to the meets with
Austin. He shut himself up in his workshop, and growled at
everyone who came near him.

Gavine and Jockie took long walks together every


afternoon. One day Gavine's face was unusually grave.

"Jockie, dear, I must go back to the aunts. I can't stay


here."

"Why?" Jockie's horrified face made Gavine smile.

"I don't think mother wants me."

"She never has," said Jockie indignantly; "but I want


you. Have you had a row? You needn't mind telling me."

"Oh, it never comes to that. Mother never loses her


temper, you know. I sometimes wish she did. But I annoy
her. I blurt out truths which are best not expressed, and I
can't understand what I'm expected to say, and what I am
not. Major Urquhart came yesterday, and mother asked him
to tea to-day, as there was no meet anywhere. Mr. de
Cressiers happened to come in this morning, and wanted us
to go motoring with him this afternoon. Mother accepted,
and, thinking she had forgotten, I said quickly: 'Oh, we
can't do that, can we, mother? You asked Major Urquhart to
tea to-day, and you asked him to come early, for you had
not seen him for such a long time.'

"Now why should that speech of mine be such a crime?


Mother carried it off all right at the time, but she was most
annoyed with me afterwards. She told me I was like an
awkward child, had no manners, and she really thought I
was better in my 'northern wilds' than in decent society. I
honestly think I am. I hate the chitter-chatter of society. It
leads to nothing, and I am living a lazy idle life here. It
doesn't suit me. I have been accustomed to attend to my
two aunts, and do some sick-nursing. There is nothing to do
here, and Jockie, dear—it is not her fault. We have lived our
lives apart since I was four years old, but mother has no
more affection or feeling for me than that stone.'"

She struck a wayside stone with her stick as she spoke,


but there were tears rising in her blue eyes. Jockie linked
her arm in hers.

"No, dear, you two will never hit it off together, never!
Has your mother disappointed the old Major again?"

"I took up a note to him, asking him to dinner instead.


She is out now motoring, but I did not want to go. It is no
fun to me."

"No. You're gooseberry!" said Jockie.

Gavine stared at her.


"I sometimes think I am very dense. What do you
mean? You don't know mother as I do, Jockie. She is friends
with everybody. She always has been, but never anything
more."

There was an anxious look in Gavine's eyes, and Jockie


did not enlighten her further. They began to talk of "work,"
which was Gavine's favourite topic.

"I want to work somewhere in London, Jockie. If only


mother would give me a little more money, I could do it. I
should like to go to one of those settlements, where
everybody is doing something for others. There is so much
to be done, so few to do it. I don't want to hide my talents
in a napkin. It is the next life that matters, not this. We are
in a school of discipline here. We must make efforts towards
heaven, and I do not want to fail in getting there, do you?"

"I don't know," said Jockie soberly. "I don't incline


towards the strenuous disciplined life. I have often told you
so. I want to enjoy everything as it comes. It always seems
to me that in preference you cross the street to the shady
side. Now I like to walk in the sun."

"I want to keep my body in subjection," said Gavine,


with earnest shining eyes, "so that it will not be a hindrance
to me when I am working. I sometimes think I should like
to join a sisterhood. I was very nearly doing it a year ago,
and then I promised someone I would not."

"Who?" Jockie asked bluntly.

A soft pink colour stole into Gavine's cheeks.

"Oh, it's only someone who has gone abroad."

Jockie's eyes twinkled.


"I'm waiting to be told his name."

But Gavine kept her own counsel and would say no


more.

CHAPTER XI
AUSTIN'S ENLIGHTENMENT

CHRISTMAS came with its festivities; and though


Thanning Dale was not a very gay neighbourhood, there
was enough going on to keep everyone occupied. Sidney
was freer now that her father was convalescent, and she
and Jockie pressed Gavine into their service, for there were
parish teas and entertainments and a Christmas tree for the
children. And somehow or other, Austin was always with
them. Sidney noticed that he did not mention Mrs.
Norman's name, and there was something in his feverish
gaiety and forced ring of cheerfulness, that made her
wonder if anything had gone wrong in their friendship.

She was too busy to seek for his confidence; and,


indeed, there was little opportunity for quiet talk between
them. Gavine and he were good friends, but nothing more.
Jockie made fun of him, laughed at him, and contradicted
him whenever she got a chance, but Austin held his ground
with her, and Sidney listened to their gay talk and laughter
with relief of mind. This was Austin in his wholesome boyish
state again. What had occasioned the change?
She was enlightened at last. Austin was seeing her
home after the village children's prize-giving and treat. It
was a windy night.

"Take my arm," he insisted; "you are tired out with the


romping. Are you my friend still, Sid?"

"Is it my way to change?" Sidney said quietly.

"Oh, no, but women are beyond me. And it's my fate to
have my ideals shattered."

"You'd better tell me," Sidney suggested.

"I want to. But you're the only one on earth I'll speak to
about it; for I know you won't crow, and say 'I told you so.'
It's only—only I've had a nasty shock about that little
woman. I really can't bring myself to tell you, but it's all up
between us, and I'm going to clear out for a bit. The mother
condescended to say that I could have a holiday, and I'm off
to Cairo next week. I know a fellow going out, and I've fixed
it up with him."

"That is very wise of you," said Sidney, hardly knowing


what to say.

"You don't ask questions? But I'll try to tell you. She
sent me a letter intended for your uncle. 'Pon my honour, I
feel sorry for her, but she began, 'My dearest,' and dashed if
I didn't read it right through before I twigged she had put it
in the wrong envelope. And she told him not to be angry
with her, for the 'poor boy' would not keep away, and she
could not make him see how he bored her. Then she went
on to hint that if this poor infatuated youth still frequented
her cottage, the Major must take into consideration that
there was her girl ready to amuse him, and young people
liked each other's company. Now what do you think of that?
After assuring me that the Major was a daily purgatory to
her. It bowled me over, I can tell you."

"I am sorry for you," Sidney said, "but you would take
no warnings. She has wanted to keep you both as friends."

"Oh!" cried Austin with a little groan. "I tell you it has
been a pretty stiff eye-opener to me! I sent the letter back
to her, and told her she need not trouble to send the letter
she originally meant for me, and, of course, I haven't been
near her since. She wrote an abject apology, saying she
could explain if I called, but mum's the word! And I shall be
out of it soon. And I'm jolly well cured of a leaning towards
your sex, Sid. If it were not for you, I'd never believe in a
single woman again. By George! How she's taken me in,
and befooled me. Do you think the Major got my letter?"

"No, I don't think he did," said Sidney, stifling a sigh. "I


almost wish he had. I don't think his eyes will ever be
opened."

"I shouldn't like to tell you of the jeers and jibes she
has flung at his courting. But she may pull it off with him.
And I say, do befriend that poor girl; she does have a time
of it."

"Do you mean Gavine?"

"Yes, I put my foot in it several times trying to stand up


for her. Don't think I'm a broken-hearted youth, Sid. I tell
you, I rode by the cottage on purpose to-day, and whistled
merrily. But all the same, I shall be glad to turn my back on
this place for a time."

When they parted, Sidney looked at him gravely.


"Austin, you ought to be thankful to have had your eyes
opened. She never would have made you happy."

But when she got indoors she said to herself:

"And now I feel that Uncle Ted is doomed. She will not
let him escape her."

And that feeling hovered about her like an angry


looming cloud. The more cheerful her uncle became, the
more anxious she was. The uncertain future seemed to
menace her. It needed all her faith and fortitude to go about
with a bright and smiling face.

About the same time Monica had a visit from Mrs.


Norman. She was the first to inform her that Austin was
leaving home for a time.

"It is an immense relief to me. In fact, I may tell you in


confidence that it is chiefly through my instrumentality that
he is going. It was bad enough to have him in and out of
my house all hours of the day, before Gavine came to me. I
was sorry for the boy. He seemed so lonely and miserable,
so misunderstood at home. But you know a woman's pity is
sometimes mistaken for something else, and I found he was
presuming too much, so I had to stop it. You see, I do not
mind what people say of myself. I am quite impervious to
idle gossip. I think if one has a clear conscience one is
perfectly indifferent to the wagging of tongues. But I have
my daughter to think of now, and I was afraid if he was
never out of our house, that her name might be a subject of
gossip. A woman is always supposed to have matrimonial
plans, if she has a pretty daughter. So I wrote him a letter
which has effectually quenched him. I have acted rightly,
have I not? I believe you would have done the same, had
you been in my place."
Monica could not but agree. She did not know how
much went on at Lovelace's Cottage; she was too busy a
woman to meddle much in her neighbours' affairs; but
when Sidney came next to see her, she told her what she
considered were "the rights of the story." Sidney listened,
and felt hopeless and helpless to put the matter straight, so
did not try to do so.

"We had better take Mrs. Norman at her own valuation,


Monnie. It will be only a fret and annoyance to ourselves if
we don't. How do you like her daughter?"

"I have hardly seen her, but she happens to be coming


to tea this afternoon. Will you stay to meet her? Jockie is
going to bring her in here after their walk."

"Yes, I shall like to stay. Father and Uncle Ted have


actually gone out driving together. It is some business they
want to do with their lawyer in Pegborough."

Something in Sidney's tone made Monica look at her


sharply.

"Nothing wrong, I hope?"

"Nothing, I believe; but I am full of fears, Monnie."

"And I am afraid Austin's absence will not mend


matters."

"We shall see. How is Chuckles? Do you think his


Sunday lessons are impressing him?"

"He is still mad on building. Some of his remarks are


very funny. He asked Aunt Dannie if God had not nearly
finished building her yet; and when she said she did not
know, he informed her that when the top stone was put on,
God would take her to heaven. I really enjoy listening to
him. I will bring up the subject at tea-time, and you will see
for yourself if he does his teacher credit."

Sidney gave a little sigh.

"It is so easy to talk, so difficult to live. Life is very


perplexing, Monnie."

"But you don't find it perplexing," said Monica with a dry


little smile. "You tell me that your foundation is so sure that
you are never affected or moved by difficulties and troubles.
Isn't there a verse in the Psalms, 'I shall never be moved'?
That is your position, is it not?"

Sidney looked wistfully out of the window.

"It ought to be my realisation." Then a light came into


her eyes. "But it doesn't say 'I shall never be shaken'; only
'never be moved.' It's the buffeting I find so trying. It isn't
the building's fault when the wind and storm attack it."

She visibly brightened up.

"I like to tease you sometimes," said Monica, smiling at


her.

"Yes, you brace me up, Monnie. I feel very slack at


present. I have all kinds of presentiments, and I honestly
don't like living near anyone who is not friendly to me. I see
the girls are coming in. They are a handsome couple, are
they not?"

Chuckles was dancing up the garden after them. He was


in a very dirty overall, and brandished a trowel in one hand.
Monica carried him off to make him tidy for tea; the
girls joined Sidney in the cosy sitting-room. Both were
genuinely glad to see her there.

"We've been up the Beacon," said Jockie. "It's our


favourite walk. Oh, dear! I shall be glad of some tea.
Talking and climbing are rather exhausting, and our tongues
have been hard at it. Gavine says she's going away soon;
isn't it a shame of her, when I want her so much?"

"Does your mother want you to leave her so soon?"


Sidney asked, turning to Gavine.

"Yes," the girl answered simply; then she added, with a


little effort: "We have been talking together, and mother is
quite willing that I shall go and do something. You see, my
aunts do not really need me. They told me so when I came
away; they thought my duty was to stay with my mother."

"And is it not?" asked Sidney.

"Not when it is her wish that I should leave her," said


Gavine quietly. "I am going up to London to stay with a
clergyman and his wife; he has a curacy in the slums
somewhere, and they say they can give me plenty of work.
She was at school with me. Jockie knows her."

"Yes; she's not a bit like a clergyman's wife; much too


fond of dress and society," said the outspoken Jockie; and
then she laughed.

"I expect people say much the same of me—not a bit


like a clergyman's cousin; much too fond of fun. I tell
Gavine we can give her plenty of parish work, can't me,
Miss Urquhart? But I know what she wants—a more
rigorous, self-denying life; she wants to live in a kind of cell
and be short of food and fires, and go out to early services
at six o'clock in the morning, and make herself very ill and
bad-tempered."

Monica came back at this juncture, leading a very clean


Chuckles by the hand. Then she asked them to come to a
sit down tea in the dining-room.

When they were at the table, Sidney asked the small


boy what he had been doing with himself all the afternoon.
His eyes gleamed.

"I've been building a real house, me and Mr. Rudge


togever."

"It's a labourer's cottage being erected," said Monica.


"You can fancy that he discovered it very quickly."

"Yes," said Chuckles, with a self-satisfied nod. "Mr.


Rudge holded my hand and showed me how to put the
mortar atween the bwicks. He was very like God this
morning. I tolded him so."

Gavine stared at the child with her grave eyes.

Jockie giggled.

"How was he, Chuckles?" she asked. "Tell us."

"He helped me to build," said Chuckles with great


gravity. "That's what God does to me every day, doesn't He,
Miss Sid?"

Monica looked across at Sidney with a smile.

Chuckles was never better pleased than when he had


got an audience. He lifted up his voice and continued:

"I'm just about middle built now."


"What do you mean?" asked Jockie.

"Well, fust, you see, God builded me a baby; that's


when I couldn't do nuffin myself, and God builded me all by
Hisself. Then He went on building me taller, a little bit at a
time, until I was builded into a boy; now I've got to build a
little myself, and build all kinds of bwicks on me; and God
just hold His hand over mine so I don't make no mistakes.
He's building me up gooder every day."

"Oh," said Monica, "I hope I see the goodness coming,


Chuckles; but you don't grow in that direction very fast."

Chuckles cocked his head on one side like some saucy


sparrow.

"The bwicks don't stick always," he asserted;


"sometimes they tummles off; 'specially the bwick this week
—it's to do what you're told quick, and it won't stick."

"Did you teach him all this, Miss Urquhart?" asked


Gavine, a light leaping into her eyes.

"Yes," said Sidney; "we're doing a course of building


every Sunday, and we find out a lot about it, don't we,
Chuckles? We're all builders—of a sort."

"Of a sort," repeated Monica slowly.

"When I'm builded into a man, I shall begin to build


other people," asserted Chuckles.

And the important tone with which he said it made the


girls laugh.

They had a merry tea. Jockie was overflowing with fun


and spirits, but when the time came for them to go, she
said to Sidney:

"Will you let Gavine walk a part of the way with you. I
have promised to be home in time for the choir practice;
and she's dying to talk to you."

Sidney was only too delighted. She had wanted to see


more of Gavine, but seemed to have had no opportunities
with her.

When they were left alone together Gavine said:

"What a quaint child that boy is. He seems such a


mixture. Jockie says he is a regular pickle, and yet he talks
like a little saint."

"He is far from a saint," said Sidney; "but real religion is


as natural to children as their daily food. They only want
teaching, and Chuckles has a bright intelligence and a vivid
imagination. I love having him on Sunday."

"I want to be a builder," said Gavine earnestly. "I really


think I'm going to get my wish. But I wish I could think with
Chuckles that God would put His hand over mine to prevent
mistakes."

"He will if you ask Him," said Sidney earnestly. "Only, if


you want to be a successful builder, be sure about your
foundation."

"How do you mean?"

"Chuckles and I began with the stories of the houses on


the rock and sand. Don't build on sand; it will only court
disaster. It says in the Bible: 'Other foundation can no man
lay than that is laid, which is Jesus Christ.'"
"Oh, do talk to me, Miss Urquhart," said Gavine in a
voice which vibrated with earnest longing. "Jockie said you
would. I want to know so much. I want to get satisfied."

Sidney gave a little happy laugh as she tucked Gavine's


arm within hers.

"You poor child! Talking is easy, but the right talk is


what we want. And I don't quite know where you are."

"I don't know where I am myself," said Gavine, "except


that long ago I felt that life would not bring me sunshine, so
I determined that it should bring me work. But I seem
thwarted on all sides. Now, it is true, I feel light is coming,
but it has been obtained at tremendous cost. My mother
has been long in coming round to my point of view, and she
has told me definitely that, as I wish to take up work, I
must look upon it as my profession or vocation in life, and
never count again upon her house as my home. It makes
me feel bitter, but it is happier to have a complete
understanding between us. We haven't an idea in common.
She says I am my father's daughter, and she never cared
about him; it is no good to pretend she did. All my life I
have been hoping she would have me with her, and let me
take care of her and work for her. It has been one series of
hopes and disappointments. Now it has come to a crisis,
and it is better so. I can learn to stand alone.

"Many girls would glory in such freedom. I have £80 a


year of my own now, for I was twenty-one last week. But
though work is coming to me, it has not as yet made me
really happy, and I am wondering if it will. I suppose it
doesn't matter about being happy, does it? But you carry it
about in your face. I was watching you to-day. I know you
feel sad sometimes. I—don't laugh—but Jockie and I love
looking at your face. It is so beautiful, and has so many
changes in it. Before Chuckles began to talk, conversation
was a little effort to you, and your thoughts were far-away;
then, when he began to talk about building, light and
gladness crept into your eyes and the merry ring into your
voice. You looked as if you were brimming over with
happiness, and I felt as if I was outside a house in the cold
and rain, looking into a cosy firelit room. Do help me."

Quick tears had sprung into Sidney's eyes. She


exclaimed impulsively:

"You shall not go to London till you know how you can
be happy, dear. You will want the deep fountains of content
inside you to tide you over all the sin and misery that you
will see in London's slums. I wish you could come back to
dinner with me this evening. Do you think you could? We
will send you home."

Gavine's eyes looked very wistful.

"I wish I could. But I don't know whether mother would


like it."

"Oh, yes, she will. I will send a note down and say I
have kept you; that is the best way. Now let us go on
talking. I wonder what foundation you have under your
feet? I mean what do you rely on when things go wrong?
What is your aim, your hope, your inspiration?"

Gavine's young pulses throbbed, yet her eyes were


troubled.

"I think I'm like a watch without a mainspring. I have


great ideas of what can be done, what ought to be done,
and of what I mean to do, but I don't seem to get the
power to do it. I'll confess to you, Miss Urquhart. Jockie has
been giving me sick poor to go and see in the village. I've
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like