abstraction: the process of creating pieces of code such that a programmer does not need to understand how the code works to use it in her program. You do not necessarily need to know how a piece of code, like a procedure, works to use it in a program. As long as you know the procedure’s name, its inputs, its outputs, and what it does, you can use it. For example, in the piano tutorial, when you use the readCapacitivePin procedure, you’re taking advantage of abstraction.

analog: in electronics, a signal that conveys information through a continuously changing value. For example, the sensor you constructed in the monster tutorial is an example of an analog sensor since it conveys information through a continuously changing value—electrical resistance. Analog signals are different from digital signals, which convey information through discrete changes in values. See also digital.

array: a list or table in code. Arrays provide a way to store an ordered collection of data in your program. For example, the statement int keys[7] = { key1, key2, key3, key4, key5, key6, key7 }; declares an array called keys that consists of seven entries, key1, key2, key3, key4, key5, key6, key7, of type int. The entries in an array are accessed using numbers in square brackets. The access numbers begin with zero. For example, the first entry in the keys array can be accessed with the statement keys[0], the second entry with the statement keys[1], and so on.


baudrate/baud: see communication speed.


C (programming language): a general-purpose programming language developed in the late 1960s by Dennis Ritchie, a researcher at AT&T Bell Labs. All Arduino programs are written in C. However, the Arduino environment has many features that aren’t part of standard C, including built-in procedures like digitalWrite and delay, so the Arduino language can be said to be a dialect (or version) of C. C is one of the most widely used programming languages in the world.

call (a procedure): calling a procedure means that you use the procedure in the main part of your program. For example, you call Arduino’s built-in delay procedure when you include the statement delay(1000); in the loop part of your program.

capacitance: a material’s ability to store electric charge.

capacitive sensor: a sensor based on changing capacitance. That is, a sensor that changes its capacitance in response to a stimulus, often touch. For example, each piano key in the piano tutorial is a capacitive sensor because the capacitance of a key changes when a person touches it.

circuit: a network of electrical devices. It is generally a closed loop that includes a power supply and other electrical elements like LEDs and switches. The loop structure enables the flow of electric current from (+) to (-).

code or source code: a collection of instructions that will be carried out by a computer (or LilyPad) and that are written in a programming language. Any piece of an Arduino program can be called code. See also program.

comment: a piece of text in a program that is ignored by the compiler and the computer (or LilyPad) that executes the code. In the C programming language there are two kinds of comments: comments that extend for several lines (like paragraphs) and comments that are written on a single line. To create a comment that spans multiple lines, begin the comment with /* and end it with */. To create a comment that is only on one line, begin it with //. Comments are shown in a greyish brown in the Arduino environment. For example, the line // set all keys to be inputs is a comment. So is the line // the loop routine runs over and over again forever.

comment out (code): to turn a piece of code into a comment. Commenting out a piece of code allows you to temporarily prevent that code from executing—since comments are ignored by the compiler—while keeping the text of the code in your program. To comment out a single line of code, add two slash characters // to the beginning of the line. To comment out a larger piece of code, add /* characters to the beginning of the section you want to comment out and */ to the end of the section. You should see the commented out section turn grey in the Arduino window. When you want to include the code in your program again, un-comment it; change it from a comment back into code by removing the // or /* and */ characters. For example, the statement delay(1000); is commented out when two slash characters are placed in front of it like so: //delay(1000); See also comment.

communication speed: (also known as baud rate) the speed at which one computational or electronic device communicates with another. Communication speed is measured in bits per second. 9600 bits per second (or “baud”) is the standard communication speed for most Arduino applications. Before sending data from a LilyPad to a computer in an Arduino program, you must specify the communication speed using the Serial.begin procedure. For example, the statement Serial.begin(9600); sets the LilyPad’s communication speed to 9600 pits per second. See also serial port.

compile: to translate a program, written in a programming language like C, into a machine-readable code like hex code. In the Arduino environment, clicking on the check mark icon in the toolbar compiles C code that you wrote into hex code that a LilyPad can understand.

compile error: an error in a program that is detected when software attempts to compile the program. Compile errors are often syntax errors like misspellings or missing semi-colons. For example, since the word “delay” is misspelled in the statement dellay(1000);, code containing this statement will generate a compile error.

condition: a statement that is always either true or false. Conditions are often comparisons using less than (<), greater than (>), and equal to (==) operators. For example, the condition x < 10 is true when x is less than 10 and false when x is 10 or greater. Conditions are an important part of conditional statements, where they appear in parentheses. For example, in the line if (i<10), (i<10) is the condition. See also conditional statement.

conditional statement: a block of code that does one thing if a condition is true and another thing if the condition is false. if else statements and while loops are examples of conditional statements. See also condition.

conductive: a conductive material is one that an electrical current flows through easily. Metals like copper, silver, and aluminum are highly conductive. Conductive materials in the projects in this book include the tabs on the LilyPad components and the conductive (stainless steel) thread used to sew these components together. The opposite of a conductive material is a insulating material. Insulating materials—like plastic, glass, and fabric—resist the flow of electricity. Electrical current does not flow through insulating materials.

constant: a named variable in a program whose value never changes. Constants are declared like variables with a type and a name. However, constants require an additional code word, const, at the beginning of the statement. For example, the numberOfKeys constant in the piano project is declared with the statement const int numberOfKeys=7;. This constant stays the same throughout the Piano program.


digital: information represented using discrete values. In computing, information represented using 1s and 0s. In electronics, a signal that conveys information through discrete values (HIGH/LOW) instead of continuously varying values. For example a switch is an example of a digital sensor since it conveys information in a discrete manner; a switch is either open or closed. Digital signals are different from analog signals, which convey information through continuous changes in values. See also analog.


electric current: the flow of electricity through a circuit. Current travels from the (+) side of a battery (power), through the components connected in the circuit, and back to the (-) side of the battery (ground). Electric current only flows through a circuit if the path is complete, that is, if there are no breaks in the circuit. Electric current is measured in amps.

electronic textiles or e-textiles: fabrics that include soft electrical circuitry and embedded electronics like sensors, lights, motors, and small computers. Designers of e-textiles strive to keep things soft by using new materials like conductive thread, conductive fabric, and flexible circuit boards.

energy: electrical energy is the ability of a power supply to run a circuit over time, to light up an LED, or make sounds with a speaker. The amount of energy stored in a battery is equal to its amp-hour rating multiplied by its voltage rating. Energy is measured in watt-hours (Wh). For example, a 3-volt battery with an amp-hour rating of .25 amp-hours stores .75 watt-hours of energy.

execute (a program): (also run) the act of carrying out the instructions specified by a program. A computer—like the LilyPad Arduino—executes programs line-by-line in the exact order in which they are written.


frequency: the speed or pitch of a sound wave. Sound is created by vibrations of molecules in the air. When the molecules vibrate very quickly—at a high frequency—you hear a high note; when they vibrate more slowly—at a low frequency—you hear a low note. Frequency is measure in pulses per second or Hertz (Hz).


ground (-): the negative terminal of a battery or other power supply in a circuit; 0 volts. Also, any part of a circuit that is at 0 volts. Ground is the reference point in a circuit from which all other voltages are measured. The color black is used to denote ground in circuit diagrams and drawings. In Arduino code, ground is referred to as LOW. See also low and power.


hex code: short for hexadecimal code. A numerical code based on 16 symbols (a base 16 number system). When Arduino code is compiled it is translated into hex code. This code is then loaded onto the LilyPad Arduino, which can read and execute it.

high or HIGH: in Arduino code, the term used to refer to power (+) in electrical circuits. Power, (+), and HIGH refer to the positive terminal of a battery or other power supply in a circuit. See also power and low.


initialize (a variable): a variable is initialized when a value is assigned to it for the first time. For example, the statement int led = 13; declares a variable called led and initializes it to 13. The statement assigns the value of 13 to the variable led.

input (device): an electrical component that gathers information from the world. This information could include how hard a sensor is being pressed, the current temperature, or the ambient sound level is. Input devices include switches, touch sensors, thermometers, cameras, and microphones. All sensors are inputs. In Arduino, information is collected from inputs with digitalRead and analogRead statements. The readCapacitivePin procedure used in the piano tutorial also collects information from an input (a touch sensor). See also read and output (device).

input (to a procedure) or input variable: information required by a procedure. In this book, usually a number supplied in parentheses after the procedure name in a procedure call. For example, in the statement delay(1000);, the number 1000 is the input. Input variables help programmers write procedures that are applicable to a wide range of situations. Inputs enable you to carry out the same basic set of instructions or statements, but with different values. For example, the fact that the built-in procedure delay has an input, lets you delay for different amounts of time in your programs. When you call delay with an input of 1000, your program pauses for one second. When you call delay with an input of 100, it pauses for 1/10 of a second, and so on. Similarly, in the monster tutorial, the duration input variable to the song procedure lets you play the song you created at different speeds when different values are provided as inputs.

int or int: a data type used in Arduino programs used to declare integer, or whole number, variables. Almost all of the variables and numbers used in the programs in this book are of type int. For example, the statement int led = 13; declares a variable called led of type int. See also type.


LED: short for light-emitting diode. LEDs contain an electroluminescent material—a material that glows when electrical current flows through it. LEDs are polarized. That is, they have a (+) and a (-) side and will only light up when current flows from their (+) to (-) side. If you attach an LED backwards in your circuit, it will not work. LEDs are more efficient than most other light sources. That is, they produce more light with less energy than most other types of lights. See also polarity.

logical error: an error that occurs when your code compiles and uploads, but doesn’t behave the way you want it to. These errors are the trickiest to find and fix because the computer doesn’t give you any feedback about what might becausing problems, like it does with compile and upload errors.

low or LOW: in Arduino code, the term used to refer to ground (-) in electrical circuits. Ground, (-), and LOW refer to the negative terminal of a battery or other power supply in a circuit. LOW is always 0 volts. See also ground (-) and high.


memory: where an Arduino program is stored once it’s uploaded to a LilyPad. Once a program is stored in the LilyPad’s memory, the LilyPad can run the program independently of the computer.

microcontroller: a small computer chip that stores and execute programs and controls electronics. Microcontrollers, like most computers, have a memory that is used to store programs and program data, and a processor that is used to interpret and execute programs. Microcontrollers also have pins that can be used to control input and output devices. When input and output devices like sensors and LEDs are attached to the pins, the microcontroller can read electrical signals from the inputs and send electrical signals out to the outputs. The LilyTiny board contains an ATtiny85 microcontroller and the LilyPad Arduino SimpleSnap board contains an ATmega328 microcontroller. See also pin.

milliseconds: 1/1000 of a second. 1000 milliseconds (1000 ms) is one second. The input to the Arduino procedure delay is in milliseconds. Thus, delay(1000); pauses program execution for one second, delay(100); pauses program execution for 1/10 of a second, and so on.


open source: a term used to describe a program whose source code is publicly available for you to use, examine, and modify. The sharing of open source software, also known as free software—free as in speech, not free as in beer—can enable people to collaborate on projects by helping them extend and expand on each other’s work. You are making use of open source software and open source hardware throughout this book. The Arduino software is open source and the designs of the LilyPad boards are also open source. You use open source software most directly in the Piano tutorial when you use the readCapacitivePin procedure—code that was written by someone else and published in open source fashion online.

output (device): an electrical component that takes action—does something—in the world. Actions could include lighting up, moving, making sound, or changing shape. Output devices include lights, motors, speakers, and display screens. In Arduino, outputs are controlled by digitalWrite statements. See also write and input (device).


parallel circuit: components in a parallel circuit have all of their (+) sides connected together and all of their (-) sides connected together. This configuration allows for all of the components to receive the same voltage.

pin: part of a microcontroller that can attach to and control an input or output device. Each microcontroller pin can control either an input device, like a switch, or an output device, like an LED. The pins on a microcontroller look like tiny legs coming out of the controller’s black square body. On the LilyTiny and LilyPad Arduino SimpleSnap boards, microcontroller pins are connected to sewable tabs and snaps. When an input or output device is attached to a tab or snap, the microcontroller can control that component. This book uses the terms pin and tab interchangeably. See also tab and microcontroller.

polarity: electrical orientation or direction. Electricity flows in one direction in a circuit, from (+) to (-). Due to this property, electrical circuits are said to be polarized. Electrical components with polarity will only work properly when electrical current flows through them in a particular direction, from their (+) to (-) side. LEDs are examples of components with polarity.

power (+): the positive terminal of a battery or other power supply in a circuit. Generally the highest possible voltage in a circuit. The color red is used to denote power in circuit diagrams and drawings. Note: Different circuits may have different power (+) voltages. For example, in a circuit that uses a 3-volt battery, power is +3 volts. In a circuit that uses a 3.7 volt battery, power is +3.7 volts. In Arduino code, power is referred to as HIGH. See also high and ground.

procedure: a block of code that is given a unique name. A procedure may have one or more inputs and it may return a value. When a procedure is called, the program jumps to the place in the program where the procedure is defined, executes the block of code that makes up the body of the procedure, and then jumps back to the point right after the procedure was called in the program. The Arduino language has a library of built-in procedures like delay, digitalWrite, and analogRead. You can also define your own procedures (see for example, page 76). See also input (to a procedure) and return.

program: a set of instructions to be carried out by a computer (or LilyPad). A program is written in a programming language. Programs can also be called pieces of code. A program does its work when a computer runs or executes its instructions by following them in order. See also code.

programming language: a language that enables people to write instructions for computers. Programming languages generally have limited vocabularies and very strict formatting rules. This enables them to be read and understood by machines. There are many different programming languages. You may have heard of languages like Python, Java, C++, and Scheme. Arduino programs are written in the C programming language.


read (from a pin): the act of gathering information from an input device. Information is collected via an input device attached to a pin on a LilyPad (or other microcontroller). In Arduino, information is read from a pin with the statements digitalRead and analogRead. digitalRead(pin); tells you whether the pin is HIGH or LOWanalogRead(pin); measures the voltage level of the pin and gives you a number between 0 and 1023 that corresponds to the voltage. See also write and input (device).

resistive sensor: a sensor based on changing resistance. That is, a sensor that changes its electrical resistance in response to a stimulus. For example, the touch sensor in the monster tutorial is a resistive sensor because the electrical resistance between the monster’s two paws changes when a person touches and squeezes them.

return: a procedure is said to return when it finishes executing. Some procedures return a value. That is, the procedure finishes executing and provides the results of its execution back to the program that called it. For example, the procedure analogRead(pin); returns the value it read from the input pin. See also procedure.

run: see execute.

running stitch: the most basic stitch in hand sewing. Also called a straight stitch. This stitch is created by passing a needle and thread up and down through a piece of fabric along a line. A good running stitch consists of neat, even stitches of about 1/4” (6mm) in length.


sensor: an electrical component that gathers information from the world, for example: how hard a touch sensor is being pressed, what the current temperature is, or what the ambient sound level is. Sensors include touch sensors, thermometers, cameras, and microphones. All sensors are inputs. In Arduino, information is collected from sensors with the analogRead statement. The readCapacitivePin procedure used in the piano tutorial also collects information from a sensor. See also read and input (device).

serial port: the communication channel through which a computer communicates with a LilyPad and vice versa. The serial port connection—the USB attachment between the LilyPad and your computer—allows Arduino to upload programs to your LilyPad and allows your LilyPad to send information back to your computer with Serial.println and Serial.print statements. See also communication speed.

short circuit or short: the direct electrical connection of a power supply’s (+) and (-) sides. When a short circuit occurs, the circuit’s power supply releases a tremendous burst of energy. A short circuit can ruin a battery and can electrocute or burn you if the power supply is powerful enough. The batteries you’re using for the projects in this book won’t shock or burn you even if you create a short circuit. But, if you do create one—by connecting your project’s (+) and (-) sides or by connecting other traces that should not be touching, like the trace connecting the (+) side of your LED and the trace connecting the (+) side of your speaker in the monster project—your project may not work and you may quickly ruin your battery.

statements: computer sentences; lines of code written in a programming language that tell a computer to do something. Simple statements in Arduino end with a semicolon the way that English sentences end with a period. The line digitalWrite(led, HIGH); is a simple statement. So are the lines delay(1000); and song(2000);. More complex statements can span several lines. Examples of complex statements include if statements and while loops.

switch: a circuit component that is always in one of two states: open (disconnected) or closed (connected). In a simple circuit, like the one in the bookmark tutorial, the flow of electricity through a circuit is stopped when the switch is open and restored when the switch is closed.

syntax: the rules that define the structure of a programming language. These are the spelling, punctuation, capitalization, and formatting rules you must follow when you’re writing a program. Different programming languages have different syntaxes.

syntax error: an error in a program that happens when you do not follow the programming language’s syntax. See also syntax and compile error.


tabs: the silver-rimmed holes in the sewable LilyPad boards used in the projects described in this book. On the LilyTiny and LilyPad Arduino SimpleSnap boards, tabs are connected to microcontroller pins. See also pin.

threshold: a cutoff value used in a program such that one behavior happens if a variable has a value below the threshold and a different behavior happens in the variable has a value above the threshold (see for example page 100). Thresholds are often used in conditional statements of the form if (variable < threshold) or if (variable > threshold).

trace: a conductive connection between two components in a circuit.

type: computer programs handle different kinds of information including whole numbers, decimal numbers, text, and images. Before a program can manipulate a piece of data, it needs to know what type of data it is dealing with—whether it is dealing with an image or a piece of text, for example. In most programming languages, each variable used in a program must have a specified type when it is first declared. In the projects described in this book, almost all of the variables you use are of type integer or int. They are whole numbers. In Arduino, integer variables are declared with a statement of the form int variableName; or int variableName=#;. In these statements, int specifies the variables’ type. See also variable declaration, int and integer.


upload: the act of sending code that has been compiled and converted into hex code from a computer to a LilyPad Arduino.


variable: a named location in a program’s memory that can store values. Variables enable you to give names to information and elements used in your program. They make programs easier to write, understand, and modify. Variables are generally listed at the beginning of an Arduino program. This list as analogous to the list of ingredients at the beginning of a cooking recipe. Every Arduino variable has a type that is specified when it is declared. See also variable declaration, variable initialization and type.

variable declaration: a statement introducing (or “declaring”) a variable and its type. For instance, the statement int myVariable; declares a variable named myVariable of type int, short for integer. All variables in a program must be declared before they can be used. Variables are often declared and initialized in a single statement. The statement int myVariable=13;, for example, both declares a variable called myVariable and initializes it to the value 13. See also variable, variable initialization and type.

variable initialization: a statement that gives a variable a value for the first time. For example, the statement int myVariable=13; declares a variable called myVariable and initializes it to the value 13. Variables are often declared and initialized in the same statement, but not always. The statement int myVariable=13; can be broken down into two separate statements. The statement int myVariable; declares the variable myVariable. The statement myVariable=13; initializes myVariable, giving it its initial value. See also variable and variable declaration.


write (a pin): the act of controlling an output device attached to a pin on a LilyPad (or other microcontroller) by sending it electrical signals. In Arduino, electrical signals are written to a pin with the statement digitalWritedigitalWrite(pin, value); sets the pin to be either HIGH (maximum circuit voltage, power (+)) or LOW (minimum circuit voltage, 0 volts, ground(-)). See also read and output (device).