LilyPad ProtoSnap Plus Activity Guide
Before You Begin
To follow along with this guide, please install Arduino support for the LilyPad USB Plus by following the instructions in the LilyPad ProtoSnap Plus Hookup Guide.
LilyPad ProtoSnap Plus Hookup Guide
October 5, 2017
Before you begin working through the programming activities, confirm that:You are running Arduino version 1.8 or higher
You have added SparkFun Boards to Arduino’s Preferences
SparkFun AVR Boards have been installed through the Boards Manager (ProtoSnap Plus examples are available in 1.1.8 or higher, you may need to update to see them)
"LilyPad USB Plus" appears in Arduino's "Board" menu
"LilyPad USB Plus" appears in Arduino's "Port" menu (when connected through a USB cable).
All of these installations are covered in detail in Setting Up Arduino section of the LilyPad ProtoSnap Plus Hookup Guide.
Once you've installed the LilyPad USB Plus extensions to Arduino, you're ready to start programming the board!
Note that you won't have to install the extensions again, but you will need to perform the below three steps every time you want to program the board. These three steps are:
2. Select "LilyPad USB Plus" from Arduino's "Board" menu.
3. Select "LilyPad USB Plus" from Arduino's "Port" menu.
Let's go over the three steps in detail:
1. Connect the LilyPad ProtoSnap Plus to Your Computer
Place the LilyPad ProtoSnap Plus on a clean, non-metal work surface. Connect the LilyPad ProtoSnap Plus to a USB port on your computer using a micro-B USB cable. The cable can only be inserted one way, and should snap in securely.
Slide the switch on the LilyPad USB Plus to the ON position. You will not be able to upload code to the board if it is set to the OFF position.
2. Select LilyPad USB Plus from the Board Menu
If the Arduino board support was installed correctly, "LilyPad USB Plus" option will be available in the Tools > Board list under the SparkFun AVR Boards group. Open the menu and select LilyPad USB Plus. Depending on how many boards are already in the list, you may need to scroll down a bit to get to it. A dot (Windows) or check mark (Mac) will show next to the board in the menu when it is selected, and it will show next to Board in the Tools menu.
3. Select LilyPad USB Plus from the Port Menu
Arduino needs to know which port your LilyPad USB Plus is attached to so it can program it. Whenever you plug a USB device into your computer, your computer will assign it a port number. This used to be difficult to determine, but this board has a handy feature that identifies itself. Go to the Tools > Port menu, and select the port that has "LilyPad USB Plus" next to it.
On Windows ports are listed as COM##; on a Mac or Linux machine they will be "/dev/cu.usbmodem####". Your screen may look different than the image below, depending on what operating system you are using, but all should show LilyPad USB Plus next to the port address.
The LilyPad ProtoSnap Plus features twelve LilyPad components connected to a LilyPad microcontroller by conductive pathways called traces. For reference, each component on the ProtoSnap has a nearby label with its name and the number of the LilyPad USB Plus sew tab it is connected to. For more information on features and technical specs, please refer to the LilyPad ProtoSnap Plus Hookup Guide.
LilyPad USB Plus
The LilyPad USB Plus is an Arduino-compatible microcontroller similar to the LilyPad Arduino USB - ATmega32U4 Board but with some additional features and three additional sew tabs. It is currently only available on the LilyPad ProtoSnap Plus.
- USB port for connecting to a computer.
- Two sets of power (+) and ground (-) sew tabs.
- Built-in RGB LED attached to pins 12 (R), 13 (G), and 14 (B).
- A row of six white LEDs attached to pins 15-20.
- Charging circuit for single-cell (3.7V) Lithium-Polymer batteries.
What is a Program?
Programs are sets of instructions that tell a computer to do something, (also called “code” or a “sketch” in Arduino) . This could be blinking LEDs, playing sounds, making decisions based on input from sensors, or a combination of all those things.
When the computer runs a program, it will start at the first instruction, carry it out, and move on to the next one. These instructions come from a specific list of words that the computer knows. If you type in a word that the computer doesn’t know (or more likely, you misspell a word that the computer should know), you’ll get an error when you try to run your program. Don’t feel bad, this happens to everyone and is a normal part of writing programs, and we’ll provide you with some troubleshooting tips as you follow along with the activities in this guide.
In the Arduino system, you’ll write programs on your computer in a free application called the Arduino IDE (“IDE” stands for Integrated Development Environment). This is a specialized text editor with extra buttons to check and send your code to the LilyPad USB Plus at the center of your ProtoSnap board. There are lots of programming examples built into the Arduino IDE, we’ll be using some of them in these activities.
What is a Microcontroller?
The LilyPad USB Plus at the center of your ProtoSnap board contains a tiny computer called a microcontroller. It can’t do all the things that a larger computer does, but it’s very good at running programs that control simple hardware like LEDs.
Unlike larger computers, microcontrollers don’t have keyboards and screens for input and output. Most of your input and output will happen through sew tabs; the silver petals with holes in them evenly spaced around the outer edge of all LilyPad boards. Your program can control the sew tabs. It can use them for output by turning them on and off (internally connecting them to voltage or not). It can also use them for input, measuring any voltage coming from other components. It can use this information to read buttons, switches, and various sensors, and use that information to make decisions. (We’ll explore this in future activities.)
If you look closely at the sew tabs, you’ll see that every sew tab has a label next to it. These are the names of the sew tabs, which you’ll need to know to control them from your program. You might have noticed that some of the sew tabs have an “A” as part of the label, and some include a tilde or squiggle “~”. These symbols describe special features that some of the sew tabs have. We’ll tell you about these special features in future activities.
Some of the sew tabs have a “+” or “-” next to them. You can use these sew tabs to provide power and ground to LilyPad boards connected to the LilyPad USB Plus.
Sew Tabs and PinsEvery microcontroller chip has electrical connections to the board that look like metal legs. These are commonly referred to as pins. Each sew tab around the outside edge of the LilyPad USB Plus is connected electrically to one of these pins on the microcontroller chip. These connections are not as easy to see as the external connections (traces) between the USB Plus and the boards included on the rest of the ProtoSnap Plus. In this guide, we'll be referring to sew tabs when referencing the hardware and electrical connections on your ProtoSnap and pins when talking about the code that controls electricity in or out of the tabs.
Read more about the LilyPad USB Plus’s individual sew tabs and connections (including a chart) in the LilyPad ProtoSnap Plus Hookup Guide.