Sketch:
Lighting Aesthetics:
Process Images:
Covering the strips with the felt and placing on the shirt before sewing them on.
Wiring
Testing
Schematic:
Survival Hugging T-Shirt
Overall:
There is a saying by Virginia Satir, a respected family therapist, “We need four hugs a day for survival. We need eight hugs a day for maintenance. We need twelve hugs a day for growth.” This Survival Hugging T-Shirt can provide attention through lights in different colours. It is able to count the hugs from 0 to 4 hugs using an IR proximity sensor.
Introduction of Physical Computing class project
​
Designed, programmed, made by
Meng-Han (Mohan) Yeh
Code:
-
/*
-
Project Title: Survival Hugging T-Shirt
-
Name: Meng-Han Yeh
-
Description: Control the 4 LED strips with the IR proximity sensor.
-
​
-
Pin Mapping:
-
Digital Pin 12 is connecting to Red Strip and controlling the Blue light;
-
Digital Pin 11 is connecting to Blue Strip and controlling the Yellow light;
-
Digital Pin 10 is connecting to Yellow Strip and controlling the Purple light;
-
Digital Pin 8 is connecting to Purple Strip and controlling the Red light;
-
Analog Input 0 (A0) is reading the IR proximity sensor.
-
Coding Credit: LedStripColorTester - for LED strips colour changing
-
​
-
*/
-
​
-
​
-
int photocell = A0; // A0 is reading the IR proximity sensor
-
bool everHugged = false;
-
unsigned long timer = 0; // set up the timer
-
​
-
int hugCount = 0;
-
​
-
#include <PololuLedStrip.h>
-
​
-
/* Create names for each of the LED strips and set up the digital pins:
-
Digital Pin 12 = ledStrip (the outer LED strip) is connecting to Red Strip and controlling the Blue light;
-
Digital Pin 11 = ledStrip2 (the second LED strip from outside) is connecting to Blue Strip and controlling the Yellow light;
-
Digital Pin 10 = ledStrip3 (the third LED strip from outside) is connecting to Yellow Strip and controlling the Purple light;
-
Digital Pin 8 = ledStrip4 (the forth LED strip from outside, the central inside heart) is connecting to Purple Strip and controlling the Red light
-
*/
-
​
-
PololuLedStrip<12> ledStrip; // the biggest heart
-
PololuLedStrip<11> ledStrip2;
-
PololuLedStrip<10> ledStrip3;
-
PololuLedStrip<8> ledStrip4; // the smallest heart
-
​
-
// set up how many LEDs on the strip you would like to control
-
#define LED_COUNT 60
-
rgb_color colors[LED_COUNT];
-
​
-
void setup()
-
{
-
pinMode(photocell, INPUT); // set up the IR proximity sensor
-
Serial.begin(115200); // set up the Serial Monitor
-
​
-
}
-
​
-
void loop() {
-
​
-
int readVal; // initialize a new integer to store the photocell value
-
readVal = analogRead(photocell); // do the analog read and store the value
-
​
-
​
-
rgb_color color;
-
​
-
// if (it has been at least 10 seconds since the last hug)
-
if (millis() >= 10000 + timer) {
-
if (readVal > 500) { // if the sensor detects the volumne above 500
-
timer = millis();
-
hugCount++; // the hugCount will plus one when the sensor detects the volumn above 500
-
Serial.println (hugCount); // Showing the hugCount in Serial Monitor
-
​
-
}
-
}
-
​
-
// if (hugCount == 0) => the beginning setting
-
if (hugCount == 0) {
-
​
-
// ledStrip => blue light
-
color.red = 51;
-
color.green = 255;
-
color.blue = 255;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip.write(colors, LED_COUNT);
-
​
-
// ledStrip2 => yellow light
-
color.red = 255;
-
color.green = 255;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip2.write(colors, LED_COUNT);
-
​
-
// ledStrip3 => purple light
-
color.red = 255;
-
color.green = 0;
-
color.blue = 204;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip3.write(colors, LED_COUNT);
-
​
-
// ledStrip4 => red light
-
color.red = 255;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip4.write(colors, LED_COUNT);
-
​
-
}
-
​
-
// if (hugCount == 1) => first hug
-
else if (hugCount == 1) {
-
​
-
// ledStrip => turns off
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip.write(colors, LED_COUNT);
-
​
-
// ledStrip2 => yellow light
-
color.red = 255;
-
color.green = 255;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip2.write(colors, LED_COUNT);
-
​
-
// ledStrip3 => purple light
-
color.red = 255;
-
color.green = 0;
-
color.blue = 204;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip3.write(colors, LED_COUNT);
-
​
-
// ledStrip4 => red light
-
color.red = 255;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip4.write(colors, LED_COUNT);
-
​
-
}
-
​
-
// if (hugCount == 2) => second hug
-
else if (hugCount == 2) {
-
​
-
// ledStrip => turns off
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip.write(colors, LED_COUNT);
-
​
-
// ledStrip2 => turns off
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip2.write(colors, LED_COUNT);
-
​
-
// ledStrip3 => purple light
-
color.red = 255;
-
color.green = 0;
-
color.blue = 204;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip3.write(colors, LED_COUNT);
-
​
-
// ledStrip4 => red light
-
color.red = 255;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip4.write(colors, LED_COUNT);
-
​
-
​
-
}
-
​
-
​
-
// if (hugCount == 3) => third hug
-
else if (hugCount == 3) {
-
​
-
// ledStrip => turns off
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip.write(colors, LED_COUNT);
-
​
-
// ledStrip2 => turns off
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip2.write(colors, LED_COUNT);
-
​
-
// ledStrip3 => turns off
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip3.write(colors, LED_COUNT);
-
​
-
// ledStrip4 => red light
-
color.red = 255;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip4.write(colors, LED_COUNT);
-
​
-
}
-
​
-
// if (the sensor detects more than 3 hugs), all lights turn off
-
else {
-
​
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip.write(colors, LED_COUNT);
-
​
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip2.write(colors, LED_COUNT);
-
​
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip3.write(colors, LED_COUNT);
-
​
-
color.red = 0;
-
color.green = 0;
-
color.blue = 0;
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
ledStrip4.write(colors, LED_COUNT);
-
​
-
}
-
​
-
​
-
// Update the colors buffer
-
for (uint16_t i = 0; i < LED_COUNT; i++)
-
{
-
colors[i] = color;
-
}
-
​
-
​
-
}