(Download pdf) Learn Engineering With Lego A Practical Introduction To Engineering Concepts Grady Koch full chapter pdf docx

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 69

Learn Engineering with LEGO: A

Practical Introduction to Engineering


Concepts Grady Koch
Visit to download the full and correct content document:
https://ebookmass.com/product/learn-engineering-with-lego-a-practical-introduction-to
-engineering-concepts-grady-koch/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...

(eTextbook PDF) for Engineering Your Future A


Comprehensive Introduction to Engineering 9th Edition

https://ebookmass.com/product/etextbook-pdf-for-engineering-your-
future-a-comprehensive-introduction-to-engineering-9th-edition/

Engineering Fundamentals: An Introduction to


Engineering, SI Edition Saeed Moaveni

https://ebookmass.com/product/engineering-fundamentals-an-
introduction-to-engineering-si-edition-saeed-moaveni/

Engineering Fundamentals: An Introduction to


Engineering, 6th Edition Moaveni Saeed

https://ebookmass.com/product/engineering-fundamentals-an-
introduction-to-engineering-6th-edition-moaveni-saeed/

Engineering Your Future: A Comprehensive Introduction


to Engineering 9th ed. Edition William C. Oakes

https://ebookmass.com/product/engineering-your-future-a-
comprehensive-introduction-to-engineering-9th-ed-edition-william-
c-oakes/
Introduction to Bioplastics Engineering 1st Edition
Ashter

https://ebookmass.com/product/introduction-to-bioplastics-
engineering-1st-edition-ashter/

Engineering Software Products: An Introduction to


Modern Software Engineering Ian Sommerville

https://ebookmass.com/product/engineering-software-products-an-
introduction-to-modern-software-engineering-ian-sommerville/

Nuclear engineering : a conceptual introduction to


nuclear power Joyce

https://ebookmass.com/product/nuclear-engineering-a-conceptual-
introduction-to-nuclear-power-joyce/

Data Engineering with dbt: A practical guide to


building a cloud-based, pragmatic, and dependable data
platform with SQL Zagni

https://ebookmass.com/product/data-engineering-with-dbt-a-
practical-guide-to-building-a-cloud-based-pragmatic-and-
dependable-data-platform-with-sql-zagni/

Introduction to Plastics Engineering Vijay K. Stokes

https://ebookmass.com/product/introduction-to-plastics-
engineering-vijay-k-stokes/
MAKER
I N N O VAT I O N S
SERIES

Learn
Engineering
with LEGO
A Practical Introduction
to Engineering Concepts

Grady Koch
Learn Engineering
with LEGO
A Practical Introduction
to Engineering Concepts

Grady Koch
Learn Engineering with LEGO: A Practical Introduction to Engineering
Concepts
Grady Koch
Yorktown, VA, USA

ISBN-13 (pbk): 978-1-4842-9282-2 ISBN-13 (electronic): 978-1-4842-9280-8


https://doi.org/10.1007/978-1-4842-9280-8

Copyright © 2023 by Grady Koch


This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Susan McDermott
Development Editor: James Markham
Coordinating Editor: Jessica Vakili
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail booktranslations@springernature.com; for
reprint, paperback, or audio rights, please e-mail bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook
versions and licenses are also available for most titles. For more information, reference our Print
and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is
available to readers on the Github repository: https://github.com/Apress/Learn-Engineering-
with-LEGO. For more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Table of Contents
About the Author���������������������������������������������������������������������������������ix

About the Technical Reviewer�������������������������������������������������������������xi

Acknowledgments�����������������������������������������������������������������������������xiii

Introduction����������������������������������������������������������������������������������������xv

Chapter 1: The Hub�������������������������������������������������������������������������������1


Assembling and Charging the Hub������������������������������������������������������������������������1
Controls and Displays�������������������������������������������������������������������������������������������4
Exercise: The Motor Spinner���������������������������������������������������������������������������������8
Activating the Motor��������������������������������������������������������������������������������������11
Project: The Distance Spinner�����������������������������������������������������������������������������12
Using the Distance Spinner���������������������������������������������������������������������������15
Summary������������������������������������������������������������������������������������������������������������16

Chapter 2: Programming��������������������������������������������������������������������17
Using the Robot Inventor App������������������������������������������������������������������������������17
Installing and Updating the App���������������������������������������������������������������������18
The Interface�������������������������������������������������������������������������������������������������18
Connecting the Hub���������������������������������������������������������������������������������������20
Updating the Hub Operating System�������������������������������������������������������������21
Exploring the Hub Screen������������������������������������������������������������������������������22

iii
Table of Contents

The Program Design Process������������������������������������������������������������������������������24


Writing the Algorithm�������������������������������������������������������������������������������������25
Drawing the Flowchart����������������������������������������������������������������������������������25
Coding in Word Blocks����������������������������������������������������������������������������������������28
Writing Comments�����������������������������������������������������������������������������������������33
Coding in Python�������������������������������������������������������������������������������������������34
Downloading and Running Code�������������������������������������������������������������������41
Debugging and Troubleshooting��������������������������������������������������������������������42
Project: The Dance Floor��������������������������������������������������������������������������������43
The Word Blocks Code�����������������������������������������������������������������������������������48
The Python Code��������������������������������������������������������������������������������������������53
Summary������������������������������������������������������������������������������������������������������������57

Chapter 3: Building Elements�������������������������������������������������������������59


Liftarms���������������������������������������������������������������������������������������������������������������59
Straight Liftarms��������������������������������������������������������������������������������������������61
Bent Liftarms�������������������������������������������������������������������������������������������������62
Rectangular Liftarms�������������������������������������������������������������������������������������63
Connecting Liftarms��������������������������������������������������������������������������������������������64
Pins����������������������������������������������������������������������������������������������������������������64
Axles and Bushes������������������������������������������������������������������������������������������66
Exercise: Triangular Structures���������������������������������������������������������������������������68
Connectors����������������������������������������������������������������������������������������������������������76
Exercise: Symmetric Objects������������������������������������������������������������������������������76
Project: Mechanical Linkages�����������������������������������������������������������������������������85
The Universal Joint����������������������������������������������������������������������������������������85
The Eccentric�������������������������������������������������������������������������������������������������92
Summary������������������������������������������������������������������������������������������������������������96

iv
Table of Contents

Chapter 4: Gears���������������������������������������������������������������������������������99
Gears in the Robot Inventor Set��������������������������������������������������������������������������99
Spur Gears���������������������������������������������������������������������������������������������������101
Beveled Gears���������������������������������������������������������������������������������������������102
Speeding Up Rotation, or “Gearing Up”�������������������������������������������������������������104
Slowing Down Rotation, or “Gearing Down”�����������������������������������������������������110
Exercise: The Many-Geared Machine����������������������������������������������������������������111
Direction of Rotation������������������������������������������������������������������������������������120
Calculating Gear Ratio for More Than Two Gears����������������������������������������120
Exercise: The Torque Demonstrator������������������������������������������������������������������122
Lowering Torque by Gearing Down��������������������������������������������������������������126
Raising Speed by Attempting to Raise Input Torque (and Failing)���������������134
Exercise: The Compound-Gear Spinner�������������������������������������������������������������136
Project: Two-Speed Transmission���������������������������������������������������������������������146
Summary����������������������������������������������������������������������������������������������������������154

Chapter 5: Mechanisms��������������������������������������������������������������������157
Exercise: The Ratchet����������������������������������������������������������������������������������������157
Exercise: The Cam���������������������������������������������������������������������������������������������162
Exercise: The Differential����������������������������������������������������������������������������������167
Assembling the Differential�������������������������������������������������������������������������168
The Differential Demonstrator���������������������������������������������������������������������171
Exercise: Turntables������������������������������������������������������������������������������������������180
Project: The Mechanized Cannon����������������������������������������������������������������������195
Summary����������������������������������������������������������������������������������������������������������213

v
Table of Contents

Chapter 6: Motors�����������������������������������������������������������������������������215
Speed and Angle�����������������������������������������������������������������������������������������������215
Exercise: The Speed and Angle Demonstrator��������������������������������������������������217
Controlling Motor Speed in Word Blocks�����������������������������������������������������220
Controlling Motor Speed in Python��������������������������������������������������������������221
Setting Motor Angle in Word Blocks������������������������������������������������������������222
Setting Motor Angle in Python���������������������������������������������������������������������224
Exercise: Understanding Torque and Stall���������������������������������������������������������225
Exercise: Powering a Vehicle with a Tank Drive������������������������������������������������228
Building the Tank�����������������������������������������������������������������������������������������229
Programming the Tank��������������������������������������������������������������������������������239
Exercise: Using a Motor As a Rotation Sensor��������������������������������������������������243
Building the Position Mimic�������������������������������������������������������������������������244
Programming the Position Mimic����������������������������������������������������������������248
Project: The Rear-Wheel Drive Car��������������������������������������������������������������������251
Building the Rear-Wheel Drive Car��������������������������������������������������������������252
Programming the Rear-Wheel Drive Car�����������������������������������������������������272
Summary����������������������������������������������������������������������������������������������������������278

Chapter 7: The Motion Sensor����������������������������������������������������������279


Tilt Angle: Yaw, Pitch, and Roll���������������������������������������������������������������������������279
Exercise: Programming with Tilt Data���������������������������������������������������������������283
Measuring Tilt Angles in Word Blocks����������������������������������������������������������284
Measuring Tilt Angles in Python������������������������������������������������������������������285
Exercise: The Cat Sound Generator�������������������������������������������������������������������286
The Word Blocks Code���������������������������������������������������������������������������������290
The Python Code������������������������������������������������������������������������������������������292

vi
Table of Contents

Other Motion Sensor Measurements: Gyro Rate and Acceleration�������������������294


Project: The Up Pointer��������������������������������������������������������������������������������������296
Building the Up Pointer��������������������������������������������������������������������������������297
Programming the Up Pointer�����������������������������������������������������������������������302
Summary����������������������������������������������������������������������������������������������������������306

Chapter 8: The Distance Sensor�������������������������������������������������������307


Exercise: The Ultrasonic Tape Measure�������������������������������������������������������������307
Building the Ultrasonic Tape Measure���������������������������������������������������������308
Programming the Ultrasonic Tape Measure������������������������������������������������311
Project: The Scanning Cannon��������������������������������������������������������������������������313
Building the Scanning Cannon��������������������������������������������������������������������314
Programming the Scanning Cannon������������������������������������������������������������320
Summary����������������������������������������������������������������������������������������������������������331

Chapter 9: The Color Sensor�������������������������������������������������������������333


Exercise: The Brightness Beeper����������������������������������������������������������������������334
Building the Brightness Beeper�������������������������������������������������������������������334
Programming the Brightness Beeper����������������������������������������������������������337
Project: The Color Sorter�����������������������������������������������������������������������������������340
Building the Color Sorter�����������������������������������������������������������������������������341
Programming the Color Sorter���������������������������������������������������������������������375
Summary����������������������������������������������������������������������������������������������������������382

Appendix A: Parts Lists���������������������������������������������������������������������385

Index�������������������������������������������������������������������������������������������������409

vii
About the Author
Grady Koch is the author of several books
about LEGO and the founder of the website
hightechlego.com. He has a Ph.D. in Electrical
Engineering and 35 years of experience as a
research engineer at NASA Langley Research
Center, where he has built optical and laser
instruments that have been flown on aircraft
and orbited the Earth. He has three patents
in the field of lidar for studying the atmosphere and is the author or
contributor of over 200 journal and conference publications. Throughout
his career, Dr. Koch has mentored many interns and found that students
sometimes need a little help in making the transition of what they’ve
learned in classroom to real-world practice. These ideas of applying
knowledge to practice are incorporated into his LEGO books.

ix
About the Technical Reviewer
Vishnu Agarwal has more than seven years of experience in the field
of LEGO robotics. He is the founder of ROBO-G, a robotics and STEAM
education service provider. He is also the “Mentor of Change” for Atal
Tinkering Lab at the Vidyashilp Academy. Vishnu has successfully coached
teams in the World Robot Olympiad and First LEGO League competitions.
Many students and teachers alike have learned STEAM concepts using
LEGO education from Vishnu’s courses and coaching. And he has
presented a research paper on Teaching Programming and Computational
Thinking to Elementary Level Children Using Lego Robotics Education Kit
at T4E at IIT, Bombay.

xi
Acknowledgments
My continued appreciation goes out to the LEGO Group for their
phenomenal building toy. To me, LEGO is much more than a toy. LEGO
can be used and enjoyed on many levels for many uses. Sure, it’s a toy,
and a rather engaging one that attracts and brings together people of all
ages. But LEGO is also an excellent tool to teach science and engineering
concepts, which I’ve used with my own kids and is a motivation for this
book. Another motivation for this book is to show LEGO as a tool for
invention.
To convey the concepts and inventions in this book, I’ve included
step-by-step instructions for building exercises and projects. I made the
building instructions with a combination of BrickLink Studio (bricklink.
com) and LDraw (ldraw.org). BrickLink Studio is a computer-aided
design (CAD) utility for building with virtual LEGO that evolved from
Digital Designer developed by the LEGO Group. LDraw, originally built by
James Jessiman, is another LEGO CAD package that has been expanded
on by many dedicated people. There are several interfaces to the LDraw
foundation. Among these interfaces, I used MLCAD (mlcad.lm-software.
com) developed by Michael Lachmann, and LDCad (melkert.net/LDCAD)
developed by Roland Melkert. To create building instructions from CAD
models, I used the LIC utility (bugeyedmonkeys.com) developed by Remi
Gagne and LPub3D (sourceforge.net/projects/lpub3d) based on the work
of Trevor Sandy, Kevin Clague, Leonardo Zide, Travis Cobbs, and Peter
Bartfai.

xiii
Acknowledgments

My appreciation is extended to Apress, whose books I’ve been enjoying


for many years. So it’s been a thrill to write for such a great publishing
company for a third LEGO book. My thanks are given to Jessica Vakili and
James Markham, who did fantastic work in editing. Part of writing a good
book is to have an insightful technical reviewer, and Vishnu Agarwal came
through in this regard.
Finally, let me thank Melissa, Kirsten, and Elias for supporting my
indulgences in LEGO and building strange devices. LEGO is stuffed and
scattered throughout our home, for which I apologize and promise to
clean up one day.

xiv
Introduction
This book explores engineering concepts by building examples with
LEGO. Fundamental principles are presented of how machines work and
why they are built the way they are. There are two reasons why it may be
interesting to learn these engineering concepts. The first reason is for the
simple joy of tinkering with machinery. It can be a captivating experience
to contemplate the inner workings of a machine that can be held in the
hand to take apart, modify, and reassemble. LEGO makes such tinkering
easy and, nowadays, sophisticated with the interplay of mechanical,
electronic, and computer aspects found in MINDSTORMS Robot Inventor
or SPIKE Prime.
The second reason is that the basic designs explored in this book
can serve as a basis for customized inventions. One of the exercises
or projects may provide an idea for a new project or solve a particular
design challenge for a device. For example, examples are included for two
fundamental drivetrains for a robot or vehicle: tank drive and rear-wheel
drive. Building these two fundamental approaches provides the experience
to decide on which is better suited to a customized project. Drivetrains are
just one example of basic designs covered in this book. Building exercises
are also laid out to build structures, gear systems, sensors, computer
control, and mechanisms to spin, push, point, and shoot.
All of the parts used in the exercises and projects of this book are
in the MINDSTORMS Robot Inventor set, also referred to by the part
number 51515. With this set, there’s no need to buy any other parts. The
electronic controller, called the Hub, for Robot Inventor is programmed
by connecting to a host computer or smart device that the user provides,
from which an app is run to control and program inventions. The Robot

xv
Introduction

Inventor app works on a wide variety of computers and smart devices


including iOS, macOS, Fire OS, Windows, and Android devices. Once the
app is installed on a computer or smart device, the code described in this
book can be entered for each particular exercise or project. Code is also
available for download on GitHub.
Most of the projects in this book make use of the Hub, which is
programmed to control inventions. No prior experience is assumed in this
book with programming, with a step-by-step explanation given of how
computer programs are implemented from initial concept to code. Two
programming languages are used, Word Blocks and Python, to work with
the Hub; there is the option of using whichever language is of interest.
Beginners, persons of more casual interest, or users of a smart device
without a keyboard may prefer the Word Blocks version of the programs.
But readers interested in advanced programming may find Python of
greater interest. Many users, especially kids, start learning how to write
programs with Scratch, which is quite similar to MINDSTORMS Word
Blocks, and so it should be a quick adaptation to use the programs in this
book. But many kids of middle-school age want to learn Python, but have a
hard time. So another reason programs in this book are in both languages
is to help the transition from Scratch to Python.
LEGO makes a product called SPIKE Prime as part of its Education
product line primarily meant for use in schools that is a sort of cousin to
Robot Inventor. The programs in this book will work in SPIKE Prime with
no modification needed. Many parts are the same between SPIKE Prime
and Robot Inventor, with just a difference in color. However, some of the
more specialized parts are included in one set but not the other. So an
owner of SPIKE Prime set will have most, but not all, of the parts used
in this book. The few extra parts needed can be found individually on
aftermarket parts dealers such as bricklink.com. All of the parts used in
each exercise and project are described by part number in the Appendix,
in case a particular part is needed.

xvi
Introduction

This book explores the three specialties of software (Chapters 1 and 2),
mechanical (Chapters 3–5), and electrical (Chapters 6–9) engineering.
The electrical engineering chapters also incorporate the software and
mechanical aspects of the earlier chapters. Each chapter has quick
building exercises plus a larger concluding project. Topics in each chapter
are described here in brief.
Chapter 1, “The Hub,” describes working with the Hub, the device
that controls motors and sensors. Instructions are given on how to power
the Hub and navigate its front panel controls. The Hub can be used as a
stand-alone controller, without the need to get into programming, to spin a
motor, and then use a Distance Sensor to control the speed of the motor.
Chapter 2, “Programming,” advances to the next level of using the
Hub by programming it from the Robot Inventor app. The design of a
program is described as starting from a problem statement to developing
an algorithm. Implementation of an algorithm with a flowchart makes the
final step of coding easier to understand. There are two options for the
coding language, Word Blocks and Python, both of which are presented.
Building projects include controlling the displays of the Hub, followed by a
miniature dance floor decorated with light and sound effects.
Chapter 3, “Building Elements,” starts an exploration of mechanical
engineering concepts by touring the many parts in the Robot Inventor set
used to build structures and machines. The basic structural element is the
liftarm, with connections made by pins, axles, and connectors. Liftarms
come in a variety of shapes, and the reasoning behind these shapes will
become apparent with building exercises. These building exercises include
topics in strong structures, symmetry, and linkages.
Chapter 4, “Gears,” unlocks the principles of using gears to change the
speed, torque, and direction from a rotational power source, like a motor.
Speed and torque are critical parameters in designing robots and vehicles,
and the relationship between speed and torque is explored. Moreover,
building exercises show how to manipulate gear configurations to get the

xvii
Introduction

desired speed and torque. The concluding project of the chapter builds a
two-speed transmission.
Chapter 5, “Mechanisms,” explores fundamental machines for taking
action to lift, spin, push, nudge, drive, or shoot. Building exercises include
the example mechanisms of a ratchet, cam, differential, turntable, and dart
shooter. The final chapter project combines several mechanisms to build a
steerable cannon.
Chapter 6, “Motors,” begins topics in electrical engineering with
learning how to use motors, including programming to set speed or go
to a specific angle. Practical limitations of torque and stall on motor
performance are explored. Motors are integral in providing motion to
robots and vehicles, and so two fundamental ways of providing steerable
motion of tank drive and rear-wheel drive are presented in building
examples.
Chapter 7, “The Motion Sensor,” works with the sensor built into the
Hub to measure tilt and orientation. The meaning of yaw, pitch, and roll is
explored by building a motion alarm. Another exercise experiments with
orientation of the Hub to trigger different sounds. The chapter project
combines the Motion Sensor with a motor to build a machine that always
points toward the ceiling, no matter the roll angle.
Chapter 8, “The Distance Sensor,” incorporates distance measurement
into inventions. The first exercise is to build a handheld tool to replace an
old-fashioned tape measure. This sensor can also detect when an object
comes close, which is put into use to modify the cannon in Chapter 5 to
automatically detect and fire upon a target.
Chapter 9, “The Color Sensor,” adds the capability to work with
light, measuring the brightness of light and the color of objects. Building
experience starts with a beeping tone generator that changes pitch
depending on brightness of light. The concluding project combines ideas
from earlier chapters in the book to combine the Color Sensor, motors, a
linkage, and structures to sort liftarms by color.

xviii
CHAPTER 1

The Hub
The Hub, pictured in Figure 1-1, is a small computer that powers
and controls inventions. This book will show how to combine it with
sensors and motors to explore many engineering concepts. This chapter
introduces the Hub, including how to power it up, charge it, and navigate
the controls on its front panel.
While the Hub is meant to be programmed, as will be done throughout
this book, it can also control sensor- and motor-based projects by using
the front panel of the Hub alone, without any programming needed. This
chapter includes two such projects that spin a motor at various speeds.

Assembling and Charging the Hub


The Hub comes in the Robot Inventor (and SPIKE Prime) set in two
pieces: the hub and a battery, as pictured in Figure 1-2. The battery snaps
into the Hub, with little need to ever remove the battery, except perhaps
for swapping out batteries if a spare is urgently needed. The battery is
rechargeable and likely needs a fresh charging when first used. Charging
is done by the USB cable that comes in the set, with the small connector
(called a USB Mini) plugging into the Hub and the large connector (called
a USB A) plugging into a computer or USB charger. These USB connections
are shown in Figure 1-3. If plugged into a computer for charging, the Hub
powers on with a musical chirp and the front panel lights up, and the host

© Grady Koch 2023 1


G. Koch, Learn Engineering with LEGO, https://doi.org/10.1007/978-1-4842-9280-8_1
Chapter 1 The Hub

computer sounds a notice that it has found new hardware—this can be


ignored for now. The Hub can take a few hours for a full charge. There’s
a way to check for the level of battery charge, which will be described in
Chapter 2. While charging, the features of the Hub can be explored as
described as follows.

Figure 1-1. The Hub is a small computer for controlling sensors


and motors

2
Chapter 1 The Hub

Figure 1-2. The Hub is powered by a removable battery

3
Chapter 1 The Hub

Figure 1-3. The Hub battery is charged by a USB connection

Controls and Displays


The Hub has several buttons, displays, and a speaker built into it that serve
to turn on the Hub and control various features. These control features on
the Hub can be for either input or output. Input functions are the buttons
on the front panel, while output functions are displays and a speaker.
There are four buttons on the front panel of the Hub used to control
functions, pictured in Figure 1-4. The center button is the power control,
which, when pressed, turns on the Hub. Another press and hold of at least
three seconds turns off the Hub. The center button also executes a program
that has been loaded into memory, as will be described in Chapter 2. Next
to the center button are the left and right buttons, used to scroll through
programs that are stored in the Hub’s memory. With no programs loaded

4
Chapter 1 The Hub

into the Hub, these buttons don’t show any effect yet. But the left and right
buttons also serve to increment motor settings, as will be used later in this
chapter. Another button is the Bluetooth button, which is pressed to set up
a Bluetooth link. Bluetooth is a type of radio link between computers.

Figure 1-4. The four input buttons on the Hub

Two displays are part of the Hub, pictured in Figure 1-5. One display is
a 5 × 5 matrix of yellow LEDs, which are used in Chapter 2 to make shapes,
numbers, or letters. But this matrix display is also involved in indicating
the status of the Hub. For example, after powering up the Hub, a play
symbol (a triangle like on an old-fashioned tape recorder) lights up on the
matrix display to indicate that things are working OK. The brightness of the
5 × 5 LED matrix can be changed, but its color can only be yellow.

5
Chapter 1 The Hub

Figure 1-5. Two outputs on the front panel of the Hub are a 5 × 5
LED matrix of yellow lights and a ring around the center button

The other display on the Hub is a colored ring around the center button.
When the Hub is first powered, this ring is a white color. In Chapter 2,
options will be presented to change the color of the center button light.
As buttons are pressed, various beeping and musical sounds are
emitted from a speaker on the side of the Hub, shown in Figure 1-6. Every
press of a button gives a sound through the speaker to provide feedback
that a button has been pressed. The different button functions have
different sounds. For example, when the Hub is turned on by pressing
the center button, there is a series of accelerating clicks followed by a
musical chirp.

6
Chapter 1 The Hub

Figure 1-6. Sound output is from a speaker on the side of the Hub

As shown in Figure 1-7, all six sides of the Hub have holes for inserting
LEGO pins. There are several kinds of pins, which are discussed in detail in
Chapter 3. Larger LEGO building elements can be attached to these pins,
as will be seen in the upcoming projects of this book.

7
Chapter 1 The Hub

Figure 1-7. Pins can be inserted into opening on all the sides
of the Hub

Exercise: The Motor Spinner


The Robot Inventor and SPIKE Prime sets come with a variety of motors
and sensors. These motors and sensors can be quickly identified by their
attached cables, which plug into one of the six ports on the Hub. These
motors and sensors can be programmed to do all sorts of sophisticated
functions, but the Hub also allows control of a motor or sensor by simply
plugging it in, without any programming. This feature can be used to
activate a motor or change the speed of its rotation. The Motor Spinner in
Figure 1-8 demonstrates this plug-and-play feature.

8
Chapter 1 The Hub

Figure 1-8. The Motor Spinner uses the Hub to control a motor

Instructions to build the Motor Spinner are given as follows. All of the
parts for this project, and all the projects in this book, are part of the Robot
Inventor set.

9
Chapter 1 The Hub

10
Chapter 1 The Hub

A
 ctivating the Motor
To control the Motor Spinner, the first step is to power up the Hub by
pressing the center button. The Hub should chirp, and the matrix should
display the play symbol. After another press of the center button, a row of
lights next to port E should appear with the LED light closest to the port
coming on, along with a square of light moving from right to left. This lit-up
row indicates that the Hub has recognized the motor. Since port E is used
for motor connection, this row of lights is lit up. If, instead, a different port
was used, its associated row would light up. Port E is used in this exercise
for convenient routing of the cable and in preparation for the following
project. A press of the left button once should activate the motor to spin

11
Chapter 1 The Hub

slowly in a clockwise direction. Pressing the right button once should stop
the motor. Another press of the right button will make the motor spin
slowly counterclockwise. Motor rotation can be sped up by pressing the
right button up to ten times. The left button will slow the motor down.
With repeated pressing of the left button, the motor will stop, then begin
to speed up in a clockwise rotation. When done using the motor, pressing
the center button will go back to the home menu, represented by the play
symbol on the LED matrix display.

Project: The Distance Spinner


Sensors can also be read by the Hub without programming, much like a
motor can be controlled by just plugging it into the Hub. The Distance
Spinner project in Figure 1-9 shows how to include a sensor in a project
and uses all the techniques of this chapter. The Distance Spinner spins a
motor at a speed that depends on how close the Hub is to an object. The
closer the object, the faster the motor will spin. Building instructions are
given following Figure 1-9. The Distance Spinner is an extension of the
Motor Spinner, so the following instructions start after completion of the
Motor Spinner in Figure 1-8.

12
Chapter 1 The Hub

Figure 1-9. The Distance Spinner will spin faster when objects are
closer to the sensor

13
Chapter 1 The Hub

14
Chapter 1 The Hub

Using the Distance Spinner


After powering up the Hub with a press of the center button, a second
press of the center button will activate the Distance Spinner. The lowest
row of the LED matrix display should light up on the front panel, indicating
that the Hub has recognized the connection of both the Distance Sensor
and motor. If an object, such as a wall, is within about 2 m distance away,
the motor will spin. A good test is to stand about 2 m away from a wall
with the Distance Spinner facing the wall. In moving closer to the wall, the
motor spins faster. When done working with the Distance Sensor, a press of
the center button will return the user back to the home play symbol on the
Hub’s LED matrix.

15
Chapter 1 The Hub

S
 ummary
This chapter introduced the Hub, the computer heart of the Robot Inventor
or SPIKE Prime set. The Hub uses a rechargeable battery for power, which
can be charged by a USB connection. There are a number of displays on
the Hub, including LEDs, as well as a speaker for audio output. Input to
the Hub includes several buttons to navigate the front panel control and
displays. The center button on the Hub turns the Hub on and off. The Hub
offers simple functionality for the motors and sensors without a need to
program the Hub, and two quick building projects showed the use of the
Hub with the Distance Sensor and a motor. Of course, the Hub is meant to
be quite versatile with programming, which Chapter 2 delves into.

16
CHAPTER 2

Programming
As described in Chapter 1, the Hub can control motors and sensors, with
some functionality under control of the Hub’s front panel. But the real
power of the Hub is that it can host computer programs for sophisticated
control of inventions. This chapter will show how to program the Hub.
Moreover, the process will be described of how to design and build
computer programs, starting from a basic idea to the finished product of
code. Programs are coded in the Robot Inventor app on a smart device or
computer, then downloaded into the Hub’s memory. The Hub can then be
disconnected from the host device to work independently. Exercises and
the project in this chapter will explain how to install and use the Robot
Inventor app, navigate through its functions, and write code in both the
Word Blocks and Python computer languages.

Using the Robot Inventor App


Programming the Hub is done in the Robot Inventor app, which can be
hosted on a smartphone, tablet, desktop, or laptop computer. Programs
developed in the app get downloaded and stored in the Hub’s memory, so
programs can then be run without connection to a host device.

© Grady Koch 2023 17


G. Koch, Learn Engineering with LEGO, https://doi.org/10.1007/978-1-4842-9280-8_2
Chapter 2 Programming

Installing and Updating the App


Robot Inventor can typically be downloaded from the app store on a
particular device, such as the Microsoft Windows Store on a PC computer
or the iOS App Store for an Apple Product. A search in the app store for
“LEGO MINDSTORMS Robot Inventor” should find the app. Alternatively,
the app can be found on the LEGO website at www.lego.com/en-us/
themes/mindstorms/app. Running the app should bring up a home screen
like Figure 2-1. The first time the app is run, and every so often afterward, a
notice may pop up on the screen indicating that an update is available, and
directions on the screen will make the update. This update is from LEGO
to improve features of the app and fix small problems that are discovered
as more people use the app.

The Interface
The largest feature on the home screen, shown in Figure 2-1, is the five
example robots that are featured with the Robot Inventor set. Clicking one
of these robots will show instructions for building the robot. These robots
are fun to build and a good introduction to LEGO MINDSTORMS, but the
main interest in this book is on the icons at the bottom of the home screen
for home, community, projects, and code.

18
Chapter 2 Programming

Figure 2-1. The home screen for the Robot Inventor app

• Home: Returns to the home screen

• Community: Shows extra projects in addition to the


five example robots

• Projects: Shows a list of saved programs

• Code: Opens a new screen in which to write programs

Clicking Code accesses the code screen, as in Figure 2-2. There’s a lot
going on in this screen, which will be covered in detail in this chapter.

19
Chapter 2 Programming

Figure 2-2. The code screen in the Robot Inventor app

Connecting the Hub


The Hub gets connected to the app by clicking the small icon in the
upper-right corner of the screen. (This icon looks like the Hub’s outline.)
The screen shown in Figure 2-3 should then appear to prompt the type of
connection: USB cable or Bluetooth.
The USB cable comes with the Robot Inventor set and serves two
functions of connecting the Hub to the app and charging the Hub’s battery.
With successful connection, the icon of the Hub in the upper-right corner
now has a green dot next to it.
The second option for connection is by Bluetooth, which is useful if
the host device doesn’t have a USB port, such as smartphone or many
tablet computers. Bluetooth is a type of radio communication, so it doesn’t
require a cable. Clicking the Bluetooth tab at the top of the Connect
Hub screen will bring up instructions for making the connection, which
involves pressing the button on the Hub’s front panel.

20
Chapter 2 Programming

Once successfully connected, the app returns to the code screen in


Figure 2-2. However, a prompt may appear to update the Hub, as described
in the following section.

Figure 2-3. The Connect Hub screen presents two options for
connecting the Hub to the Robot Inventor app

Updating the Hub Operating System


After the Hub is connected to the Robot Inventor app for the first time, a
notice is likely to appear to prompt for an update of the Hub’s operating
system, such as in the screenshot in Figure 2-4. This update will make the
Hub run better, with improvements and bug fixes that LEGO releases every
few months or so. Clicking start update will proceed with loading the
update onto the Hub. This update for the Hub is different from the update
for the app, but in either case the app will give a pop-up menu when it’s
time for either update.

21
Chapter 2 Programming

Figure 2-4. The Robot Inventor app will prompt the user when an
update is needed to the Hub’s operating system

Exploring the Hub Screen


Once the Hub is connected to the Robot Inventor app and needed updates
are done, the Hub icon again should appear in the upper-right corner of
the code screen. Clicking this icon will bring up a diagnostic view of the
Hub, as reproduced in Figure 2-5. Information at the top of the screen
includes the Hub’s operating system version and the level of the battery’s
charge. The purple oval in the upper-right corner will disconnect the Hub
from the device running the app. Disconnecting the Hub in this way avoids
potential problems with data transfers that could occur if the USB cable
was pulled out or Bluetooth abruptly shut off.
Two tabs near the top of the screen are noteworthy: Hardware and
Programs. The Hardware tab includes a picture of the Hub, as well as
any sensors or motors connected to it and any measurements coming
from them. In the example in Figure 2-5, a motor is connected to port A
and a Distance Sensor connected to port B. In addition to any external
components connected to the Hub, the Hardware tab also displays

22
Chapter 2 Programming

readings from the built-in Motion Sensor, which indicates the tilt angle,
orientation, gyro rate, and acceleration of the Hub. Chapter 7 explores this
Motion Sensor in detail, but a quick experiment can be done now by tilting
the Hub and watching the yaw, pitch, and roll angle values change.

Figure 2-5. The Hub screen

The Programs tab lets the user view and manage the files stored on
the Hub. It shows the 20 storage slots available for programs, as well as the
name, size, date of creation, and date of last modification of all programs.
Programs can also be deleted from this screen, which may occasionally be
desired to clear memory space as new programs are developed.
The last important item on the Hub screen is the three-dot icon at the
top-right edge. Clicking this feature will bring up a submenu that allows
renaming the Hub, resetting the Hub, and updating connected motors.
If using more than one Hub, for instance, in working with a school group
or team, different names for the Hub can avoid confusion. “Reset hub” is
a quick way to delete all the programs on the Hub, so care must be taken
to be sure such action is actually desired. “Update motors” starts a set of
instructions that checks the motors’ operation and calibration, notably

23
Chapter 2 Programming

related to their reference zero home position (a feature described in


Chapter 6). If motors are used often, they can develop problems, which
can likely be fixed with this update feature.
Now that a tour of the Hub screen is complete, it’s time to develop a
program. Clicking the X in the upper-right corner of the Hub screen should
return the user to the code screen, such as in Figure 2-2.

The Program Design Process


The code screen, shown in Figure 2-2, is where a program is entered.
But in implementing a program, entering the code is the last of three
parts. The first two parts are algorithm development and flowcharting,
which are written out separately from the code screen, such as in a
word processing app or even on paper. The reason not to just jump right
into coding is that the whole picture of a computer program has to be
understood. It’ll actually save time and effort to write out the big picture
first, in words, of the steps involved in the program. These steps are called
an algorithm. Then an intermediate component of flowcharting will help
translate algorithm steps into code. In the professional world of computer
programming, more time is spent debugging and fixing computer code
than in writing code. But by taking the time up front to design a computer
program with a logical process from an algorithm to a flowchart to code,
time and trouble can be saved in the long run. The following sections walk
through the process of each of the three parts of the algorithm, flowchart,
and code. Then, in the rest of the book, the three parts of the algorithm,
flowchart, and code will be used in building projects. As a first example
of the program design process, the following exercise has the Hub to
spell out a name, beep the speaker, and light up the center button with a
specific color.

24
Chapter 2 Programming

Writing the Algorithm


An algorithm is a set of step-by-step instructions to solve a problem. To
start creating an algorithm, the problem or goal should be understood and
written out. For example, a goal to achieve could be the following:

Display my name, emit a beep from the Hub’s


speaker, and light up my favorite color on the Hub’s
center button. Keep my favorite color lit up for ten
seconds.

Next, the sequence of steps needed to achieve this goal is written out:

1. Start the program.

2. Display the text “Grady” on the Hub’s front panel.

3. Beep the Hub’s speaker.

4. Set the center button color to blue.

5. Wait for ten seconds.

6. Stop the program.

Of course, the reader can change the code to their own name and
favorite color.

Drawing the Flowchart


A flowchart is a graphical representation of an algorithm and serves as an
intermediate component in implementing the final product of code. The
reason to use a flowchart is that it shows how the algorithm flows and how
algorithm steps may be interrelated. This flow and interaction of steps
matches how to represent instructions in computer languages. Flowcharts
use shapes to represent different types of algorithm functions, such as
in Table 2-1. These functions include starting and stopping a program,

25
Chapter 2 Programming

manipulating data, asking for input, providing output, making decisions,


and repeating steps with a loop. A flowchart can be sketched on paper for
a quick solution or by using the shapes built into most word processors.
There are also many apps that are meant for quickly drawing flowcharts.

Table 2-1. Flowchart Shapes and Functions


Shape Name Description

Flow Direction of algorithm steps


direction
Terminal Beginning or end of an algorithm (usually the first
and last steps of an algorithm)

Process Instruction to change the value, form, or location of


data

Input/ Sending of data into or out of the algorithm


output
Decision Question to offer choices in the path of the
algorithm

Looping Repetition of a set of steps

Delay Pause in the algorithm for a specified duration of


time

Connector Joining of flow paths coming from different


directions

The flowchart is a sequence of these shapes joined by arrows. As


an example, Figure 2-6 shows a flowchart to match the name and color
algorithm laid out in the previous section.

26
Chapter 2 Programming

Figure 2-6. Flowchart for the name and color algorithm

Writing the Program


Now that a flowchart is written, it’s easy to see the commands needed
to enter into the code. The Hub can be programmed with two different
computer languages in the Robot Inventor app: Word Blocks or Python.
Word Blocks is the default language that comes up when the Robot
Inventor app is opened to the code screen, such as in Figure 2-2.
Commands are entered in Word Blocks by dragging them from the left side
of the screen into the center, linking blocks from top to bottom. To program
in Python, there’s an extra step from the code screen to open a new screen
for entering commands, described in a section later. Python is entered
by typing lines of code. Deciding on which language to use depends

27
Chapter 2 Programming

on several factors. If using a smartphone or tablet computer without a


keyboard, then Word Blocks is probably a better choice. Using Python
requires a lot of typing, which is rather tedious without a keyboard. Word
Blocks is easier for a beginner to use and has more built-in commands
in the Robot Inventor app. Python is oriented toward more experienced
users. The benefit of Python is that it more directly interacts with the
Hub, so it can be used for more advanced inventions. Python is widely
used outside MINDSTORMS, such as for programming microcontrollers,
sophisticated computer programs, and scientific applications. So
MINDSTORMS or SPIKE Prime can be a good introduction to building up
skill with Python.
In the following sections, and throughout this book, code will be
presented in both Word Blocks and Python. This way, the reader can
choose whichever computer language is preferred or whichever language
is better suited to the type of smart device or computer.

Coding in Word Blocks


Word Blocks is the computer language that appears by default in the code
screen, such as in Figure 2-2. Programs are built by clicking a command
from the left side of the screen and dragging it to the center part of the
screen to link below an existing Word Block. There are many Word Blocks
to choose from. They’re arranged in pallets of various colors on the left
side of the screen, as shown in Figure 2-7, to group the blocks into families
that, for example, work with particular motors or sensors. At the bottom
of this column of colored circles, there’s an icon that looks like an outline
of two stacked Word Blocks, which will access Word Block features used to
perform advanced functions.

28
Chapter 2 Programming

Figure 2-7. Families of Word Blocks are organized by color

The code screen has the first block preloaded of when program starts,
which starts the program and represents step 1 of any algorithm and
the first step in a flowchart. Figure 2-8 shows the insertion of the second
command of the flowchart in Figure 2-6 by selecting write from the left
side of the screen and dragging it underneath when program starts. The
text to get written is entered by clicking the text oval within write and
typing in the desired text.

29
Another random document with
no related content on Scribd:
distance without speaking. The silence was growing apparent when
Fanchon broke it.
“So that’s the girl who’s in love with you!” she said abruptly.
William reddened.
“Don’t say that!” he exclaimed hastily. “I never said that!”
She laughed, and he grew angry.
“Listen, Fanchon, I’ve got something to say to you!”
She gave him a sidelong look.
“Dis donc,” she said.
“I wish you wouldn’t smoke on the street. American girls never do it.”
“Street?” Fanchon looked about her vacantly. “Ciel, do you call this a
street?”
“Yes, I do. It’s a street in my home town,” replied William doggedly.
“I’m sorry you don’t like it. We’ve got to live here, you know.”
“Here?” She looked at him now, her lip trembling. “Toujours?”
Suddenly she began to laugh, softly at first, and then wildly,
hysterically, dashing tears from her eyes.
William, nonplused, simply stared. He no longer understood her.
VII
The difficulties of St. Luke’s Church had been very great. The
interest on the debt was heavily in arrears, and the Ladies’
Association, selected from the active female members of the
congregation, had labored early and late to find its share of the
money. There had been fairs and tableaux and even Mrs. Jarley’s
waxworks, but none of these things had done more than collect a tax
on the members of the church. Outsiders had been absolutely shy,
and the members were beginning to find a hole in both sides of their
pockets. They made dainty articles for sale—splashers and
whiskbroom holders and aprons—and dressed dolls and baked
cakes, and then went to the bazaar and solemnly bought them back
again. It had become a little wearing on sensitive nerves and
pocketbooks.
Finally, as a brilliant climax, old Mrs. Payson conceived the idea of a
concert that would be fine enough to coax the reluctant dollars from
the Presbyterians and the Baptists, the Methodists and the
Universalists and the Catholics—in fact, an entertainment that would
draw the town. The Sunday-school hall, a gift from Dr. Barbour’s
father, was large enough to seat almost a theater audience, and it
had a fine platform, furnished with footlights, and wide enough not
only for a grand piano but for a number of famous singers.
The question of paying the singers had, at first, staggered the ladies,
but Mr. Payson had finally come to their relief. As the wealthiest
member of the congregation, he usually had to make good the
deficiencies, and he proposed to pay for some first-class performers
if the ladies of the association would guarantee that they could fill the
hall at good prices—five dollars for the best seats, two-fifty for the
second best, and one dollar and fifty cents for children. If they sold
every seat at these rates, they could cover the deficit, and Mr.
Payson would escape another and heavier levy.
It was Virginia Denbigh who finally achieved it. She had taken hold
with the ardor of youth and the executive ability which Colonel
Denbigh proudly claimed was an attribute of his family. The thing
was done. The pianist, Caraffi, was engaged and one fine singer,
besides a first-rate orchestra from out of town.
“No one,” said Virginia, “will pay to hear our own people, even if they
play better.”
The wisdom of this diagnosis of the popular sentiment was
demonstrated by the sale of tickets. As the night drew near, it
became apparent that not a seat would be vacant. The invitation to
young Mrs. William Carter was a brilliant coup. The town was
anxious to see her and to hear her; the announcement that she
would sing—probably a French ballad—had rushed the last seats up
to a premium. For William Carter’s sudden marriage abroad had
aroused no small amount of gossip.
The hall began to fill early. Virginia Denbigh, who had come down
with her grandfather, glanced over it with a thrill of pleasure.
“We’re going to make it,” she said softly, “every cent! Look, grandpa,
they’re selling the last seats for five dollars—away back, too!”
“Scandalous!” retorted the colonel. “Can’t see a thing there but the
top of Mrs. Payson’s bonnet, and there’ll be a draft from the door.
You’ve got no conscience, Jinny. Make them sell those for a dollar.”
She laughed, patting his arm.
“You go and take your seat; I’ve got to be back in the reception-room
to meet the singers.”
The old man nodded, making his way to a front seat, and looking
about him interestedly as he went.
The congregation was there in force, with the rector and his wife well
down in front; but, for the first time in the history of their church
entertainments, the rest of the townspeople appeared there, too.
Colonel Denbigh counted three ministers and half a dozen deacons.
The black coats and white neckties were well forward, and there
were three old ladies, patrons of the church, already seated, with
their ear trumpets at their ears. On the rear benches the young
people were congregated, and, as the hall filled, the young men of
the town stood about in groups in the aisles and behind the last
seats.
But it was a very solemn gathering, after all.
“Sunday-school meeting,” thought the colonel. “Hard-shelled Baptists
and Methodists on one side, and High-church Episcopalians and
Roman Catholics on the other. Needs something a little sprightly to
make ’em sit up and take notice. I wonder——”
He looked about him curiously, and then he saw Mr. Carter going
slowly down the aisle, followed by his wife and Emily.
“Hello!” said the colonel. “Didn’t expect such luck. You’ve got the
seat next to me, Mrs. Carter. How are you, Emily?” He glanced
rather sharply at the girl as he spoke, startled by her unusual
appearance, for Emily’s white eyelashes were now a dark brown,
and her nose was whitened. “Bless my soul!” thought the colonel,
and then, to Mr. Carter: “Where’s William and his pretty wife?”
“William isn’t coming,” Mr. Carter replied shortly, seating himself
heavily and feeling of his necktie. “He’s at home, smoking a pipe with
Dan. His wife”—Mr. Carter glanced at the lighted platform, filled with
a grand piano and many palms—“I suppose she’s coming. She
started with Leigh half an hour ago. He’s bringing her.”
“Humph!”
The colonel tried to think of something more to say, but Mrs. Payson
relieved him. She fluttered across the aisle.
“Dear Mrs. Carter, we’re all crazy to hear your new daughter sing!
Judge Jessup says she’s got a lovely voice.”
Mrs. Carter smiled tremulously and blushed.
“Yes,” she said faintly, but with some pride in her voice. “The judge
heard her the other night. She’s—she’s coming with Leigh.”
As she spoke there was a flutter and stir in the audience, and Mrs.
Payson retreated hastily to a front seat. Judge Jessup had just
appeared on the platform with a tall, thin man who wore an
immaculate dress-suit and displayed an amazing head of black hair.
“Ladies and gentlemen,” said the judge in his deep bass, “it’s my
duty and my pleasure to introduce the great pianist, Signor Caraffi.”
Colonel Denbigh led the applause, and for a moment it was
deafening. The pianist, thrusting one hand in the front of his white
satin waistcoat, bowed low. Judge Jessup discreetly withdrew into
the shadow of the palms where—at intervals—the audience
glimpsed white skirts and pink skirts and blue skirts, and two or three
amazing pairs of feet skirmishing behind the foliage and between the
substantial green tubs. But even these things became less diverting
when the hirsute gentleman began to play.
“Oh, how wonderful!” breathed Mrs. Carter with relief.
Colonel Denbigh nodded.
“Looks like a hair-restorer advertisement,” he replied gently; “but he
can play. I reckon it’s genius that makes his hair grow!”
It certainly looked like genius, for he was really a great pianist. For a
while he held the audience spellbound. Splendid music filled their
ears and, in some cases at least, stirred their souls. Even the more
frivolous listeners forgot to make fun of the huge, shaggy head as it
bent and swayed and nodded while the pianist forgot himself and
forgot the world in his conflict with the instrument—a conflict that
always left him supremely master of heavenly harmonies.
Back in the little room behind the platform, Virginia listened and
forgot that she was worn out with superintending it all; forgot that she
still had her anxieties, and would have them until the last number
was successfully rendered, for Mrs. William Carter was next on the
bill, and Mrs. Carter had not come. Not yet! Virginia was waiting for
her, much against her will, for there were two or three operatic
strangers waiting also, and that intolerable man Corwin, Caraffi’s
manager.
Virginia was aware of him, aware of his sleek good looks and his
watchful eyes. Finding them fixed in her direction, she turned her
shoulder toward him, and was thus the first to see the arrival of
Fanchon and Leigh. They came in softly, Fanchon on tiptoe, listening
to Caraffi, and Leigh laden with her wraps and her music-roll, his
young, flushed face turned adoringly toward his sister-in-law.
Virginia could not blame him. It seemed to her that the girl—she
looked no more than seventeen or eighteen—was wonderfully pretty.
For Fanchon had stopped just inside the door, where the light fell full
upon her, and was listening, her head a little bent and her finger on
her lips. She had given her wrap to Leigh, and stood there, a shining
little figure, in white and silver, much décolleté, her slender arms and
her lovely young throat unornamented. Her gown—a Parisian thing,
Virginia thought—clung to her in a wonderful way, like the shining
calyx of a flower; and yet it floated, too, when she moved. Her dusky
hair, her wonderful dark eyes, and the piquant little face, needed no
better frame than the glimpse of starry night in the open door behind
her and the glimmer of shaded lights overhead.
Virginia went forward.
“I’m so glad you’ve come,” she said softly. “Your number is the next
one, Mrs. Carter.”
Fanchon turned to answer, putting out a small, bejeweled hand,
confident and smiling, a sparkling little creature. Then suddenly there
came a change. She stopped short and stood motionless. She
scarcely seemed to breathe. It was as if some force stronger than
her will had arrested her.
Watching her face, Virginia felt the shock of it, without knowing what
it was—fear or hate, or a mingling of both. But Fanchon’s eyes were
fixed on Corwin, and they were no longer soft. It was not the look of
a wild fawn, but of a tigress at bay. Something within, some feeling
as strong as it was extraordinary, transformed her. For an instant she
seemed to flinch, then she stood facing him.
The man, turning as suddenly, saw her. He jumped to his feet.
“Fanchon la Fare!” he exclaimed, and came toward her, speaking
rapidly in French.
Virginia turned away. She did not want to listen, but she heard an
exclamation from Fanchon, and saw her leave Corwin standing, an
odd look on his face.
Leigh, who had been busy with the wraps, turned, saw the meeting
and Fanchon’s face. He dropped his burden and crossed over to her
quickly.
“What did he say to you, Fanchon?” he panted. “If he was rude to
you, I’ll—I’ll thrash him!”
Fanchon laughed a wild little laugh.
“Dear boy!” she said softly, and stroked his hand. “Je t’adore!”
Leigh flushed, his lowering gaze fastened angrily on Corwin, and
Virginia drew a breath of relief when she heard the applause outside.
Caraffi had given them a cheery encore; he was coming off the
platform, and Fanchon must go on. Virginia called to her softly.
“Now, please, Mrs. Carter!” she said.
Fanchon turned and looked at her, saw by her face that Virginia had
seen too much, and her eyes blazed with anger. She took a step
forward and snatched up her music-roll, running her fingers over the
leaves and biting her lip.
“Tell them to play this, please,” she said, with her head up.
Without looking at it, Virginia took it to the director of the orchestra,
glad to escape the little scene. It seemed to her that the air was
charged, and she knew that the wait had been too long already. She
could hear the impatient stir outside.
There was, indeed, a little stir of impatience in the hall. Two or three
young ushers went up and down the aisles with pitchers of iced
water, and the rear seats began to fill up with gentlemen who were
eating cloves. The rest of the audience studied the program,
expectant. “No. 2, Mrs. William Carter, solo,” appeared on it in fine
type.
“My daughter-in-law’s going to sing next,” said Mr. Carter,
remembering the broken engagement and putting out a feeler. “Seen
her yet, colonel?”
“Saw her the other day.” The colonel clasped the top of his cane,
leaning on it, and looking absently at an amazing pair of feet and
ankles that he saw approaching from behind the palms. “She’s
mighty pretty.”
“Think so?” Mr. Carter smiled. “Notice her eyes? Something fawn-
like about them—and velvety. We’ve got to calling her—among
ourselves, of course—‘the wild fawn.’”
At this moment one of the old ladies behind them interrupted. She
tapped Mr. Carter’s shoulder with her fan.
“I do like music,” she said in a loud whisper. “It’s so churchy. I can’t
hear much, but I feel it down my spine. Now, tableaux—well,
sometimes they’re not just the thing, but music for the church, it’s—
it’s safe!”
Colonel Denbigh, overhearing, pulled his mustache. His ear had
caught the first notes of a piece that was not “churchy”; it was far too
light and too fantastic.
“The kind of tune that makes a fellow sit up and take notice,” the
colonel thought. “I wonder——”
He got no farther before he was drowned in applause. A small,
graceful, shimmering figure had slipped out from behind the palms.
Fanchon stood in the center of the stage, her slender arms raised
and her hands clasped behind her head, her eyes bent downward,
the shadowy hair framing a low, white brow, her red lips slightly
parted. If she heard the applause, she did not heed it. She made no
response; she only waited.
Then, as the soft, seductive strains began to fill the hall with music,
she began to sing—softly at first, then rising note by note until her
clear soprano floated upward like the song of a bird. Then, just as
the tension seemed to relax and a deep sigh of pleasure came from
the most anxious of the audience, she began to dance.
Still singing, she danced wonderfully, strangely, wildly. Her skirt,
clinging and shimmering and floating at the edges, clung to her. It
unfolded like a flower as she stepped, and folded again about her
slender ankles, above the marvel of her dancing feet. She swayed
lightly from side to side, her slender body the very embodiment of
grace and motion, as her dancing seemed to be the interpretation of
the music, subtle, seductive, wonderful. So might the daughter of
Herodias have danced before Herod Antipas!
Breathless, the good people in the front rows stared. Movement was
impossible, every sense seemed suspended, everything but the
sensation of amazement. Mrs. Carter looked in a frightened way at
her husband and caught the twinkle in Colonel Denbigh’s eye. Then
she saw her rector mop his forehead with his handkerchief, and she
raised her shamed eyes to the stage. Fanchon was pirouetting on
one toe! Applause had started in the back rows, among the black
sheep, and was running down the side aisles like a prairie-fire when
Mr. Carter abruptly rose.
“Excuse me,” he said roughly to Colonel Denbigh as he clambered
over him. “I—I’ve forgotten something!”
Mrs. Carter half rose and then sank back, pulled down by Emily, but
she seemed to hear, through the spluttering applause, her husband’s
crashing exit.
It might be said that Mr. Carter had the effect of a stone thrown from
an ancient catapult, he went with such bounds and rushes. For a
stout man his performance was little short of miraculous. He covered
the distance to his own door in ten minutes, got out his latch-key,
found the key-hole unerringly in the dark, went in, and banged the
door to with a violence that made the ornaments on the hall mantel
rattle.
The hall was vacant, but he saw a stream of light coming out of the
library, and headed violently for it. William was alone, huddled in an
easy chair, smoking and reading. Mr. Carter came in and shut the
door. Then he advanced on his son with a face of thunder.
“William Henry Carter,” said he, “you’ve married a dancer—a French
dancer!”
William, overtaken by the unexpected, laid down his book and
stared. But his father only roared the louder. He seemed to think that
his son had grown suddenly deaf.
“Do you hear me, sir?” he bellowed fiercely. “You’ve married a—a
dyed-in-the-wool ballet-dancer!”
VIII
It was an hour later when Miranda, looking very dark and showing
the whites of her eyes to an alarming extent, opened the front door
for Mrs. Carter, Emily and Leigh.
“Mist’ Carter says, please, ma’am, yo’ come inter de libr’ry,” said the
colored servitress in a sympathetic undertone.
Mrs. Carter cast an apprehensive look at her daughter.
“I guess you two had better go up-stairs,” she whispered.
Emily nodded, and started for the staircase, but Mr. Carter shouted
from the library:
“I hear you-all out there—come in here!”
They went. Leigh, having forgotten to put down Fanchon’s extra
wraps, brought up the rear, his flushed face just appearing above a
mass of chiffon, lace and fur.
Mr. Carter, striding up and down the room alone, caught sight of his
youngest son first.
“Put down those things!” he shouted. “You look like a dromedary.”
Leigh obeyed, but he straightened himself and stood, sullenly, his
eyes on the ground. His father took no further notice of him.
“I’d like to know if any of you knew what that girl was going to do to-
night?” he demanded fiercely.
Mrs. Carter sank weakly into the nearest chair.
“No, we didn’t! Wasn’t it awful? I was so mortified. The Baptist
minister went out just after you, Johnson, and the rector was as red
as could be. I’m sure I don’t know what he thought!”
“Thought! Where is she?”
“William came for her, and took her out to supper at the inn,” said
Emily in a weak voice.
Like Leigh she stood back, unsympathetic, but she was a little
frightened, too.
“Humph! Took her out to supper, eh?” Mr. Carter thundered. “I reckon
he thought he’d better! I gave him a piece of my mind.”
“Oh, papa! He was as white as a sheet.” William’s mother pressed
her handkerchief against her shaking lips. “He didn’t know, of course.
He wasn’t to blame, dear—you shouldn’t have done it!”
“Wasn’t to blame?” Mr. Carter blazed with wrath. “Didn’t he marry
that ballet-dancer? Didn’t he bring a French ballet-dancer home here
and foist her on a decent, respectable family? He wasn’t to blame,
you say? By Jove, I wish he was small enough to thrash!”
He was still walking up and down. As he swung around, Leigh faced
him.
“She’s a lovely creature!” the boy cried passionately. “That dance
was beautiful—everybody thought so!”
“Oh, Leigh!” gasped his mother. “Dr. Fanshawe was ashamed to look
at it!”
“Old idiot!” cried Leigh. “You’re all making her unhappy—any one
can see it. Nothing but criticism from morning until night—I call it
cruel!”
Mr. Carter stared at him a moment in amazed incredulity. Then he
jeered.
“Hear, hear!” he cried. “Wisdom from the mouths of babes and
sucklings! Do you want to marry a ballet-dancer, too, sir?”
But his son’s blood was up.
“I call it a burning shame!” he cried. “She’s come here, a foreigner,
and she wants to love us, and you’re talking brutally about her. She’s
exquisite, she was to-night, she——”
“Go to bed!” shouted Mr. Carter. “Shut up and go to bed!”
Mrs. Carter rose hastily and gave Leigh a little shove.
“Go!” she whispered. “There, there—don’t aggravate papa.”
Leigh, shaking with anger, yielded ground reluctantly.
“She’s an angel!” he shouted at the door. “I won’t have her abused!”
“Did you marry her!” Mr. Carter asked with fine sarcasm. “Maybe I’ve
made a mistake; I thought it was William.”
Leigh almost choked with indignation.
“He isn’t here—I won’t have her talked about.”
“Go to bed!” thundered Mr. Carter, taking a step forward.
“I——” Leigh began to sputter again, but his mother thrust him out
and shut the door.
“Do speak lower, Johnson,” she sobbed. “I know Miranda listens.”
“I don’t care a hang whether Miranda listens or not,” said Mr. Carter.
“That boy’s an ass—talk about his being a genius!”
“Oh, papa, he’s only eighteen,” said Mrs. Carter deprecatingly, “and
she’s made up to him from the very first.”
“He’s an ass!” repeated Mr. Carter. “And I guess the whole town
knows I’ve got a ballet-dancer——”
He stopped; his eye had suddenly lighted on Emily. She was
huddled in a frightened attitude behind her mother’s chair, and the
light was strong on her face. Her father stared.
“What’s the matter with that child’s eyes?” he demanded suddenly.
“They look like burnt holes in a blanket!”
Mrs. Carter, following his look, suddenly noticed her daughter’s
eyelashes and nose. In an illuminating flash she remembered that
first night in Emily’s room.
“Oh, Emmy!” she gasped. “You’ve painted your eyelashes!”
Emily clung to the back of her chair.
“I had to, mama. They’re horrid and white.”
“Good Lord, that minx is teaching my daughter to paint her face!
Mama, you ought to be ashamed of yourself. Can’t you watch your
own children?” bellowed Mr. Carter, beside himself.
“Emmy, I’m ashamed!” Poor Mrs. Carter sat gasping, her mouth
open. “I never dreamed—what’s that on your nose?”
Emily seized her handkerchief and began to rub the offending
feature.
“It’s nothing, mama—just a little liquid powder.”
“You march up-stairs and wash your face!” said her father. “Hear
me? Don’t let me catch you painting up like that—singing doll!”
Emily began to cry.
“It’s—it’s nothing, papa. Everybody does it. The girls think I look so
nice.”
“Wash your face!” shouted her father. “March up and wash your
face!”
“I don’t want to!” sobbed Emily. “The girls say my eyes look twice as
——”
Mr. Carter seized her by the shoulder and turned her toward the
door.
“Want me to wash your face?” he asked her grimly. “No? I thought
not. Well, then, you march!”
Emily, sobbing loudly, marched. They could hear her stumbling up-
stairs, crying as she went.
“Oh, papa, you were awful!” Mrs. Carter wiped her own eyes. “The
poor child!”
“Do you suppose that I’m going to let my daughter paint her face?”
Mr. Carter fairly bellowed. “I reckon I’ve got enough in a daughter-in-
law! I’ll see to Emmy myself, if you can’t!”
“Johnson, you know I didn’t notice.”
Mr. Carter emitted another roar, and finally threw himself into a chair
and thrust his feet out.
“What did that fool William do?”
“You mean to-night?” Mrs. Carter dried her eyes. “He just met us at
the door. He was so white he scared me, and he took Fanchon off in
a taxi—in that scandalous dress! Said he’d give her a supper out to-
night. I’m afraid you’ve done it this time, Johnson. What did you do to
the poor boy?”
“Poor donkey! I told him what I thought of that woman—called by my
name, too—a woman dressing like one of those yellow East Indian
dancing-girls—that’s what I told him.”
“Johnson!”
“I did! What do you s’pose the congregation thought? By George, it
made me hot all over. Did you see her legs?”
“You mean her stockings? They were a little startling. I told her so
before we started.”
“Startling? My word.”
Mr. Carter relapsed into a terrible silence. Mrs. Carter sat helplessly
looking at him. She was thinking of that dance, that terrible, amazing,
dazzling dance. What a pretty creature, too! That was it; she had
turned William’s head; and Leigh’s and Emily’s, too. Those painted
eyelashes! For a moment Mrs. Carter half laughed.
“It’s funny—I can’t help it, Johnson,” she said, feebly apologetic, as
she met his irate eyes. “I was thinking of Emmy trying to paint her
lashes.”
“I’m glad you think it’s funny,” he retorted hoarsely. “Don’t see the
joke myself. I’ve got too much daughter-in-law, that’s my trouble!”
“Hush! There’s some one now—they’ve come!” Mrs. Carter tiptoed to
the door and listened, coming back, relieved. “No, it’s only Dan.”
“I wish William had Dan’s sense!”
“I wish Dan would marry a nice home girl. It would make things
better,” sighed Mrs. Carter.
“Daniel marry?” Mr. Carter raised his voice again to a roar of
discontent and hopelessness. “Who d’you think Dan could marry?
What kind of a girl d’you think would pick a cripple?”
“Hush!”
Mrs. Carter, very pale, rose and shut the door; but she was too late.
Daniel, suspecting the trouble in the library, had started for his own
room. The stairs were just outside the library door, however, and he
could not help hearing every word his father said. In fact, Mr. Carter’s
irate voice rang out like a trumpet. “What kind of a girl d’you think
would pick a cripple?”
Daniel, clinging to the banisters, ascended more wearily than usual.
The stairs turned at the landing, and he was out of sight when his
mother shut the door. He never used a cane in the house now. He
was well enough to get along with a heavy limp, and he made no
noise as he crossed the upper hall and went into his own room.
Once there, he locked his door, and, crossing to the window, stood
staring out with absorbed and thoughtful eyes.
The night was perfect. A young moon had set, and there seemed to
be, instead, a myriad of stars. He could discern, too, even in the
darkness, the darker profile of the hills, and, nearer at hand, the
clustering beauty of foliage, pierced here and there with the lights of
near-by houses, which shone in the darkness, without any
discernible outlines behind them, like fallen stars. The air was
fragrant and soft, with the sweetness of flowering grapes, familiar
and homelike, amid all that blended early blossoming.
He could hear soft, blurred sounds, too—the hum of insect life, the
piping of frogs, the murmur of the brook that flowed not a hundred
yards away. He stood motionless, thinking, and glad of the cool night
air on his hot cheeks and brow. He felt as if some one had dealt him
a physical blow, and his bruised flesh was still quivering under it.
“What kind of a girl d’you think would pick a cripple?”
Daniel shut his lips sharply over his clenched teeth. It wasn’t a new
idea; it wasn’t even a suggestion. He had known it all along, he told
himself, and yet the bare words were brutal. They seemed to brand
him like hot iron, to shrivel into his shrinking flesh and leave the mark
there.
“Cripple!” He remembered, in a flash, his well days—the days when
he was like other boys, before the fall which lamed him. He
remembered his own young scorn of the weakling and the maimed,
the repugnance that the physically strong often feel toward the
physically disabled. Yet there was nothing disfiguring in his trouble.
He was lame, but he was not twisted; he only halted in his walk. But,
none the less, he was a cripple.
“What kind of a girl d’you think would pick a cripple?”
Daniel stared steadily out into the night, as if the starry darkness
held the answer. One by one he saw the lights go out in the houses
near at hand. Farther off, lights still shone in the town but darkness
grew and grew. Then, far off, he detected a moving thing, saw a leap
of flame and sparks as the smoke belched from the funnel of the
engine. He could trace it coming nearer and nearer, and then he
heard the clamor of its bell at the crossing, strangely distinct at night.
He turned slowly away, lit the lamp on his table, and, going to his
desk, took out the picture of Virginia that he had stolen from the
mantel down-stairs after Fanchon’s attack upon it. He brought it to
the table, and, setting it down beside him, began to write. From time
to time, as he wrote, he glanced up at the young face in the frame,
and felt an exquisite sense of companionship. He was not alone; the
picture kept him company. The pallor of his face, too, gradually
changed, and a slight color rose in his cheeks. He took off his coat
and lit his pipe. Well into the small hours he worked steadily on a
case for Judge Jessup.
He was aware of doors shutting below, aware that sounds gradually
ceased and sleep drenched the household, but he worked on with
the passionate zeal that only an ambitious man can feel—a man who
has no other end in life but to forget himself in the fury of his toil. Yet,
all the while, the young face of Virginia bore him mute company, and
sometimes it seemed to smile upon him.
At daybreak, the fury of his thirst for work slaked, he lifted a haggard
face to the light, glanced at the picture, and stretching his arms
across the table laid his head upon them with a groan. He fell asleep
there from sheer exhaustion and was sleeping when the sun rose.
IX
William Carter took his wife to the inn for supper. He had
appeared at the door of the Sunday-school hall with a taxi and
abruptly bundled Fanchon into it. It was just after her performance on
the stage and before the audience began to disperse. In fact, they
heard the strains of some very churchy music coming from the
orchestra, as if an effort was being made—delayed but strenuous—
to soothe the startled spectators of Fanchon’s amazing dance.
William said nothing. He sat in the dark interior of the taxi with a face
as white as paper, and Fanchon, watching him covertly, saw that the
hand he laid on the window shook. She leaned back in her corner,
twisting a strand of pearls around her throat—a strand that she had
put on after the dance—and watching him; but she said nothing.
She had danced so wildly, indeed, that she was still panting and
throbbing with excitement. She seemed to feel the thrill of the music
even in her feet. It was intoxicating, it was what she loved—the
glamour of the lights, the music, the motion. Her whole body
vibrated, she could scarcely sit still, her feet still moved restlessly.
She loved it!
Yet she felt that heavy silence of her husband, the stiffness of his
body as he sat there, and she had caught a glimpse of his ghastly
face. She bit her lips, staring out into the night, her bosom heaving
passionately. She felt like a beautiful wild bird in a trap.
She stared, too, at the quiet street, with inveterate dislike of its
quietness. She saw the group of loungers in front of the chemist’s,
the belated pedestrians at the crossing. There was a glimpse of
shadowing trees. Pendent branches swept and swayed before feebly
lighted show-windows, where the shades were partly drawn down,
and the infrequent street-lamps shot occasional lances of light
across their dingy way. One such shaft struck on William’s profile
and revealed his tightened lips.
Fanchon wondered. She had not been aware of Mr. Carter’s
catapultic exit, and she did not know how much her husband knew.
Some one must have telephoned him—whom, she could not
conjecture. She shrank away from him a little, thinking, and Corwin’s
face rose before her mind’s eye. She saw again the confidence of
his smiling, mocking eyes, and she shuddered.
William seemed to feel it and gave her a quick look, but said nothing.
The taxi had stopped in front of an old-fashioned inn. It was a long,
low building with a glassed-in dining-room, built to accommodate the
stream of motorists who had begun to tour the mountains and scatter
gold and gasoline in their wake.
Into the new dining-room—a plain, bare place with rows of white-
covered tables and a few lean palms on pedestals—William
conducted his wife. Half a dozen negro waiters came forward. He
selected one he knew, chose a remote table, and gave his order for
supper.
“I suppose you want wine?” he said shortly to Fanchon—almost the
first words he had addressed to her.
She shrugged, slipping off her wraps and amazing the other diners
with the marvels of her costume.
“Mais non,” she replied indifferently. “I’m heated; I never drink wine
when I have danced.”
William, who was giving his order, stopped short a moment, his eyes
down, and she saw him pant like a man short of breath. But in
another moment he had despatched the waiter with his order and
drained his glass of water.
“Mon Dieu!” said Fanchon, watching him with dark, mysterious,
brooding eyes. “How can you? Iced water—it’s bad for your liver!”
“Drat my liver!” said William hoarsely. Then he leaned across the
table, his eyes raised to hers at last and spoke in a low, even voice
for her ears alone. “What have you been doing, Fanchon?”
She had never seen that look in his eyes before, and the blood
rushed back to her heart. She could not answer for a moment; her

You might also like