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

Programming Arduino: Getting Started with Sketches (Tab) Monk pdf download

The document provides information about the book 'Programming Arduino: Getting Started with Sketches' by Simon Monk, detailing its content, structure, and purpose for beginners in programming Arduino. It covers various topics including Arduino hardware, C language basics, functions, input/output, and Internet of Things programming. The book aims to simplify the programming process and is suitable for those with no prior programming experience.

Uploaded by

poenkurane
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
10 views

Programming Arduino: Getting Started with Sketches (Tab) Monk pdf download

The document provides information about the book 'Programming Arduino: Getting Started with Sketches' by Simon Monk, detailing its content, structure, and purpose for beginners in programming Arduino. It covers various topics including Arduino hardware, C language basics, functions, input/output, and Internet of Things programming. The book aims to simplify the programming process and is suitable for those with no prior programming experience.

Uploaded by

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

Programming Arduino: Getting Started with

Sketches (Tab) Monk pdf download

https://ebookmass.com/product/programming-arduino-getting-
started-with-sketches-tab-monk/

Explore and download more ebooks at ebookmass.com


We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmass.com
to discover even more!

Programming Arduino: Getting Started with Sketches, Third


Edition Simon Monk

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

Programming Arduino: Getting Started with Sketches 3rd


Edition Simon Monk

https://ebookmass.com/product/programming-arduino-getting-started-
with-sketches-3rd-edition-simon-monk/

Programming Arduino Next Steps: Going Further with


Sketches 2nd Edition Simon Monk

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

Programming the Raspberry Pi, Third Edition: Getting


Started with Python Simon Monk

https://ebookmass.com/product/programming-the-raspberry-pi-third-
edition-getting-started-with-python-simon-monk/
Programming the Intel Galileo: Getting Started with the
Arduino -Compatible Development Board Christopher Rush

https://ebookmass.com/product/programming-the-intel-galileo-getting-
started-with-the-arduino-compatible-development-board-christopher-
rush/

Programming the Photon: Getting Started with the Internet


of Things Rush Christopher.

https://ebookmass.com/product/programming-the-photon-getting-started-
with-the-internet-of-things-rush-christopher/

Programming With STM32: Getting Started With the Nucleo


Board and C/C++ Donald Norris

https://ebookmass.com/product/programming-with-stm32-getting-started-
with-the-nucleo-board-and-c-c-donald-norris/

Programming the Photon: Getting Started with the Internet


of Things (Tab) Christopher Rush

https://ebookmass.com/product/programming-the-photon-getting-started-
with-the-internet-of-things-tab-christopher-rush/

Hacking Electronics: Learning Electronics with Arduino and


Raspberry Pi, 2nd Edition Simon Monk

https://ebookmass.com/product/hacking-electronics-learning-
electronics-with-arduino-and-raspberry-pi-2nd-edition-simon-monk/
Programming Arduino™
Getting Started with Sketches

SECOND EDITION

Simon Monk

New York Chicago San Francisco


Athens London Madrid
Mexico City Milan New Delhi
Singapore Sydney Toronto
Library of Congress Control Number: 2016938700

McGraw-Hill Education books are available at special quantity discounts to use as


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

Programming Arduino™: Getting Started with Sketches, Second Edition

Copyright © 2016, 2012 by McGraw-Hill Education. All rights reserved. Printed in the United
States of America. Except as permitted under the United States Copyright Act of 1976, no
part of this publication may be reproduced or distributed in any form or by any means, or
stored in a database or retrieval system, without the prior written permission of the
publisher, with the exception that the program listings may be entered, stored, and executed
in a computer system, but they may not be reproduced for publication.
McGraw-Hill Education, the McGraw-Hill Education logo, TAB, and related trade dress are
trademarks or registered 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.
Arduino is a trademark of Arduino LLC.
1 2 3 4 5 6 7 8 9 DOC 21 20 19 18 17 16

ISBN 978-1-25-964163-3
MHID 1-25-964163-5

This book is printed on acid-free paper.

Sponsoring Editor
Michael McCabe
Editorial Supervisor
Stephen M. Smith
Production Supervisor
Pamela A. Pelton
Acquisitions Coordinator
Lauren Rogers
Project Manager
Srishti Malasi,
Cenveo® Publisher Services
Copy Editor
Claire Splan
Proofreader
Cenveo Publisher Services
Indexer
Jack Lewis
Art Director, Cover
Jeff Weeks
Illustration
Cenveo Publisher Services
Composition
Cenveo Publisher Services

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.
To my boys, Stephen and Matthew, from a very proud Dad.
About the Author
Simon Monk has a bachelor’s degree in cybernetics and computer
science and a doctorate in software engineering. He has been an
active electronics hobbyist since his school days and is an
occasional author in hobby electronics magazines. Dr. Monk is also
author of some 20 books on Maker and electronics topics, especially
Arduino and Raspberry Pi. You can find out more about his books at
http://simonmonk.org . You can also follow him on Twitter, where he
is @simonmonk2.
CONTENTS
Preface
Acknowledgments
Introduction

1 This Is Arduino
Microcontrollers
Development Boards
A Tour of an Arduino Board
Power Supply
Power Connections
Analog Inputs
Digital Connections
Microcontroller
Other Components
The Origins of Arduino
The Arduino Family
Uno and Leonardo
Mega and Due
The Micro and Small Arduino Boards
Yun
Lilypad
Other “Official” Boards
Arduino Clones and Variants
Conclusion
2 Getting Started
Powering Up
Installing the Software
Uploading Your First Sketch
The Arduino Application
Conclusion

3 C Language Basics
Programming
What Is a Programming Language?
Blink—Again!
Variables
Experiments in C
Numeric Variables and Arithmetic
Commands
if
for
while
Constants
Conclusion

4 Functions
What Is a Function?
Parameters
Global, Local, and Static Variables
Return Values
Other Variable Types
floats
boolean
Other Data Types
Coding Style
Indentation
Opening Braces
Whitespace
Comments
Conclusion

5 Arrays and Strings


Arrays
Morse Code SOS Using Arrays
String Arrays
String Literals
String Variables
A Morse Code Translator
Data
Globals and Setup
The loop Function
The flashSequence Function
The flashDotOrDash Function
Putting It All Together
Conclusion

6 Input and Output


Digital Outputs
Digital Inputs
Pull-Up Resistors
Internal Pull-Up Resistors
Debouncing
Analog Outputs
Analog Input
Conclusion

7 The Standard Arduino Library


Random Numbers
Math Functions
Bit Manipulation
Advanced I/O
Generating Tones
Feeding Shift Registers
Interrupts
Conclusion

8 Data Storage
Constants
Storing Data in Flash Memory
EEPROM
Storing an int in EEPROM
Using the AVR EEPROM Library
Storing a float in EEPROM
Storing a String in EEPROM
Clearing the Contents of EEPROM
Compression
Range Compression
Conclusion
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
9 Displays
Alphanumeric LCD Displays
A USB Message Board
Using the Display
Other LCD Library Functions
OLED Graphic Displays
Connecting an OLED Display
Software
Conclusion

10 Arduino Internet of Things Programming


Communicating with Web Servers
HTTP
HTML
Arduino Uno as a Web Server
Web-Controlled Arduino
Node MCU Web Server
Web-Controlled Node MCU
Calling Web Services
Arduino Uno and IFTTT
Node MCU ESP8266 Board and IFTTT
Other IoT Options
Arduino Yun
Particle Photon
Conclusion

11 C++ and Libraries


Object Orientation
Classes and Methods
Built-In Library Example
Writing Libraries
The Header File
The Implementation File
Completing Your Library
Conclusion

Index
PREFACE

The first edition of this book was published in November 2011 and
has been Amazon’s highest ranking book on Arduino.
At the time the book was originally written, the current Arduino
model was the Arduino 2009 and the software version was Beta018.
Almost at the time the book arrived in stores, the Arduino Uno and
version 1.0 of the Arduino software were released. Soon after, the
second printing of the book had a minor update to cover the new
board and software without formally being a second edition. This
edition brings the book fully up to date and is based on Arduino 1.6.
The Arduino Uno R3 is still considered to be the standard
Arduino board. However, many other boards, including both official
Arduino boards (like the Leonardo, Zero, 101, Due, and Yun) and
other Arduino programming language–based devices like the Photon
and Intel Edison, have also appeared.
This edition also addresses the use of Arduino in IoT (Internet of
Things) projects and the use of various types of display including
OLED and LCD.
Simon Monk
ACKNOWLEDGMENTS

I thank Linda for giving me the time, space, and support to write
this book and for putting up with the various messes my projects
create around the house.
Many thanks to Robert “BobKat” Logan and the many other
eagle-eyed and helpful folk who reported errata for the first edition. I
have done my best to fix what you found.
Finally, I would like to thank Michael McCabe, Srishti Malasi, and
everyone involved in the production of this book. It’s a pleasure to
work with such a great team.
INTRODUCTION

Arduino interface boards provide a low-cost, easy-to-use


technology to create microcontroller-based projects. With a little
electronics, you can make your Arduino do all sorts of things, from
controlling lights in an art installation to managing the power on a
solar energy system.
There are many project-based books that show you how to
connect things to your Arduino, including 30 Arduino Projects for the
Evil Genius by this author. However, the focus of this book is on
programming the Arduino.
This book will explain how to make programming the Arduino
simple and enjoyable, avoiding the difficulties of uncooperative code
that so often afflict a project. You will be taken through the process of
programming the Arduino step by step, starting with the basics of the
C programming language that Arduinos use.

So, What Is Arduino?


Arduino is a small microcontroller board with a universal serial bus
(USB) plug to connect to your computer and a number of connection
sockets that can be wired to external electronics such as motors,
relays, light sensors, laser diodes, loudspeakers, microphones, and
more. They can be powered either through the USB connection from
the computer, from a 9V battery, or from a power supply. They can
be controlled from the computer or programmed by the computer
and then disconnected and allowed to work independently.
The board design is open source. This means that anyone is
allowed to make Arduino-compatible boards. This competition has
led to low costs for the boards and all sorts of variations on the
“standard” boards.
The basic boards are supplemented by accessory shield boards
that can be plugged on top of the Arduino board.
The software for programming your Arduino is easy to use and
also freely available for Windows, Mac, and Linux computers.

What Will I Need?


This is a book intended for beginners, but it is also intended to be
useful to those who have used Arduino for a while and want to learn
more about programming the Arduino or gain a better understanding
of the fundamentals. As such, this book concentrates on the use of
the Arduino Uno board; however, almost all of the code will work
unmodified on all the Arduino models and variants.
You do not need to have any programming experience or a
technical background, and the book’s exercises do not require any
soldering. All you need is the desire to make something.
If you want to make the most of the book and try out some of the
experiments, then it is useful to have the following on hand:
♦ A few lengths of solid core wire
♦ A cheap digital multimeter
Both are readily available for a few dollars from a hobby electronics
store or online retailer such as Adafruit or Sparkfun. You will of
course also need an Arduino Uno board.
If you want to go a step further and experiment with displays and
network connections, then you will need to buy shields that are
available from online stores. See Chapters 9 and 10 for details.
Using This Book
This book is structured to get you started in a really simple way and
gradually build on what you have learned. You may, however, find
yourself skipping or skimming some of the early chapters as you find
the right level to enter the book.
The book is organized into the following chapters:
♦ Chapter 1: This Is Arduino An introduction to the Arduino
hardware, this chapter describes what it is capable of and the
various types of Arduino boards that are available.
♦ Chapter 2: Getting Started Here you conduct your first
experiments with your Arduino board: installing the software,
powering it up, and uploading your first sketch.
♦ Chapter 3: C Language Basics This chapter covers the
basics of the C language; for complete programming
beginners, the chapter also serves as an introduction to
programming in general.
♦ Chapter 4: Functions This chapter explains the key concept of
using and writing functions in Arduino sketches. These
sketches are demonstrated throughout with runnable code
examples.
♦ Chapter 5: Arrays and Strings Here you learn how to make
and use data structures that are more advanced than simple
integer variables. A Morse code example project is slowly
developed to illustrate the concepts being explained.
♦ Chapter 6: Input and Output You learn how to use the digital
and analog inputs and outputs on the Arduino in your
programs. A multimeter will be useful to show you what is
happening on the Arduino’s input/output connections.
♦ Chapter 7: The Standard Arduino Library This chapter
explains how to make use of the standard Arduino functions
that come in the Arduino’s standard library.
♦ Chapter 8: Data Storage Here you learn how to write sketches
that can save data in electrically erasable read-only memory
(EEPROM) and make use of the Arduino’s built-in flash
memory.
♦ Chapter 9: Displays In this chapter, you learn how to interface
an Arduino with displays and to make a simple USB message
board.
♦ Chapter 10: Arduino Internet of Things Programming You
learn how to make the Arduino behave like a Web server and
communicate with the Internet using services such as dweet
and IFTTT.
♦ Chapter 11: C++ and Libraries You go beyond C, looking at
adding object orientation and writing your own Arduino libraries.

Resources
This book is supported by an accompanying website:
www.arduinobook.com
There you will find all the source code used in this book as well as
other resources, such as errata.
1
This Is Arduino

Arduino is a microcontroller platform that has captured the


imagination of electronics enthusiasts. Its ease of use and open
source nature make it a great choice for anyone wanting to build
electronic projects.
Ultimately, it allows you to connect electronics through its pins so
that it can control things—for instance, turn lights or motors on and
off or sense things such as light and temperature. This is why
Arduino is sometimes given the description physical computing.
Because Arduinos can be connected to your computer by a universal
serial bus (USB) lead, this also means that you can use the Arduino
as an interface board to control those same electronics from your
computer.
This chapter is an introduction to the Arduino, including the
history and background of the Arduino, as well as an overview of the
hardware.

Microcontrollers
The heart of your Arduino is a microcontroller. Pretty much
everything else on the board is concerned with providing the board
with power and allowing it to communicate with your desktop
computer.
A microcontroller really is a little computer on a chip. It has
everything and more than the first home computers had. It has a
processor, a kilobyte or two of random access memory (RAM) for
holding data, a few kilobytes of erasable programmable read-only
memory (EPROM) or flash memory for holding your programs and it
has input and output pins. These input/output (I/O) pins link the
microcontroller to the rest of your electronics.
Inputs can read both digital (is the switch on or off?) and analog
(what is the voltage at a pin?). This opens up the opportunity of
connecting many different types of sensor for light, temperature,
sound, and more.
Outputs can also be analog or digital. So, you can set a pin to be
on or off (0 volts or 5 volts) and this can turn light-emitting diodes
(LEDs) on and off directly, or you can use the output to control higher
power devices such as motors. They can also provide an analog
output. That is, you can control the power output of a pin, allowing
you to control the speed of a motor or the brightness of a light, rather
than simply turning it on or off.
The microcontroller on an Arduino Uno board is the 28-pin chip
fitted into a socket at the center of the board. This single chip
contains the memory, processor, and all the electronics for the
input/output pins. It is manufactured by the company Atmel, which is
one of the major microcontroller manufacturers. Each of the
microcontroller manufacturers actually produces dozens of different
microcontrollers grouped into different families. The microcontrollers
are not all created for the benefit of electronics hobbyists like us. We
are a small part of this vast market. These devices are really
intended for embedding into consumer products, including cars,
washing machines, DVD players, children’s toys, and even air
fresheners.
The great thing about the Arduino is that it reduces this
bewildering array of choices by standardizing on one microcontroller
and sticking with it. (Well, as we see later, this statement is not quite
true, but it’s close enough.)
This means that when you are embarking on a new project, you
do not first need to weigh all the pros and cons of the various flavors
Visit https://ebookmass.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
Exploring the Variety of Random
Documents with Different Content
Then they adorned the funeral pyre with garlands of flowers, with
golden vessels and rings, with finely wrought weapons and rich
necklets and armlets; and when this was done they carried out the
fair body of Balder the Beautiful, and bearing it reverently upon their
shields they laid it upon the pyre.
Then they tried to launch the good ship, but so heavily laden was
she that they could not stir her an inch.
The Mountain-Giants, from their heights afar, had watched the
tragedy with eyes that were not unpitying, for even they had no ill-
will for Balder and they sent and told of a giantess called Hyrroken,
who was so strong that she could launch any vessel whatever its
weight might be.
So the Asas sent to fetch her from Giantland, and she soon came,
riding a wolf for steed and twisted serpents for reins.
When she alighted, Odin ordered four of his mightiest warriors to
hold the wolf, but he was so strong that they could do nothing until
the giantess had thrown him down and bound him fast.
Then with a few enormous strides, Hyrroken reached the great
vessel, and set her shoulder against the prow, sending the ship
rolling into the deep.
The earth shook with the force of the movement as though with
an earthquake, and the Asa folk collided with one another like pine-
trees during a storm. The ship, too, with its precious weight, was
well-nigh lost. At this Thor was wroth and, seizing his hammer,
would have slain the giantess had not the other Asas held him back,
bidding him not forget the last duty to the dead god. So Thor
hallowed the pyre with a touch of his sacred hammer and kindled it
with a thorn twig, which is the emblem of sleep.
Last of all, before the pyre blazed up, All-Father Odin added to the
pile of offerings his magic ring, from which fell eight new rings every
ninth night, and bending he whispered in Balder’s ear.
But none to this day know the words that Odin spake thus in the
ear of his dead son.
Then the flames from the pyre rose high and the great ship drifted
out to sea, and the wind caught the sails and fanned the flames till it
seemed as though sky and sea were wrapped in golden flame.

“And while they gazed, the sun went lurid down


Into the smoke-wrapt sea, and night came on.
But through the dark they watched the burning ship
Still carried o’er the distant waters.…
But fainter, as the stars rose high, it flared;
And as, in a decaying winter fire,
A charr’d log, falling, makes a shower of sparks—
So, with a shower of sparks, the pile fell in,
Reddening the sea around; and all was dark.”

And thus did Balder the Beautiful pass from the peaceful steads of
Asgard, as passes the sun when he paints the evening clouds with
the glory of his setting.

Note.—Most of the poetical extracts throughout this chapter are taken from
Matthew Arnold’s “Balder Dead.”
THE WONDERFUL QUERN STONES
By Julia Goddard

O
nce upon a time there was a king of Denmark, or Gotland, as it
was then called, whose name was Frothi. He was a great-
grandson of the god Thor, and a very mighty king, and wherever the
Danish language was spoken there was Frothi’s name honored and
respected.
Among his treasures were two quern stones; nothing much to look
at, simply two common millstones in appearance, and no one who
did not know what they could do would think of taking any notice of
them. Nevertheless these quern stones were of more worth than
anything that King Frothi had, for they could produce anything that
the grinder of the quern or hand-mill wished for. They would bring
gold, silver, precious stones, anything and everything; and besides
this they could grind love, joy, peace; therefore it is not too much to
say that these stones were worth more than all the treasures of the
king put together.
At least they would have been if he could have made use of them,
but they were so heavy that few could be found to turn the quern,
and just at the time of which I am speaking there was no one at all
in the land of Gotland able to work away at the quern handle.
Now the more King Frothi pondered over his wonderful quern
stones, the greater became his desire to use them, and he sought
throughout the land from north to south, from east to west, if
perchance he might find someone strong enough to help him in his
need. But all to no purpose, and he was utterly in despair when, by
good luck he happened to go on a visit to Fiölnir, King of Sweden,
and to hear of two slave-women of great size and strength. Surely,
thought Frothi, these are just the women to grind at my quern Grotti
(for so it was called), and he asked King Fiölnir to be allowed to see
them.
So King Fiölnir ordered the slaves to be brought before Frothi, and
when Frothi saw them his spirits rose, for certainly Menia and Fenia
were strong-looking women. They were eight feet in height, and
broader across the shoulders than any of Frothi’s warriors, and the
muscles of their arms stood out like cords. And they lifted heavy
weights, threw heavy javelins, and did so many feats of strength
that Frothi felt quite sure that they would be able to turn the quern
handle.
“I will buy these slaves,” said he, “and take them with me to
Gotland.”
Menia and Fenia stood with their arms folded and their proud
heads bowed down, while Frothi counted out the gold to the seller.
They were slaves; with money had they been bought, with money
were they sold again. What cared Frothi who was their father, or
how they had come into the land of Sweden?
And he took them home with him and bade them grind at the
quern. Now he should be able to test the power of the wonderful
stones.
“Grind, grind, Menia and Fenia, let me see whether you have
strength for the work.”
So spake the King Frothi, and the huge women lifted the heavy
stones as though they had been pebbles.
“What shall we grind?” asked the slaves.
“Gold, gold, peace and wealth for Frothi.”
Gold! gold! the land was filled with riches. Treasure in the king’s
palace, treasure in the coffers of his subjects—gold! gold! There
were no poor in the land, no beggars in the streets, no children
crying for bread. All honor to the quern stones!
Peace! peace! no more war in the land. Frothi is at peace with
everyone. And more than that, there was peace in all countries
where Frothi’s name was known, even to the far south; and
everyone talked of Frothi’s peace. Praise be to the quern stones!
Wealth! yes, everything went well. Not one of the counsels of King
Frothi failed. There was not a green field that did not yield a rich
crop; not a tree but bent beneath its weight of fruit; not a stream
that ran dry; not a vessel that sailed from the harbors of Gotland
that came not back, after a fair voyage, in safety to its haven. There
was good luck everywhere.
“Grind on, grind on, Menia and Fenia! good fortune is mine,” said
King Frothi.
And the slaves ground on.
“When shall we rest, when may we rest, King Frothi? It is weary
work toiling day and night.”
“No longer than whilst the cuckoo is silent in the spring.”
“Never ceasing is the cry of the cuckoo in the groves; may we not
rest longer?”
“Not longer,” answered King Frothi, “than whilst the verse of a
song is sung.”
“That is but little!” sighed Menia and Fenia, and they toiled on.
Their arms were weary and their eyes heavy; they would fain have
slept, but Frothi would not let them have any sleep. They were but
slaves who must obey their master, so they toiled on, still grinding
peace and wealth to Frothi:
“To Frothi and his queen
Joy and peace—
May plenty in the land
Still increase.
Frothi and his queen
From dangers keep;
May they on beds of down
Sweetly sleep.
No sword be drawn
In Gotland old,
By murderer bold.
No harm befall
The high or low—
To none be woe,
Good luck to all,
Good luck to all.
We grind, we grind,
No rest we find,
For rest we call.”

Thus sang the two giant women; then they begged again: “Give
us rest, O Frothi!”
But still Frothi answered: “Rest whilst the verse of a song is sung,
or as long as the cuckoo is silent in the spring.”
No longer would the king give them.
Yet Frothi was deemed a good king, but gold and good luck were
hardening his heart.
Menia and Fenia went on grinding, and their wrath grew deeper
and deeper, and thus at last they spoke.
First said Fenia: “Thou wert not wise, O Frothi. Thou didst buy us
because like giants we towered above the other slaves, because we
were strong and hardy and could lift heavy burdens.”
And Menia took up the wail: “Are we not of the race of the
mountain giants? Are not our kindred greater than thine, O Frothi?
The quern had never left the gray fell but for the giants’ daughters.
Never, never should we have ground as we have done had it not
been that we remembered from what race we sprang.”
Then answered Menia: “Nine long winters saw us training to feats
of strength, nine long winters of wearisome labor. Deep down in the
earth we toiled and toiled until we could move the high mountain
from its foundations. We are weird women, O Frothi. We can see far
into the future. Our eyes have looked upon the quern before. In the
giants’ house we whirled it until the earth shook, and hoarse thunder
resounded through the caverns. Thou art not wise, O Frothi! O
Frothi; thou art not wise!”
But Frothi heard them not; he was sleeping the sweet sleep that
the quern stones had ground for him.
“Strong are we indeed,” laughed Fenia sorrowfully, “strong to
contend with the puny men—we whose pastime in Sweden was to
tame the fiercest bears, so that they ate from our hands; we who
fought with mighty warriors and came off conquerors; we who
helped one prince and put down another. Well we fought, and many
were the wounds we received from sharp spears and flashing
swords. Frothi knows not our power or he would scarce have
brought us to his palace to treat us thus. Here no one has
compassion upon us. Cold are the skies above us, and the pitiless
wind beats on our breasts. Cold is the ground on which we stand,
and the keen frost bites our feet. Ah, there are none to pity us. No
one cares for the slaves. We grind forever an enemy’s quern, and he
gives us no rest. Grind, grind; I am weary of grinding; I must have
rest.”
“Nay,” returned Menia, “talk not of rest until Frothi is content with
what we bring him.”
Then Fenia started: “If he gives us no rest, let us take it ourselves.
Why should we any longer grind good for him who only gives us
evil? We can grind what we please. Let us revenge ourselves.”
Then Menia turned the handle quicker than ever, and in a wild
voice she sang:

“I see a ship comes sailing


With warriors bold aboard,
There’s many a one that in Danish blood
Would be glad to dip his sword.
Say, shall we grind them hither?
Say, shall they land to-night?
Say, shall they set the palace afire?
Say, shall they win the fight?”

Then called Fenia in a voice of thunder through the midnight air:


“Frothi, Frothi, awake, awake! Wilt thou not listen to us? Have mercy
and let us rest our weary limbs.” But all was still, and Frothi gave no
answer to the cry.
“Nay,” answered Menia, “he will not hearken. Little he cares for
the worn-out slaves. Revenge, revenge!”
And Frothi slept, not dreaming of the evil that was coming upon
him.
And again Fenia shouted: “Frothi, Frothi, awake! The beacon is
blazing. Danger is nigh. Wilt thou not spare?”
But Frothi gave no answer, and the giant women toiled on.
“O Frothi, Frothi, we cannot bear our weariness.” And still no
answer came.
“Frothi, Frothi, danger is nigh thee. Well-manned ships are gliding
over the sea. It is Mysingr who comes; his white sail flutters in the
wind; his flag is unfurled. Frothi, Frothi, awake, awake; thou shalt be
king no longer.”
And as the giant women ground, the words they spake came to
pass—they were grinding revenge for themselves and brought the
enemy nearer and nearer.
“Ho! hearken to the herald! Frothi, Frothi, the town is on fire. The
palaces will soon be ruined heaps. Grind, Menia, ever more swiftly,
until we grind death to Frothi.”
And Menia and Fenia ground and ground till Mysingr and his
followers landed from the ships. They ground until they had reached
the palace.
“To arms, to arms!” shouted the warder, but it was too late. The
Gotlanders armed themselves; but who could stand against the army
that the slave women were grinding against them?
Not long did the struggle last. Frothi and his Gotlanders fought
bravely, but the sea-king and his allies were mightier, for the
giantesses were in giant mood, and turned the handle faster and
faster, until down fell the quern stones. Then sank Frothi pierced
with wounds, and the fight was over. The army that Menia and Fenia
had ground to help Mysingr vanished; and Mysingr and his men
alone were left conquerors on the bloody field.
They loaded their ships with treasure, and Mysingr took with him
Menia, Fenia, and the quern stones.
But, alas! Mysingr was no wiser than King Frothi had been.
Gold, however, was not his first thought; he had enough of that,
but he wanted something else that just then was more to him than
gold.
There was no salt on board the sea-king’s vessels; so he said:
“Grind salt.”
And Menia and Fenia ground salt for Mysingr.
At midnight they asked if they had ground enough.
And Mysingr bade them grind on.
And so they ground and ground until the ship was so heavy with
salt that it sank, and the sea-king and all his men were drowned.
Where the quern stones went down there is to this day a great
whirlpool, and the waters of the sea have been salt ever since.
THEY WOULD SWOOP DOWN AND BEAR HIS LIFELESS
BODY TO VALHALLA

—page 100

From the painting by K. Dielitz


BRUNHILDA AND THE MAGIC
SWORD
By Constance Maud

O
n the summit of a rocky mountain peak a beautiful maiden lay
sleeping. On every side rose the tall dark pine trees, like huge
giants on guard. A circle of magic fire formed a glowing wall around
her rocky couch.
The sun rose and set, night succeeded day, winter and summer
came and went, but the maiden slept on still.
From head to foot she was encased in shining armor. On her
breast lay a shield, on her head glistened a warrior’s helmet, and at
her side a spear. For on a day long past it had been decreed that
thus this maiden should sleep, till awakened by the kiss of one who
would dare the flames for her sake, and claim her as bride.
Many a knight, hearing of the beautiful sleeper, had thought to
win his way to her; but no sooner did he see the angry fire darting
out on all sides, and feel the scorching heat of the great flames,
than the bravest fell back discouraged.
Time was when this fair warrior had dwelt with the gods and
goddesses in Valhalla, for she was none other than Brunhilda,
favorite daughter of Wotan the king. She had eight sisters, each one
beautiful as the dawn, and knowing neither fear nor weakness; but
among them all Brunhilda was fairest, bravest, and strongest. These
nine maidens were known as the Valkyrie, and each was a warrior
perfect in the art of war. Chief among their duties was to attend all
battles on earth. Riding on their winged horses, they would hover
over the battlefield, and, when a hero fell, swoop down and bear his
lifeless body to Valhalla, where he would awaken to live among the
gods, and be from henceforth one of the chosen bodyguard of
Wotan.
Now it happened on a day in these times long past that Wotan
called to him Brunhilda, and charged her that she should defend
Siegmund the Volsung in a deadly combat he was about to engage
in with the grim and savage Hunding.
Wotan had reasons for wishing to grant Siegmund a special favor.
The Father of the Gods had once struck a mighty sword into the
heart of an ancient ash tree, decreeing that it should belong to him
alone who could pluck it out. Many a valiant knight had tried to win
the sword; but all in vain. Buried deep in the ash-stem it remained
till Siegmund came and with one powerful wrench drew forth the
weapon. Then Wotan rejoiced that a man had been found strong
enough to win his sword, and he loved Siegmund the Volsung
greatly.
But Wotan hated Hunding, for he was a tyrant and a bully. With all
his strength and bluster, he had never been able to pluck out the
sword, though many a time had he tried, grinding his teeth savagely
over his failure.
Now the cause of strife between Hunding and Siegmund was this
—Hunding had a beautiful wife, Sieglinda by name, whom he had
married sorely against her will. With her whole soul she loathed and
hated the cruel Hunding, and only longed to escape from him. So it
befell one day she fled with Siegmund the Volsung; for the first
moment they met, these two loved one another, and Sieglinda said
to herself: “It were better far to die with Siegmund than to live with
Hunding.”
When Hunding discovered their flight, he set forth to pursue the
lovers, uttering loud threats of vengeance, which echoed through
the forest for miles round.
He called on Fricka, Queen of Valhalla, to help him, for he knew
this goddess to be most stern in her view of the duties of wives.
“O mighty goddess,” cried Hunding, “grant me thine aid! May thy
justice and my righteous vengeance speedily overtake the miscreant!
Let not the scoundrel Volsung turn the power of Wotan’s sword to
his own advantage, for then would all men surely say that the god’s
favor rests on faithless wives!”
Fricka promised him her warm support, and also that of Wotan,
whom she knew she could bend to her all-powerful will, however
opposed he might feel. Scarcely had Brunhilda left the presence of
her father when the goddess Fricka drove up in a car drawn by two
fierce fleet-footed rams.
With stern majesty she demanded that Siegmund should be given
up to justice, and the magic sword he had won be broken against
the spear of Wotan himself. It was for the honor of the gods and
Valhalla, cried Fricka, that Hunding’s prayer for vengeance on his
faithless wife and her lover be answered.
In vain did Wotan plead every excuse he could devise for his
favorite Siegmund. Not until he had solemnly sworn on oath to cast
off Siegmund, and recall the order given to Brunhilda, did the stern
goddess take her leave. Wotan sank on the nearest rock a picture of
utter dejection. In this sad state Brunhilda found him shortly after.
She listened in dismay, when in gloomy tones he said to her:
“Thou shalt fight to-day as Fricka desires, and thou shalt vanquish
utterly Siegmund the Volsung! Heed well my words—my former
order I now recall.”
Brunhilda could scarcely believe she heard aright. “Nay, but thou
lovest Siegmund,” she cried in sore perplexity, “and Hunding dost
thou hate! Ah,” she continued, as a new thought came to her, “this
second decree is not given with thy heart! Rather will I abide by the
first!”
Brunhilda spoke with good intent, but these were unlucky words.
In many respects the mighty Wotan was not unlike a mortal man.
“How, froward child! Dost dare dispute my word?” he cried. “Thou
who are naught but the blind tool used by my hand! Wake not my
wrath, but heed well my command—Siegmund dies in the fight with
Hunding. I have spoken—go!”
In sorrowful amaze the warrior-maiden took up her weapons and
departed. She found the ill-starred lovers resting awhile in their
wanderings through the trackless forest. Sieglinda’s strength was
utterly spent, and she had fallen into a deep swoon.
“Siegmund the Volsung,” spoke Brunhilda in solemn tones, “I
come to call thee hence!”
“Who art thou, so fair and stern?” he asked.
“Only those already doomed to death may look upon my face,”
she answered. “I am she who bears the fallen warrior to Valhalla.”
“And will this my love come also to Valhalla?” asked Siegmund,
gazing tenderly at the pale face of the sleeping Sieglinda.
“Nay,” replied Brunhilda, “such is not the will of Wotan; Sieglinda
must remain upon the earth. But thou shalt be with heroes, and the
daughters of Wotan shall wait upon thee.”
“If my love may not be there, I will have none of Valhalla’s
delights! I follow thee not!” answered Siegmund fixedly.
“Thou hast looked on the face of the Valkyrie—thou hast no choice
but to follow her,” said Brunhilda.
“By what warrior’s hand must I fall?” asked Siegmund.
“Hunding will fell thee in the fight to-day,” answered the Valkyrie.
But Siegmund laughed this prophecy to scorn. “Seest thou this
sword?” he said, drawing forth the weapon of Wotan. “It was made
by one in whose name I am sure of victory.”
“He who bestowed that sword now withdraws the charm, and
himself dooms thee to death!” cried Brunhilda in terrible ringing
tones.
“Hush! or thou wilt awaken my love,” said Siegmund, bending
tenderly over Sieglinda. “If what thou sayest be true, woe and
shame be to him who bestowed such a sword! If I must perish and
desert her,” he continued bitterly, “never will I pass to the Valhalla of
Wotan.”
“What!” cried Brunhilda in horror. “Thou wouldst forego the glory
of Valhalla for the sake of this poor feeble woman?”
“If thou canst feel no pity, and canst give no help in my sore
distress, then leave me at least in peace. Speak not of Valhalla’s
empty joys.”
How help this heroic lover without disobeying the order of Wotan
her father? “Confide thy beloved to my care—I will protect her, noble
Siegmund,” she said earnestly.
“I thank thee,” replied Siegmund, “but none save I alone can
protect my love. And if this sword, which a traitor fashioned, is to
prove false in the fight, better it should take our two lives with one
fell stroke.” So saying, he drew his sword and held it over Sieglinda.
But Brunhilda seized his arm.
“Stay thy hand, reckless man! Thou shalt not die, but live. Thou
shalt not leave Sieglinda. Sooner will I, Brunhilda, cancel the death-
lot. Doubt me not, my promise is spoken. Take up thy sword, it shall
prevail, for I will aid thee. Speed now to meet thy foe. Hark to the
sound of Hunding’s horn! Farewell, Siegmund!”
With these words Brunhilda sprang on her winged horse, and soon
vanished through the clouds.
Siegmund gazed after her with grateful eyes; then, stooping,
kissed Sieglinda, saying softly: “Slumber in peace, my beloved, till
the fight is over and peril past.” The horn of Hunding sounded loudly
in the distance, and Siegmund hastened away to meet him, leaving
Sieglinda still asleep.
A terrible thunderstorm now broke over the forest, thunderclouds
rolled and clashed together. All was dark as night, no light save from
the forked flashes which darted here and there in fiery streaks, like
the gleaming swords of an unseen enemy fighting in the clouds.
Louder and louder called the hunting-horns of Hunding and his
followers. Presently a terrific thunderclap awoke Sieglinda. She
started up in wildest terror. Siegmund was no longer by her side, a
dense darkness surrounded her, while near at hand rang the voice of
Hunding crying in tones of wrath: “Ha, thou scoundrel Volsung!
come out and fight, or my hounds shall hunt thee down!”
The voices now seemed to come from a rock over Sieglinda’s
head. She listened in eager anxiety as they continued to shout to
one another. Suddenly a flash of lightning showed them fighting
desperately on a ridge of the rock.
Sieglinda rushed forward, forgetting all fears for herself in an
agony for Siegmund’s safety. Another blinding flash made her
stagger backwards, dazed and giddy. For one instant the whole
mountain-peak was lit up, and she saw, hovering over Siegmund in
the air, a woman on a winged horse, covering him with a shield as
he fought.
“Now is the moment, Siegmund the Volsung,” cried a dear voice
from above. “Slay him with thy magic sword!”
But as Siegmund aimed his deadly stroke at the heart of Hunding,
a dreadful disaster befell. Wotan, standing unseen at Hunding’s side,
put forth his spear and received the thrust of Siegmund’s sword.
“Back before my spear! Be splintered, thou sword!” roared the voice
of the god in tones of thunder.
With a sharp sound like a cry the sword of Siegmund snapped and
flew to pieces.
Brunhilda fell back in dismay as the gleaming eye of Wotan met
her own; and instantly Hunding plunged his sword into the heart of
his defenseless foe. Sieglinda fell senseless to the ground. Brunhilda,
gathering up the fragments of the sword, hurried to her side, and,
lifting her to the saddle, rode off at lightning speed through the
clouds.
Siegmund’s lifeless body lay at the feet of Wotan. Remorsefully he
gazed upon the brave young warrior he would fain have spared. The
sight of Hunding was more than he could bear. With a backward
wave of his hand Wotan cried fiercely: “Go, knave! Kneel before
Fricka and tell her how well Wotan avenged her slight!”
And at these words Hunding staggered and fell lifeless to the
ground; for no mortal man could stand before the scornful wave of
Wotan’s hand, unless he were of the race of Heroes who know not
fear.
So Hunding died; but there was no Valkyrie to bear him to
Valhalla. All his life he had been a tyrant and a bully, and such men,
were they the best fighters in the world, could find no favor with the
warrior-maidens.
“Now for Brunhilda!” cried Wotan, his voice causing the very trees
to quake and shiver. “She who has dared to defy and disobey me!
Terrible shall be her punishment, though she be my best-loved
child.”
He sprang on his war-horse and followed where the parted clouds
showed Brunhilda’s recent track.
BRUNHILDA’S SLEEP GUARDED BY
LOKI’S FIERY ARM
By Constance Maud

O
n the summit of a lofty mountain the Valkyrie sisters met after
the day’s toil, to await their father Wotan, and present him with
the heroes they had gathered from the battlefields on earth.
One by one they alighted from their winged steeds, shouting the
Valkyries’ war-cry greeting to each other, “Hei-a-ha! Hei-a-hei!
Hoyoto-ho!”
From the north came Helmwiga and Gerhilda well-laden; the fierce
Norsemen never failed to supply fresh recruits for Wotan’s
bodyguard. From east and west and every quarter came some
tribute to Wotan, borne on the Valkyries’ saddle-bows.
“Where tarries our sister Brunhilda?” asked several eagerly. “She is
late to-night. Ah, see, in the distance, who is that speeding hither
like a cloud driven before the storm? Surely not so rides our queenly
Brunhilda!”
With the fainting Sieglinda in her arms, it was indeed Brunhilda
who came in sight at last, flying on the wings of the wind.
“Faster! oh, faster, Grani my steed!” she cried to the panting
horse.
And Grani, his strong head downward bent, with his winged feet
cleft the rolling clouds till they hissed like water meeting fire, while
his breath came in great snorting gasps, and the foam flew from his
mouth in big flakes like snow. Never before in his long service with
his noble mistress had Grani been urged to flight, and he knew that
dire indeed must be the danger which Brunhilda dare not stand and
face.
“Well striven, good Grani, faithful steed!” cried Brunhilda, as the
horse alighted on the mountain and dropped exhausted to the
ground. Lifting Sieglinda, now fully conscious, from the saddle,
Brunhilda hastened toward her sisters.
“She brings no hero! It is naught but a maiden!” they exclaimed in
wonder and disappointment.
“Help me, O sisters! Shield me and this poor woman, I beseech
you!” implored Brunhilda breathlessly.
“Why this furious haste? From whom fliest thou?” asked the
Valkyries, crowding round her in amazement.
“I fly from our father! In terrible wrath he hunts me down!”
“Thou fliest from our father?” cried all the sisters, horror-struck.
“What hast thou done that thou shouldst fly from him?”
Brunhilda poured out her tale in eager haste. From one to another
she looked for pity or sympathy but in vain. Sternly the Valkyries
eyed her as she knelt and implored them to shelter her and the
unfortunate Sieglinda from the wrath of Wotan.
“Woe to thee, most unworthy sister! How durst thou disobey the
sacred command of Wotan our father? Naught but disaster can
follow!”
And now, from the north, raging storm-clouds came sweeping
toward them. One of the Valkyries mounted to the topmost peak,
and, looking across the sky, called out:
“He comes! Wotan the wrathful father! flying furiously in the
storm-clouds on his snorting steed!”
“Who will lend me a horse? Grani is spent—see, he cannot even
stand! Rossvisa, my sister, have pity, lend me thy racer!” Brunhilda
implored, turning to a stately Valkyrie whose magnificent steed was
at her side.
“My racer never yet fled our father in fear, and never shall!”
replied Rossvisa coldly. To each one Brunhilda went, beseeching a
horse.
“We stand by our father!” the Valkyries all answered her. Brunhilda
was in despair.
Then Sieglinda, who had watched the scene in gloomy silence,
came forward and spoke. “Sorrow not for me, noble maiden. Oh,
why didst thou not leave me to die with Siegmund? If thou hast
indeed pity on me, stretch forth thy sword and pierce me now to the
heart.”
“Nay, that must not be,” answered Brunhilda. “Thou must live still,
Sieglinda, for thou shalt have a son, who will one day be the
greatest hero in the world. Heed now what I say. To the eastward
there lies a mighty forest; there Wotan will not pursue thee, for he
abhors the spot. It is the dwelling of Fafnir the dragon, his mortal
foe. Thither haste thee. I will remain here to face the god’s wrath,
and hinder him till thou hast escaped far on thy journey.”
“Fly, then, Sieglinda!” cried Brunhilda; “speed to the east! Faint
not and fear not, whatever betide. Live for thy son, and call him by
this name from me—Siegfried the Victor! Give him these shattered
pieces of his father’s sword—from the field of death I took them.
One day he shall weld them into a mighty weapon. Farewell,
Sieglinda!” It was none too soon. Another minute, and with a crash
the angry god descended in the midst of the dismayed Valkyries.
“Where is Brunhilda, the rebel?” he roared in tones of fury. “Let
her come forth! Dare any to shelter her, they shall share the same
doom.”
The Valkyrie sisters had closed round Brunhilda in the vain hope of
hiding her; but at these words she came out from their midst, her
face pale and set. “Here am I, my father, to suffer my sentence,” she
said firmly.
Wotan was not prepared for such calm fearlessness. “I sentence
thee not,” he answered. “’Tis thine own misdeed condemns thee!”
Then, with gathering wrath, he continued, “I made thee a Valkyrie,
highest in honor and favor. Thou hast forsworn thy noble calling, and
played traitor to thy father. No longer mayest thou dwell in Valhalla
as my child. Never more will I send thee for my dead heroes. Never
again shalt thou fill my cup at the feast! Degraded and exiled art
thou forever!”
Brunhilda stood as though turned to stone.
The Valkyries burst into loud lamentations. “Woe! woe! Alas, our
unhappy sister!”
Then Brunhilda cried aloud in great agony of mind, “O father,
disown me not! Take not from me all thy gifts! Leave me not to utter
desolation!”
But Wotan was not to be appeased, and the worst part of the
sentence was yet to come. “Thou thyself hast called down my curse,
and here where we now stand it shall strike thee!” he answered. “A
deep, dreamless sleep shall overpower thee, and to that man who
first awakens thee shalt thou belong from henceforth!”
At this grim sentence all the Valkyries lifted their voices in a wail of
horror and dismay, crying: “Oh, terrible father, recall the curse! Let
not our sister be degraded to such a shameful fate. Each one of us
shares in her disgrace.”
Brunhilda’s woe was too great for any cry.
“I have spoken once—my words abide forever!” retorted Wotan.
“Thy treacherous sister,” he continued, “no longer belongs to the
glorious troop of Valkyries. Her godhood is forfeit! The doom she has
earned is now to wed a mortal man.”
At this picture of her future, poor Brunhilda sank with a deep
groan to the earth.
Wotan turned to the eight sisters, who looked on in deep distress.
“If ye desire not a like doom, forbear to pity the outcast. Away now,
begone, every one of ye! Haste, lest I hurl the same woe on your
heads!” The earth quaked and trembled as Wotan passionately
stamped his foot, and fiery gleams shot from his eyes.
With a last despairing look at Brunhilda and a wild cry of woe, the
Valkyries sprang on their horses and fled in hot haste. They knew if
their stern father spared not his favorite Brunhilda, still less would he
spare them.
The storm had now ceased. Brunhilda lay prostrate on the ground.
Wotan stood motionless in silent gloom. His rage seemed spent, like
that of the storm. Then Brunhilda rose slowly from the ground, and
spoke in deep sorrowful tones. “Was my deed verily so shameful that
such shame should fall upon me? Was it so base an act to fulfil thy
first command? Speak, O my father, and soften thy wrath toward
me.”
“Thou didst wilfully disobey my sacred order. The first command I
recalled,” replied Wotan bitterly.
“But not of thine own will. ’Twas Fricka who made thee false to
thy nobler self; and because I held in my heart thy true wish, I
dared to slight thy second order.”
The mention of Fricka brought an angry flash from the eyes of
Wotan. “For that rebellious act the curse now falls on thee,” he
answered.
“But I knew how well thou lovedst Siegmund,” pleaded Brunhilda;
“and when I found him in the forest and told him of thy death
decree, he revealed to me a wondrous thing I never before had
known. For in his strong courage and his undying devotion to
Sieglinda, I learned what love could be. And I resolved, whether
victory or death came of it, to serve one so noble. In acting thus, O
father, I was faithful to thee, even though disobeying thereby thy
command.”
Wotan groaned. “Thou knowest naught of what compelled my
action. Dark clouds are gathering on every side—the day of doom
threatens Valhalla! I dared not follow what my heart desired. But all
this woe I kept from thee, that thy life might be happy and free from
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmasss.com

You might also like