Reader small image

You're reading from  The Ultimate Guide to Informed Wearable Technology

Product typeBook
Published inOct 2022
PublisherPackt
ISBN-139781803230597
Edition1st Edition
Right arrow
Author (1)
Christine Farion
Christine Farion
author image
Christine Farion

Christine Farion is a Post Graduate Lecturer at The Glasgow School of Art for MDes Inn and Interaction Design. A PhD in Smart objects in the domain of Forgetfulness, Christine has been involved in teaching computing, programming, electronics, and prototyping for over 15 years. Previously she created interactive installations internationally, and did research and support for a visual impairment charity. Her interests are memory, accessibility, and physical computing. Currently researching and creating wearable technologies, her focus is on the way we experience our environment and interact with others. This involves interaction to improve quality of life, interpersonal communication, and community well-being.
Read more about Christine Farion

Right arrow

Implementing Arduino Code Using Gemma M0 and Circuit Playground

Gemma M0, Circuit Playground, and other sewable boards are a great way to add more interaction to your wearables. As you learned in the previous chapter, their different sizes, functions, and I/O ports make them appropriate for different uses.

In this chapter, we will focus on learning through building a practical application with a Gemma M0 or Circuit Playground board so that you can expand the capabilities of your circuit. We will also explore flex sensors and the many ways to alter, use, and make them. Once you’ve considered their uses, you will connect a circuit. We will also read about how flex sensors have been used in research. Reading how components are used is a great way to inspire your projects. After that, we’ll spend some time learning about the Arduino IDE, which you’ll use to program your wearable. This will be followed by testing your circuits.

By the end of this chapter, you...

Technical requirements 

In the practical part of this chapter, you’ll use the Circuit Playground and Gemma M0 boards and create flex sensors. You’ll also connect a flex sensor and servo motor to the same circuit. To follow along, you’ll need the following items for the circuits. You can choose or swap items out from the following list:

  • A Circuit Playground/Gemma M0 board and a micro USB cable
  • Various flex sensors and a stretch sensor
  • Conductive fabrics/textiles
  • Velostat resistive plastic
  • A 10KΩ resistor
  • A servo motor
  • The Arduino IDE: https://www.arduino.cc/en/software

Prototyping accelerometer and flex circuits

Previously, we connected our Circuit Playground board and programmed its LED to blink through the Arduino IDE. Now, we’ll add to our skills by using an example from Circuit Playground and modifying it. We’ll use the built-in accelerometer for this. We have a lot of exciting ground to cover, so let’s jump straight in with our first activity.

Activity 4.1 – Hello_Accelerometer

Let’s have some fun checking out one of the sensors on our Circuit Playground board to get to know it better. The accelerometer measures motion in your wearable. We will use the included example code from Adafruit. Plug in your Circuit Playground board and choose the correct board and port, as we’ve done previously.

As a reminder, go to the Tools | Board menu and select your board. Then, go to Tools | Port and select your port. The Arduino IDE may have found your board and port when you plugged it in, so you may not...

Understanding flex sensors

Because we move in all sorts of ways, a flex sensor can be a great way to track some of that movement. Where do we bend? Elbows, wrists, fingers, toes, ankles, knees, and the waist are a few examples. We can buy flex sensors, that are of various lengths. To get an accurate reading, you need to consider the position and how you can protect the sensor. Be sure it isn’t too delicate a sensor if it is placed somewhere with vigorous bends.

In terms of sensors, you can get a carbon-impregnated conductive rubber cord or a flex sensor/bend sensor, which is like a variable resistor. As it bends, the resistance values change. There are also a variety of linear soft pot ribbon sensors, square force-sensitive resistors, circular soft potentiometers, and round force-sensitive resistors available. We will look at these in more detail in Chapter 5, Working with Sensors: All about inputs!.

By measuring the resistance, we can tell how much bend there is. We...

Research and innovation

Flex sensors are used in some of the wearables that we looked at in Chapter 1, Introduction to the World of Wearables. Their use in sports clothing and medical monitoring devices are some of the most common. Flex sensors, such as the stretchable graphene thermistors researched by Khan, Y., Ostfeld, A. E., Lochner, et al. (2015), which also detail respiration knits and patches that are used for monitoring vital signs.

Human finger tracking was explored in Ponraj, G., & Ren, H. (2018). In their paper, they observed how much human hands are used every day, including in “gesture recognition, robotics, medicine and health care, design and manufacturing, art and entertainment across multiple domains.” Other interesting research is regarding sitting postures and the health issues that may come with them. The system described by Hu, Q., Tang, X., & Tang, W. (2020) uses six flex sensors to create a “novel posture recognition system on...

Troubleshooting

Is your circuit working fine? Does your servo move when the sensor you made is pressed and flexed? If not, you may want to investigate these things first. Don’t forget that there are many great places online for resources to help you on your journey. For more information about the servo library that we used in our code, you can visit https://www.arduino.cc/reference/en/libraries/servo/. For a clear hookup guide, you can visit https://docs.arduino.cc/learn/electronics/servo-motors.

If your servo is not twisting, I would first look at the connections. Even with the colored wires, you may have put it in backward. Check your connections to see that power is going to the power pin on the Gemma M0 board. If the servo is not moving as you are expecting it to, remember that this sensor works best in one direction, or sometimes with pressure. Try flexing it in different directions to see if your flex sensor responds. If you find that your servo doesn’t move...

The Arduino IDE

We’ve used the Arduino IDE for a couple of projects, so the interface should be familiar to you. In this section, I want to cover a few basics of programming and the interface.

This section is for beginners so that they feel more comfortable with using Arduino. If you are a seasoned programmer, you may want to jump ahead to hooking up the Gemma M0 board.

Let’s take a brief tour of a few of the terms and what they are:

  • Functions
  • Variables
  • Other tips/syntax

We’ll start by looking at functions, which we covered briefly earlier in this book.

Functions

Functions are important for segmenting code into modular pieces. These perform a defined task and then return to where that code was called from. It’s useful if there are a series of steps that we want to repeat. An example is the digitalWrite() function, which we can use to write a HIGH or LOW value to a digital pin. We can write our own functions, but digitalWrite...

Summary

This has been a very busy chapter where you have been making circuits, programming them, and learning about new sensors and servos. We started by using the Circuit Playground board to explore one of the many sensors: an accelerometer. We used this onboard sensor with NeoPixels to track movement. This was a great way to see firsthand the fun we can have with NeoPixels! Using the sensors on the Circuit Playground board is a great way to add interactivity to future projects. It demonstrates that we can use the sensors onboard to test code and circuits quickly.

Then, we jumped straight into understanding flex sensors. We looked at using an off-the-shelf component, but also how we can build our own. Being able to build sensors opens a whole new world for your wearables. You can start to plan your circuits and make the sensor fit easily with the body part you desire. We also used a multimeter to help us take readings from the sensor to make sure it was working.

Lastly, we...

Further reading

To learn more about the topics that were covered in this chapter, take a look at the following resources:

Khan, Y., Ostfeld, A. E., Lochner, C. M., Pierre, A., & Arias, A. C. (2015). Monitoring of Vital Signs with Flexible and Wearable Medical Devices. Advanced Materials, 28(22), n/a--n/a. Available at https://doi.org/10.1002/ADMA.201504366.

Ponraj, G., & Ren, H. (2018). Sensor fusion of leap motion controller and flex sensors using Kalman filter for human finger tracking. IEEE Sensors Journal, 18(5), 2042-2049.

Hu, Q., Tang, X., & Tang, W. (2020). A smart chair sitting posture recognition system using flex sensors and FPGA implemented artificial neural network. IEEE Sensors Journal, 20(14), 8007-8016.

Guo, Y. R., Zhang, X. C., & An, N. (2019, August). Monitoring neck posture with flex sensors. In 2019 9th International Conference on Information Science and Technology (ICIST) (pp. 459-463). IEEE.

Hiader...

Review questions and exercises

Answer the following questions and complete the following exercises to test your knowledge of this chapter:

  1. How do we know our flex sensor is working?
  2. What happens if you name my variable something that is not allowed?
  3. Why do we use Serial Monitor?
  4. Why did we need to choose a PWM pin for the LED?
  5. Can you complete the circuits created in this chapter? Add them to a part of the body, sew them into a design, or plan where you may want to incorporate them.
  6. Spend some time planning a flex sensor for a different part of the body. What do you need to consider if you are planning for a finger? For the knee? How will these sensors differ? Be aware of the size differences and the pressure or flex on different parts of the body. The knee will need to track a wider movement, but the finger will involve smaller, more precise movements.
lock icon
The rest of the chapter is locked
You have been reading a chapter from
The Ultimate Guide to Informed Wearable Technology
Published in: Oct 2022Publisher: PacktISBN-13: 9781803230597
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Christine Farion

Christine Farion is a Post Graduate Lecturer at The Glasgow School of Art for MDes Inn and Interaction Design. A PhD in Smart objects in the domain of Forgetfulness, Christine has been involved in teaching computing, programming, electronics, and prototyping for over 15 years. Previously she created interactive installations internationally, and did research and support for a visual impairment charity. Her interests are memory, accessibility, and physical computing. Currently researching and creating wearable technologies, her focus is on the way we experience our environment and interact with others. This involves interaction to improve quality of life, interpersonal communication, and community well-being.
Read more about Christine Farion