In this chapter, you’ll learn about e-textile toolkits. You will start by learning about the toolkits available, as well as some sewable components you can use.
We will begin by exploring LilyPad components and how we can connect them. Then, we will learn about Flora, Gemma, Circuit Playground, and other e-textile toolkits. We will also examine the differences and why you may choose one board over another.
Once you have a grasp of these toolkits and boards, as well as their capabilities, we can make electronic circuits. This will lead to using the Arduino IDE to program interactive elements into your designs. We will finish by setting up the software that will be needed throughout this book.
By the end of this chapter, you’ll understand what e-textile toolkits are, and how we can use them to start creating and learning about wearables. You’ll be able to choose an e-textile board confidently that suit your projects. Lastly, you’ll have the Arduino IDE installed on your computer so that you can make more intricate electronic wearable circuits later in this book.
In this chapter, we’re going to cover the following main topics:
This chapter has a practical element where you will experiment with circuits. You will need the LilyTwinkle ProtoSnap Kit for the circuits. It contains the following items, which you may choose to swap out or purchase separately:
For the last activity, we will use a Circuit Playground board, the Gemma M0 board, and the Arduino IDE, which is available for free at https://www.arduino.cc/en/software.
The LilyPad boards were the most widely known and were developed for creating wearable circuits. However, as we’ll learn, there are a variety of microcontroller boards to suit our projects. Many are based on the Arduino board with ATMEL chips. Therefore, we can use the Arduino integrated development environment (IDE) to program them. Learning about the different types of e-textile kits will help you with planning and making future wearable circuits.
A microcontroller is a small single-purpose computer with an integrated circuit (IC) that’s made up of a processor, memory, and connections for inputs and outputs. It will store and run a program that we upload to it. Most of the boards have a reset button and a way to connect power to it.
A key feature of e-textile toolkits is that they all can be integrated into our wearable designs easier than traditional microcontroller boards.
The LilyPad Arduino was one of the first commercially available wearable Arduino-based microcontrollers. It was created at the MIT Media Lab by Leah Buechley. The board was released by SparkFun in 2007. This board spawned a movement of makers and creatives and over time, it helped launch a variety of boards and components. The unique feature of this board is that it has petals, or sewable tabs, so that we can connect our soft circuits to it. It has inputs and outputs, and we can integrate them into our electronics projects with conductive thread.
There are three varieties of LilyPad e-textiles:
First, let’s look at the non-programming options: the simple sewable circuits.
The simple sewable range contains several items. There is a simple coin cell battery holder, similar to the ones we’ve been using, that has no switch. There is also a switched version.
Part of the LilyPad range includes colored LEDs, an RGB tricolor LED, and a Lily Pixel. Lastly, there are also buttons, reed switches, and slide switches that we can put in our circuit. Figure 3.1 shows some of the available LEDs, battery holders, and switches:
Figure 3.1 – LEDs, buttons, switches, and battery holders
You can configure these components into circuits for some basic but fun prototypes. Using conductive thread, you can get started with very little extra knowledge required.
The pre-programmed boards from LilyPad are LilyTiny, LilyTwinkle, LilyTwinkle ProtoSnap, and LilyMini ProtoSnap. The ProtoSnap range provides kits on a board; Figure 3.2 shows the ProtoSnap kit. The ProtoSnap version is already connected so that you can test the circuit before you sew it:
Figure 3.2 – ProtoSnap kit with power
LilyTiny is pre-programmed with different patterns for LEDs. Each of the four sew tabs, numbered 0 to 3, has a different effect. It’s a fun way to get effects quickly and easily into a circuit. There’s also LilyTwinkle. As its name suggests, it adds sparkle to your projects. This mini board is pre-programmed with random effects to mimic a twinkling star effect.
This board also has four sew tabs for sewing your LEDs to it. You can get this board on its own, or in the ProtoSnap version. We will be using this board to create a twinkling wearable in Activity 3.1 – twinkling circuits.
Lastly, there are programmable LilyPad Arduino boards, as shown in Figure 3.3. These are the boards that will bring your projects to life with interactivity. They all have a few differences. These can be purchased from http://proto-pic.co.uk or http://sparkfun.com, and other electronics retailers:
Figure 3.3 – LilyPad programmable boards – Main, Snap, and USB Plus
The LilyPad Arduino 328 Main board has the most sew tabs for your projects. Figure 3.4 shows a bag I modified where I used the LilyPad Main board to add interactivity. The board has 14 digital I/O pins and 6 analog input pins. It has the most I/O pins of all the e-textile toolkit boards. This means that it’s a great board for those projects that have a lot of interaction and components connected. It operates at 2-5V. It has a special connector called an FTDI for its programming interface, so you need to have an FTDI cable to use this board with your computer:
Figure 3.4 – Message Bag with a LilyPad Arduino 328 Main board
Some research on the Message Bag is available in the paper, Did you Pack your Keys? Smart Objects and Forgetfulness, by Farion, Christine & Purver, Matthew (2014). Conference on Human Factors in Computing Systems - Proceedings. 539-542. 10.1145/2559206.2574809: https://www.researchgate.net/publication/265652238_Did_you_Pack_your_Keys_Smart_Objects_And_Forgetfulness.
Input and Output Pins
To fully appreciate these boards, we need to understand what an input/output (I/O) pin is. An I/O pin is how we connect our components between the microcontroller and our circuit. We control these pins through programming.
In the Arduino IDE, we configure how the pin is used – is it for output or input? The digital pins use digital signals. This has two values, HIGH and LOW, which is the equivalent of ON or OFF, or 1 and 0. An analog pin has a numerical range of values, and most Arduino boards have pins A0 to A5 as usable analog pins.
The LilyPad Arduino USB is my preferred board from the LilyPad suite. It’s very easy to connect as it uses USB for the programming interface, and it has enough I/O pins that you can create a complex project. It has 10 digital pins and 4 analog pins or sew tabs. This board operates at 3.3V. Figure 3.5 shows the LilyPad Arduino USB board in a near-body wearable prototype:
Figure 3.5 – A 1950s upcycled handbag prototype with a LilyPad Arduino USB
Another Lilypad board is the Simple Snap board. This has fewer sew tabs, with 5 digital I/O pins and 4 analog pins. It has an on/off switch and an onboard chargeable battery. The charge circuit is also on board, so it’s very convenient and ready to be put into your projects. Also, because of the snap tabs, you can sew the snaps on many different prototypes and then just snap them off the board and use them in another project.
There is a modified version of the USB board, the LilyPad USB Plus, which has 10 digital I/O pins and 7 analog pins. It connects with a micro USB. The USB Plus has an RGB LED in the middle, and a row of six white LEDs that can be used as indicator lights.
Lastly, there is a specialist board known as the LilyPad MP3 player. It has an onboard LiPo charger, headphone jack, SD card socket, and stereo audio amplifier.
To complete our tour of the LilyPad e-textile range, let’s look at the sewable components that are available for enhancing the circuits we make. Figure 3.6 shows the components in the range. There are temperature, light, and accelerometer sensors, as well as buzzers and vibration boards for output:
Figure 3.6 – Components in the LilyPad range
The LilyPad range of boards and components allows us to be flexible in planning wearable designs. It’s a good place to start our prototyping. However, before we jump in, let’s create a circuit to try things out. Then, we will learn all about the Flora, Gemma, and Circuit Express boards. Once we have learned about them, you can decide which board is right for your projects.
Let’s take a closer look at one of the pre-programmed boards, the LilyTwinkle. Activity 3.1 is where we will make the circuit!
As we learned in the previous section, there are pre-programmed boards in the LilyPad e-textile range. One of those boards, the LilyTwinkle, will add some shimmer to our circuit. The components in this activity are from http://proto-pic.co.uk, who provides an extensive range of components for making wearables.
The items needed to make this circuit are shown in Figure 3.7. These are the LilyTwinkle board, four sewable LEDs, a battery holder (with an on/off switch), conductive thread, a sewing needle, and some fabric:
Figure 3.7 – Items for Activity 3.1
I usually map my circuit out on the fabric before I begin to ensure I won’t make any errors. Don’t forget that you can also use your crocodile clips to test it if you are using the standalone pieces and not the ProtoBoard version.
Sometimes, the pieces have rough edges. I like to take a moment and just softly sand down the edges so that they are nice and round. You can do this with sandpaper or a nail file, as shown here:
Figure 3.8 – Smoothing rough edges
Follow these steps to make the sewable circuit:
Figure 3.9 – The completed ground circuit
Now, it’s time to sew the positive (+) sew tabs of your LEDs to the LilyTwinkle :
Figure 3.10 – The final LilyTwinkle circuit
Now that we’ve got our LilyTwinkle board working, we can jump straight into learning about other sewable circuit boards.
In this section, we will look at the exciting choices we have for creating wearable designs with circuit boards designed specifically for this purpose. Here, we will look at Adafruit Industries in New York, founded by Limor Fried in 2005 (Ladyada) and certified as A Minority and Woman-owned Business Enterprise (M/WBE). We will look at their sewable circuit boards, including Flora, Gemma, and Circuit Playground.
We’ll learn about the differences between these microcontroller boards. Then, we’ll explore a range of components that connect to our circuits to add interactivity. Finally, we will investigate other systems that you may want to learn about through your research.
We will cover the following topics:
Let’s get started.
Let’s start with the Adafruit Flora board (currently V3 – https://www.adafruit.com/product/659). Flora is a round, small, 1.75” diameter, sewable Arduino-compatible board. It has sew tabs so that you can easily connect it to a circuit. It uses a USB (micro USB) to plug in and program it. The board has a reset button, battery connector, and power switch. Figure 3.11 shows some of the Flora range:
Figure 3.11 – Flora system
The Flora has four indicator LEDs and an RGB NeoPixel. One is for indicating power, the LED allocated to a digital signal shows bootloader feedback, and an LED for data received and transfer rx/tx. It has 14 sew tabs for connecting components, inputs, and outputs. It is a flat board so that it doesn’t snag on fabric and offers very good value for money.
The Flora board is black, which looks great in most projects! Some of the Flora components that can add interactivity to your wearables include a color sensor, a wearable GPS module, RGB NeoPixels, a Bluetooth Low Energy (BLE) module, a UV index sensor, a lux light sensor, a sewable 3-pin JST wiring adaptor, and an accelerometer/gyroscope/magnetometer. A JST is a type of connector for connecting electronics, with the standards originally developed by J.S.T. Mfg. Co. (Japan Solderless Terminal).
A NeoPixel is like a super LED. It is bright and chainable, and you can individually control each one that you add. We will look at these amazing LEDs in detail in Chapter 6, Exploring Reactions Through Outputs. The GPS module is for outdoor location-aware projects that you may want to explore making. Flora Lux Sensor senses infrared, full-spectrum, and human-visible light. I’ve played around with the color sensor as a fun way to add color-matching interaction to a project.
The color sensor is shown with a NeoPixel strip in Figure 3.12 in an electronic jewelry piece I made:
Figure 3.12 – Color sensor and NeoPixels
Lastly, the 3-pin wiring adaptor is a very handy component and such a great idea. With it, you can attach modules a lot quicker and more securely in your circuits.
The Adafruit Gemma M0 board (https://www.adafruit.com/product/3501) is small, 1.1” round and has sew tabs for easily connecting components with conductive thread. Often, it’s exactly the right size for a wearable project that may only need a few inputs/outputs.
We can use this board with the Arduino IDE. It also has USB support and there is a built-in RGB DotStar LED and sew tabs. Three of the sew tabs can be used as hardware-capacitive touch sensors. You can use NeoPixels on any pins with enough memory to drive thousands:
Figure 3.13 – Gemma M0 in the planning phase (left) and a circuit (right)
In Figure 3.13, the Gemma M0 board has been placed on paper to help map out the wearable circuit. I’ve mapped the connections that I’ll be using and how they will work together.
When I remove the parts to put them in my circuit, I’ll still have my drawn map to follow. There is also an image of the Gemma M0 in the completed circuit, with a lot of soldered wiring to it. Soldering your circuits is a good way to preserve them when you want to make them durable.
The Gemma M0 is a fun board that allows you to create discreet circuits due to its small shape. The size is not an indication of its power as I was able to run many NeoPixels and a color sensor off this little board. You can do a lot more.
Now, let’s look at the Circuit Playground boards, which allow you to take prototyping to a whole new level!
These boards were launched in 2015 and have been improved over time. There are currently three boards available and they have different features:
Figure 3.14 – Adafruit Circuit Playground e-textile boards
The Classic board provides all the base components, as do the other two boards, the Circuit Playground Express, and Circuit Playground Bluefruit. The Classic board consists of the following:
It operates at 3.3V and uses a micro USB to connect. The Circuit Playground Express (CPX) has all the same components (listed previously) as the Classic, but it also includes an infrared receiver and transmitter. It receives and transmits remote control codes while sending messages between Circuit Playground Express boards. It also acts as a proximity sensor. The Express board has 7 (not 8) touch capacity inputs; the other pin is a true analog output for sound.
There are 10 NeoPixels around the board perimeter. They turn green when the bootloader is running, and they will turn red if it has failed to initialize. These boards also have a large library of code, tutorials, and resources.
This makes them a great starter board due to the amount of support available. Getting crocodile clips to connect other sensors and outputs is a quick way to start prototyping. Figure 3.15 shows the components on the Circuit Playground board (image courtesy of www.adafruit.com):
Figure 3.15 – Mapping the Circuit Playground functions
The following table states the pins that the sensors are using. It also lists their components and General-Purpose Input/Output (GPIO) numbers:
Item |
GPIO Pins Analog/Digital |
Speaker (can be turned off). |
D11 |
You can use pin A0 as the true analog out, which has a connected amplifier. |
A0 |
A light sensor that reads between 0 and 1023. A higher reading means higher light levels. |
A8 |
Temperature. |
A9 |
Button on the left. |
D4 |
Button on the right. |
D5 |
Slide switch. |
D7 |
Infrared transmitter. |
D29 |
Infrared receiver. |
D39 |
Can be used for basic IR proximity sensing using the raw analog value from the LED. |
A10 |
Table 3.2 – Pin use for Circuit Playground Express
The pins listed (except for A0) in the preceding table are all configured internally. This means that these pins are not connected with the sew tabs that we use to attach our components. There are no conflicting pins. The pins that are physically visible on the board are all freely available for us to use in our circuits.
As we can see, Circuit Playground is a powerful board and addition to any wearable project. We will explore using this board in Chapter 4, Implementing Arduino Code Using Gemma M0 and Circuit Playground.
There are other e-textile components and items available. Some of them have been discontinued or aren’t as widely used, so I haven’t featured them here. You may want to continue exploring some of these other platforms as it’s always a good idea to know what is available. A good place to start is Kitronik: https://kitronik.co.uk/.
They have many educational resources and make many wearable components, some of which are shown in Figure 3.16, that cost a lot less than others. It can be a great way to begin on a budget:
Figure 3.16 – Kitronik components
Now that we’ve looked at the different e-textile boards, let’s compare them and understand which boards might be the most appropriate for our wearable designs.
These comparisons and observations are largely from my experiences with using different systems across a variety of projects. It also comes from reading a lot of research projects and developmental workshop information, to learn about other people’s perspectives and uses for these boards.
The LilyPad boards are usually purple and have a petal-style design. The Flora has larger sew tabs so that you can easily use your crocodile clips on them. In addition, the board is black, which I like for my circuits. The Gemma M0 is also black, and the size makes it a great fit for hiding in clothing easily.
You may want to consider choosing a board that has a lot of support and resource materials. Some boards have extensive libraries, for example, and great documentation. Also, I have found some boards difficult to source. From researching these boards, it looks like the LilyPad Arduino USB Plus will be the LilyPad board to support. Some of their other boards are being discontinued, so that may influence your decisions about projects and adaptability.
For functionality and features, you can’t get better than the Circuit Playground boards. With the huge number of embedded sensors and features, these are a great way to start creating wearables – you can start getting creative right away!
When choosing a board, there will be trade-offs. You may want more pins, but it might be a larger board and might cost more too. Most of the boards have an LED on pin 13 and a reset button.
The e-textile board I have been using the most due to its size and being able to prototype smaller fun projects is the Gemma M0. It’s a great board for the cost and you can have a lot of fun with it. It can be such a quick way to add NeoPixels to your designs! Now, let’s choose a board for our projects.
Now that we’ve had an introduction to some of the many different offerings from the boards made for wearables, it’s time to choose one! But how can you decide when you’re just starting? Here are some questions to help guide you through the process.
Think about what you want your wearable to do – what is the minimum feature set or interactivity that you want from this circuit? Plan your inputs and outputs – we will look at a huge variety of I/O components in Chapter 5, Working with Sensors: All About Inputs!, and Chapter 6, Exploring Reactions Through Outputs. So, don’t worry just yet if you aren’t sure. You can come back to the following table later to clarify the objectives for your wearable design:
Input – what would the wearable sense from the environment? |
Output – how would your wearable react to what it senses? |
Placement of the wearable – where would it be located? Is it an on-body or off-body system? Could it be used in more than one place? How close is it to the body? |
Is the size of the wearable appropriate for its placement? |
Cost of your project? Do you have a budget? |
Connectivity with batteries/for programming? |
Visibility? Do you want your circuit on show or to be hidden? |
Table 3.3 – Guide for selecting an e-textile board
Often, when we prototype, we don’t need to prototype the entire project at once. Try to get one aspect of your design working. Then, progress by adding to it and making it more complex if needed. We will look at the prototyping process in more detail in Chapter 8, Learning How to Prototype and Make Electronics Wearable.
Now that we understand these e-textile systems, let’s get the Arduino IDE set up on our computer so that we can advance our wearables knowledge further. We will be able to program interactivity through the Arduino program, which will bring our wearables to an entirely new level!
Looking back at the simple LED circuits we’ve been discussing, they are good for understanding how an electronic circuit works. If we only ever wanted a simple LED to turn on or off, then we’d be done. But we’re here to do something a lot more fun. Using a microcontroller will add interactivity – and life – to our wearables!
Let’s set up the software that we’ll use for all our circuits in this book and beyond. We’ll be using the Gemma M0 and Circuit Playground boards for many of the wearable designs. As mentioned previously, the Gemma M0 is a small-sized board that is great for wearables because of its size. It has enough sew tabs for input and output. The Circuit Playground board has a larger number of possible connections, so we can use it for more complex circuits. It also has a lot of sensors on the board so that we can use it without connecting anything as we get started. So, with these boards in mind, let’s walk through installing Arduino and setting it up.
This is a free application that you can download from https://www.arduino.cc/en/Main/Software. Be sure to download it from the official website. There are usually updates to the software, so choose whatever the most recent version is when you visit the site. The following screenshot shows version 2.0, which I’ll be using throughout this book:
Figure 3.17 – Arduino version download
Choose the correct version for your operating system. Download and install it with the correct installer for your computer. This will open the Save dialog box for you, where you can save the file:
Figure 3.18 – Saving Arduino to your computer
When the download is complete, open the file. A dialog box will appear, asking you to agree to the terms of service. Choose your install location:
Figure 3.19 – License Agreement and Choose Install Location
Once you click Install, the program will install to your chosen location. At this point, you will be presented with the complete setup window:
Figure 3.20 – Installing Arduino and the setup complete
Click to Finish the install. Now, let’s look at the program and connect our Circuit Playground board.
The Arduino IDE can be used with all the Arduino devices and many other versions of Arduino-compatible boards. It has a built-in code editor where you can test your code and see problems with the code in a message window. As shown in the following screenshot, from left to right, the main program buttons allow you to check your code (verify it), upload your code, create a new sketch, debug, open, and save. The furthest icon on the right-hand side, which looks like a magnifying glass, allows you to open the serial monitor. We will look at the serial monitor in more detail later:
Figure 3.21 – Arduino buttons in the interface
There are other ways you can program an Arduino, but I’ll be using the Arduino IDE throughout this book.
To configure the IDE to work with your circuit, you need to check three important settings. This allows your computer to communicate with your microcontroller board. You need to check the following:
To select the board and port, we need to plug our board in. The port on the board communicates with a port on your computer when you plug it in. It’s how the devices speak to each other. Plug your board in now.
Check Your Cable
Many people, myself included, have problems because they are using a charge-only USB cable. These will not work! We need a data/sync cable. You must have a good-quality syncing cable.
There is a board and port drop-down area in the center of the main program bar where we can choose the board we are using. Hopefully, Arduino will have found it for us. The following screenshot shows that Arduino has found Adafruit Circuit Playground on COM33:
Figure 3.22 – Finding the board you are using
However, the Arduino IDE doesn’t always find the board and port. You can specify it yourself by going to Tools | Board and then choosing the board you are using; for example, Adafruit AVR Boards:
Figure 3.23 – Selecting your board
Next, choose the correct port by opening Tools | Port and looking for the COM port for Windows users. On a Mac, it is a /dev/tty.usbmodem or /dev/tty.usbserial port with numbers:
Figure 3.24 – Choosing the correct port
Don’t forget that if your board isn’t plugged in, it won’t show up. I know it sounds obvious, but I can’t tell you how many times someone changes something in their circuit, unplugs it, and forgets to plug it back in!
Now, let’s have some fun and get a little piece of code running on our Circuit Playground board.
Learning a new programming language comes with the tradition of Hello World. It’s a way to make the simplest program possible to demonstrate that the system is working. The Arduino equivalent is a blinking LED, usually on pin 13. It’s the Arduino communicating to the world. It lets you know that your hardware and software are configured and working.
We will start by blinking an LED so that we can work through any issues if it doesn’t work. We don’t need to hook anything up for this; the Circuit Playground board has an LED on pin 13. We can use an example sketch that will blink the LED for us.
Go to File | Examples | 01.Basics | Blink. This will open a sketch called Blink, as shown in the following screenshot. When we write a program in Arduino, it’s called a sketch:
Figure 3.25 – Opening the Blink sketch
Looking at the code that is in the sketch, we can see it is minimal with only nine lines. We will look at it in detail after we upload it to our circuit board. This is the sketch almost all learners start with:
void setup() { pinMode(LED_BUILTIN, OUTPUT); } void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); }
Let’s upload it to our board and see it working, then look at it in more detail. To upload the code to the board, click on the second icon or the arrow facing right, as shown in the following screenshot. Your board must be plugged into your computer and the correct board and port must be selected. If you’ve done this correctly, you should see the board’s name in the drop-down menu:
Figure 3.26 – The Upload button and the board selected
This will take a few seconds. We can see the progress in the Output window. It will inform you of the percentage of bytes your program used, and the maximum available.
You should see an upload complete message in the Output window, as shown in the following screenshot. If you see this message, you should also see a red LED blinking on your board. We’ve done it!
Figure 3.27 – Output window
Let’s take a closer look at the Blink sketch and its parts before we look at troubleshooting any issues that may have happened. There are two main areas in an Arduino sketch: the setup() function and the loop() function. The setup() and loop() functions are the skeletons of every Arduino program. Let’s look at them closer:
void setup() { pinMode(LED_BUILTIN, OUTPUT); }
The setup() function runs once when you power up the board or press the reset button. The function is called when the sketch starts. This is where we initialize the components that we will be using in the code.
The setup() function sets initial values for variables, pin modes, and libraries. In this setup() function, we are defining that we are going to use the pin that the LED is connected to as an output. In this case, it is pin 13.
What is pinMode(pin, mode) for?
This sets a digital pin as either an input or an output. We need two parameters: the number of the pin and its mode, INPUT or OUTPUT. We put this command in setup() so that the pin’s behavior is determined at the start of the program.
Following that, the loop() function runs. It repeats over and over, allowing your program to respond to inputs and outputs. It will control what the microcontroller does.
Let’s take a closer look at the loop() code block in the Blink sketch:
void loop() { digitalWrite(LED_BUILTIN, HIGH); delay(1000); digitalWrite(LED_BUILTIN, LOW); delay(1000); }
What is digitalWrite(pin, value) for?
In the Blink code, we use digital pins. We are setting it HIGH, to turn the LED on. This command is used to control a digital output pin. The first parameter is which pin you would like to control. The second is the value you want to set, which can be HIGH or LOW. HIGH will turn the pin on, sending out V+ at 40mA, while LOW will turn the pin off.
What is delay() for?
This is the amount of time to delay your program. Currently, it is 1 second, noted as 1,000 milliseconds. The delay() function will bring most of the other activities to a halt. For example, it won’t read other sensors.
Try changing the microsecond amount, then upload the code again. Watch how the blink pattern changes. After the delay(1000) statement, there is another digitalWrite() function. This time, it sets the pin to LOW, meaning it won’t send the LED on pin 13 any power, turning the LED off.
That’s the basics of this first Blink sketch described. Looking through the code, I’ve mentioned functions. It’s important to understand what their purpose is. So, let’s look at functions in a little more detail.
A function is a way of organizing the code/instructions for the program that will go on your microcontroller. We can group statements and code blocks in a function. There are many pre-written functions in Arduino that can help us quickly program our boards.
Note
Also, notice that each statement finishes with a semicolon, ;. They are called a terminator, and it tells Arduino that we have finished with that statement. Your code will display an error if you forget to include it.
Another important aspect that you’ll see in most code that you download or load from Arduino is that it will have comments in it. These are important to a sketch and worth discussing.
You’ll notice there are other lines of text in the Arduino Blink sketch. These are comments. There is an initial multiline comment at the top and then there are several inline comments. A single-line comment uses // before the text you want in the comment. If you write // at the start or end of the code line, they are also referred to as an inline comment. A multiline comment is written between /* and */. These are not read by the program but are there to help us know more about the program.
I use comments a lot to remember code I have tried or code that needs to be changed. If I want the code to remain there but not be used, I can comment it out by using a multiline comment. The multiline comment at the top of your sketch is useful for providing notes, dates, attribution, and sometimes pinout information. Comments can also be used to remove lines of code, which is a useful way to remember what you tried.
Lastly, there is a Sketchbook in Arduino where your code is saved. This is saved inside the Arduino folder in your computer’s Documents folder. You can access these in the Sketchbook dropdown in the File menu. You can change this location in the Arduino IDE settings.
Sometimes, we get error messages. The one you might see after trying to upload code is Cannot run program "{runtime.tools.arm-none-eabi-gcc.path}inarm-non-eabi-g++". This likely means that you are missing an important installation, in which case you must ensure that the Arduino SAMD boards package has been installed on your system. It is important to have both the Arduino and Adafruit SAMD board packages installed.
To fix this, you can navigate to the Tools | Board | Boards Manager menu, as shown in the following screenshot, but you can also click on the second icon down on the left-hand side of the program.
Figure 3.28 – Accessing Boards Manager
The second, quicker way to access the Boards Manager window is using the left-hand side menu. The icon that looks like a circuit board (highlighted in the following screenshot) opens Boards Manager too. This icon will open a side panel, as shown in the following screenshot, and a search bar. Type Adafruit SAMD in the search bar and when the entry appears, click on Install:
Figure 3.29 – The opened Boards Manager
You’ll see confirmation of when the boards have been installed:
Figure 3.30 – Confirmation that the boards have been installed
Once you have both the Arduino SAMD and Adafruit SAMD board packages installed, the error message should stop. This will also install the Gemma M0 board for us to use in later activities. Your project should now be working – and that brings this chapter to a close!
This chapter explored the e-textile boards and kits that we can use to get up and running with our wearable circuits. We explored their differences and uses and how you can make decisions about which board will be a perfect fit for your projects. The Gemma M0 board is a great little board to start a project with due to its size and affordability, and the Flora gives us a few more options to add more interactivity to our wearables.
The Circuit Playground range of boards offers huge interaction possibilities in our projects due to their huge feature sets. At the time of writing, there isn’t a more comprehensive board on the market. We also learned about the LilyPad range of components, which allows us to add sewable sensors easily. The pre-programmed boards allow us to create fun circuits that only require sewing. Then, we learned about the LilyPad boards with I/O pins, which can be useful for expanding the projects we create.
We finished by installing the Arduino IDE, which we will need throughout this book, and uploading our first program. With that, we saw how easily we can get functions working on a Circuit Playground board. In the next few chapters, we will continue our development with this board and others.
Spend a little time thinking about the sensors we looked at in this chapter. What types of projects could you plan out that would use them? Sketch some thoughts and ideas in a notebook – don’t hold back. Make them as imaginative as possible because your skillset will develop, and you will be creating inspiration for yourself in later circuits!
In the next chapter, we will get busy with the Gemma M0 and Circuit Playground boards. These are likely to be the ones you choose most in your projects, so it’s important we expand our knowledge about them. We will be creating a stretch/flex sensor and reading the data we get from it. It’s going to be a busy and fun chapter!
Answer the following questions to test your knowledge of this chapter:
18.222.120.133