9. Wearables¶
Research¶
Dominic Elvin
Ying Gao
Tools¶
Adafruit Circuit Playground¶
The Circuit Playground has a variety of sensors and components built directly onto the board, including:
- LEDs: 10 RGB LEDs that you can program to light up in different colors and patterns.
- Accelerometer: Detects motion and orientation, allowing you to create projects that respond to movement.
- Temperature Sensor: Measures the temperature around the board.
- Light Sensor: Detects ambient light levels.
- Button: A tactile button for user input.
- Sound Sensor: Detects sound levels in the environment.
- Touch Sensors: Each of the 10 pads on the board can be used as a capacitive touch sensor.
Starting¶
To work with Adafruit via Arduino code you will need to download a library than later on you must include on your code.
Here's how you can download the library.
- Navigate to the Releases page
- Download the latest release
- Extract the zip file
- In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library
Once you've downloaded and you are ready to start with your code open the Arduino IDE. On top of the code just write the following:
Finding the perfect code¶
Before starting our project we needed to create the code that would do exactly what we had in mind. It was not easy since we wanted to combine many features together so we started off easy.
Magnet sensor
#include <Adafruit_CircuitPlayground.h>
int ANALOG_MAG_PIN = 10; //The analog pin for the analog output of the sensor
int DIGITAL_MAG_PIN = 9; //The digital pin for the digital output of the sensor
int mag_D; //Variable to store the digital reading
int mag_A; //Variable to store the analog
//Setup the Arduino
void setup()
{
Serial.begin(9600); //Start the serial connection to the computer
pinMode(ANALOG_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
pinMode(DIGITAL_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
CircuitPlayground.begin();
}
//This code will run infinitely
void loop()
{
mag_D = digitalRead(DIGITAL_MAG_PIN); //Read the signal from your sensor
mag_A = analogRead(ANALOG_MAG_PIN); //Read the signal from your
delay(100); //Add in 100mS of delay to slow the readings to 10 times per second
if(mag_D == HIGH)
{
Serial.print("A magnet is near: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
}
else
{
Serial.print("No magnet detected: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
}
}
Magnet sensor + light output
#include <Adafruit_CircuitPlayground.h>
int ANALOG_MAG_PIN = 10; //The analog pin for the analog output of the sensor
int DIGITAL_MAG_PIN = 9; //The digital pin for the digital output of the sensor
int mag_D; //Variable to store the digital reading
int mag_A; //Variable to store the analog
//Setup the Arduino
void setup()
{
Serial.begin(9600); //Start the serial connection to the computer
pinMode(ANALOG_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
pinMode(DIGITAL_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
CircuitPlayground.begin();
}
//This code will run infinitely
void loop()
{
mag_D = digitalRead(DIGITAL_MAG_PIN); //Read the signal from your sensor
mag_A = analogRead(ANALOG_MAG_PIN); //Read the signal from your
delay(100); //Add in 100mS of delay to slow the readings to 10 times per second
if(mag_D == HIGH)
{
Serial.print("A magnet is near: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.setPixelColor(0, 178, 34, 34);
CircuitPlayground.setPixelColor(1, 178, 34, 34);
CircuitPlayground.setPixelColor(2, 178, 34, 34);
CircuitPlayground.setPixelColor(3, 178, 34, 34);
CircuitPlayground.setPixelColor(4, 178, 34, 34);
CircuitPlayground.setPixelColor(5, 178, 34, 34);
CircuitPlayground.setPixelColor(6, 178, 34, 34);
CircuitPlayground.setPixelColor(7, 178, 34, 34);
CircuitPlayground.setPixelColor(8, 178, 34, 34);
CircuitPlayground.setPixelColor(9, 178, 34, 34);
}
else
{
Serial.print("No magnet detected: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.clearPixels();
}
}
Magnet sensor + LED and light output
#include <Adafruit_CircuitPlayground.h>
int ANALOG_MAG_PIN = 10; //The analog pin for the analog output of the sensor
int DIGITAL_MAG_PIN = 9; //The digital pin for the digital output of the sensor
int led_Pin = 3;
int mag_D; //Variable to store the digital reading
int mag_A; //Variable to store the analog
//Setup the Arduino
void setup()
{
Serial.begin(9600); //Start the serial connection to the computer
pinMode(ANALOG_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
pinMode(DIGITAL_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
CircuitPlayground.begin();
pinMode(led_Pin, OUTPUT);
}
//This code will run infinitely
void loop()
{
mag_D = digitalRead(DIGITAL_MAG_PIN); //Read the signal from your sensor
mag_A = analogRead(ANALOG_MAG_PIN); //Read the signal from your
delay(100); //Add in 100mS of delay to slow the readings to 10 times per second
if(mag_D == HIGH)
{
Serial.print("A magnet is near: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.setPixelColor(0, 178, 34, 34);
CircuitPlayground.setPixelColor(1, 178, 34, 34);
CircuitPlayground.setPixelColor(2, 178, 34, 34);
CircuitPlayground.setPixelColor(3, 178, 34, 34);
CircuitPlayground.setPixelColor(4, 178, 34, 34);
CircuitPlayground.setPixelColor(5, 178, 34, 34);
CircuitPlayground.setPixelColor(6, 178, 34, 34);
CircuitPlayground.setPixelColor(7, 178, 34, 34);
CircuitPlayground.setPixelColor(8, 178, 34, 34);
CircuitPlayground.setPixelColor(9, 178, 34, 34);
digitalWrite(led_Pin, HIGH);
}
else
{
Serial.print("No magnet detected: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.clearPixels();
digitalWrite(led_Pin, LOW);
}
}
Angle sensor
#include <Adafruit_CircuitPlayground.h>
#define SLOUCH_ANGLEMAX 30
#define SLOUCH_ANGLEMIN -10
#define GRAVITY 9.80665 // standard gravity (m/s^s)
#define RAD2DEG 52.29578 // convert radians to degrees
int currentAngle;
//int currentAngle1;
//int currentAngle2;
///////////////////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(9600);
// Initialize Circuit Playground
CircuitPlayground.begin();
}
///////////////////////////////////////////////////////////////////////////////
void loop() {
// Compute current angle
//currentAngle1 = RAD2DEG * asin(-CircuitPlayground.motionZ() / GRAVITY);
//currentAngle2 = RAD2DEG * atan2(-CircuitPlayground.motionZ() ,
// Compute current angle
currentAngle = RAD2DEG * asin(-CircuitPlayground.motionZ() / GRAVITY);
// Check if slouching
if (currentAngle > SLOUCH_ANGLEMAX || currentAngle <SLOUCH_ANGLEMIN ) {
// Sound alarm
CircuitPlayground.setPixelColor(0, 184, 134, 11);
CircuitPlayground.setPixelColor(1, 178, 34, 34);
CircuitPlayground.setPixelColor(2, 184, 134, 11);
CircuitPlayground.setPixelColor(3, 178, 34, 34);
CircuitPlayground.setPixelColor(4, 184, 134, 11);
CircuitPlayground.setPixelColor(5, 178, 34, 34);
CircuitPlayground.setPixelColor(6, 184, 134, 11);
CircuitPlayground.setPixelColor(7, 178, 34, 34);
CircuitPlayground.setPixelColor(8, 184, 134, 11);
CircuitPlayground.setPixelColor(9, 178, 34, 34);
}
else{
CircuitPlayground.clearPixels();
}
// Print current angle
Serial.println(currentAngle);
// real movement
delay(50);
}
Combining all
#include <Adafruit_CircuitPlayground.h>
#define SLOUCH_ANGLEMAX 200
#define SLOUCH_ANGLEMIN -40
#define GRAVITY 9.80665 // standard gravity (m/s^s)
#define RAD2DEG 52.29578 // convert radians to degrees
int currentAngle;
int ANALOG_MAG_PIN = 10; //The analog pin for the analog output of the sensor
int DIGITAL_MAG_PIN = 9; //The digital pin for the digital output of the sensor
int led_Pin = 3;
int mag_D; //Variable to store the digital reading
int mag_A; //Variable to store the analog
//Setup the Arduino
void setup()
{
Serial.begin(9600); //Start the serial connection to the computer
pinMode(ANALOG_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
pinMode(DIGITAL_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
CircuitPlayground.begin();
pinMode(led_Pin, OUTPUT);
}
//This code will run infinitely
void loop()
{
mag_D = digitalRead(DIGITAL_MAG_PIN); //Read the signal from your sensor
mag_A = analogRead(ANALOG_MAG_PIN); //Read the signal from your
currentAngle = RAD2DEG * asin(-CircuitPlayground.motionZ() / GRAVITY);
delay(100); //Add in 100mS of delay to slow the readings to 10 times per second
if(mag_D == HIGH)
{
Serial.print("A magnet is near: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.setPixelColor(0, 178, 34, 34);
CircuitPlayground.setPixelColor(1, 178, 34, 34);
CircuitPlayground.setPixelColor(2, 178, 34, 34);
CircuitPlayground.setPixelColor(3, 178, 34, 34);
CircuitPlayground.setPixelColor(4, 178, 34, 34);
CircuitPlayground.setPixelColor(5, 178, 34, 34);
CircuitPlayground.setPixelColor(6, 178, 34, 34);
CircuitPlayground.setPixelColor(7, 178, 34, 34);
CircuitPlayground.setPixelColor(8, 178, 34, 34);
CircuitPlayground.setPixelColor(9, 178, 34, 34);
digitalWrite(led_Pin, HIGH);
if (currentAngle > SLOUCH_ANGLEMAX || currentAngle <SLOUCH_ANGLEMIN ) {
CircuitPlayground.setPixelColor(0, 184, 134, 11);
CircuitPlayground.setPixelColor(1, 184, 134, 11);
CircuitPlayground.setPixelColor(2, 184, 134, 11);
CircuitPlayground.setPixelColor(3, 184, 134, 11);
CircuitPlayground.setPixelColor(4, 184, 134, 11);
CircuitPlayground.setPixelColor(5, 184, 134, 11);
CircuitPlayground.setPixelColor(6, 184, 134, 11);
CircuitPlayground.setPixelColor(7, 184, 134, 11);
CircuitPlayground.setPixelColor(8, 184, 134, 11);
CircuitPlayground.setPixelColor(9, 184, 134, 11);
}
}
else
{
Serial.print("No magnet detected: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.clearPixels();
digitalWrite(led_Pin, LOW);
}
}
Battery powered
As a final step we needed to make the Adafruit work without the computer power. For that we attached a battery and we were all set!
Final Project¶
Design¶
Key Elements
- LEDs: The bag includes LED lights that illuminate in response to inputs from sensors, allowing for dynamic light patterns or effects.
- Sensors: The bag reacts to various external stimuli using sensors. These sensors detect movement and react to magentic fields that trigger the lights to change.
- Magnet: A magnet was incorporated into the design, triggering one of the sensors, turning the lights on/off.
- Circuit Playground: The Adafruit Circuit Playground was used to control the sensors, LEDs, and other components. This microcontroller made it easy to program the bag to respond to different actions or inputs in real time.
- Battery: The bag is powered by a battery, which provides the necessary power for the LEDs, sensors, and microcontroller. This makes it fully portable and wearable.
- Conductive Thread: To connect the various electronic components, we used conductive thread, which allows us to sew the components (like LEDs and sensors) directly into the fabric of the bag.
Code¶
Here's the code we used for our final project.
#include <Adafruit_CircuitPlayground.h>
#define SLOUCH_ANGLEMAX 200
#define SLOUCH_ANGLEMIN -40
#define GRAVITY 9.80665 // standard gravity (m/s^s)
#define RAD2DEG 52.29578 // convert radians to degrees
int currentAngle;
int ANALOG_MAG_PIN = 10; //The analog pin for the analog output of the sensor
int DIGITAL_MAG_PIN = 9; //The digital pin for the digital output of the sensor
int led_Pin = 3;
int mag_D; //Variable to store the digital reading
int mag_A; //Variable to store the analog
//Setup the Arduino
void setup()
{
Serial.begin(9600); //Start the serial connection to the computer
pinMode(ANALOG_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
pinMode(DIGITAL_MAG_PIN, INPUT); //Make the pin you used an input on the Arduino
CircuitPlayground.begin();
pinMode(led_Pin, OUTPUT);
}
//This code will run infinitely
void loop()
{
mag_D = digitalRead(DIGITAL_MAG_PIN); //Read the signal from your sensor
mag_A = analogRead(ANALOG_MAG_PIN); //Read the signal from your
currentAngle = RAD2DEG * asin(-CircuitPlayground.motionZ() / GRAVITY);
delay(100); //Add in 100mS of delay to slow the readings to 10 times per second
if(mag_D == HIGH)
{
Serial.print("A magnet is near: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.setPixelColor(0, 178, 34, 34);
CircuitPlayground.setPixelColor(1, 178, 34, 34);
CircuitPlayground.setPixelColor(2, 178, 34, 34);
CircuitPlayground.setPixelColor(3, 178, 34, 34);
CircuitPlayground.setPixelColor(4, 178, 34, 34);
CircuitPlayground.setPixelColor(5, 178, 34, 34);
CircuitPlayground.setPixelColor(6, 178, 34, 34);
CircuitPlayground.setPixelColor(7, 178, 34, 34);
CircuitPlayground.setPixelColor(8, 178, 34, 34);
CircuitPlayground.setPixelColor(9, 178, 34, 34);
digitalWrite(led_Pin, HIGH);
if (currentAngle > SLOUCH_ANGLEMAX || currentAngle <SLOUCH_ANGLEMIN ) {
CircuitPlayground.setPixelColor(0, 184, 134, 11);
CircuitPlayground.setPixelColor(1, 184, 134, 11);
CircuitPlayground.setPixelColor(2, 184, 134, 11);
CircuitPlayground.setPixelColor(3, 184, 134, 11);
CircuitPlayground.setPixelColor(4, 184, 134, 11);
CircuitPlayground.setPixelColor(5, 184, 134, 11);
CircuitPlayground.setPixelColor(6, 184, 134, 11);
CircuitPlayground.setPixelColor(7, 184, 134, 11);
CircuitPlayground.setPixelColor(8, 184, 134, 11);
CircuitPlayground.setPixelColor(9, 184, 134, 11);
}
}
else
{
Serial.print("No magnet detected: "); //Print out the results
Serial.println(mag_A); //Print the raw analog output
CircuitPlayground.clearPixels();
digitalWrite(led_Pin, LOW);
}
}
Laser cutting¶
Material: Bioplastic
Thickness: 1 mm
CUT
Speed: 70
Min. power: 33
Max. power: 35
DOUBLE PASS
You can download here the Rhinoceros document!