Introduction: Interactive Sleeves - LED Fire Animation

About: Student Interaction Design at HKU located in The Netherlands.

A fire starts when a person or object comes near your arms. It literally creates the spark between you and another person.

Step 1: Step 1: Assemble Materials

What you'll need is:

  • Ardiuno
  • 2x HC-SR04 Ultrasonic Sensors
  • WS2812B RGB LED strip
  • Electric wire (regular electric wire or sewable conductive thread)
  • Soldering iron and solder
  • Faux fur (with a minimum polm length of 6cm)

Step 2: Step 2: Setup

The photo above shows the setup of the project.

The circuit should be setup as follows: Connect a red wire from the 5V pin on the Arduino to the positive channel of the breadboard. Connect a black wire from the GND pin on the Arduino to the negative channel of the breadboard. Now connect all the negative sides of the sensors to the negative channel of the breadboard and all the positive sides to the positive channel of the breadboard.

  • HC-SRO4 Ultrasonic Sensor No.1:

Trig = pin 7

Echo= pin 6

  • HC-SRO4 Ultrasonic Sensor No.2:

Trig = pin 5

Echo = pin 4

  • LED Strip No. 1:

DI = pin 12

  • LED Strip No. 2:

DI = pin 11

Step 3: Step 3: Measuring and Cutting the LED Strips

Measure the sleeves of the sweater and cut the LED strips to the correct length.

Step 4: Step 4: Attach the LED Strips and Ultrasonic Sensors

Attach the LED strips and ultrasonic sensors to the sleeves. You can do this by sewing it or gluing it on. Attach the ultrasonic sensor in the space between where your elbow and shoulder would go.

Step 5: Step 5: Measuring

Decide where you want to put your Arduino. You can keep it in your pocket or attach it to the inside of your sweater. A Lilypad Arduino is the most suitable if you choose to attach it to your clothes. Once you've made your decision start measuring and cutting the electric cables.

Step 6: Step 6: Soldering

Now start soldering everything together like in the circuit given in step 2.

Step 7: Step 7: Code

#include "FastLED.h"

#define NUM_LEDS 20

CRGB leds[NUM_LEDS];

CRGB secondleds[NUM_LEDS];

#define PIN 11

#define SECONDPIN 12

const int trigPin1 = 5;

const int echoPin1 = 4;

const int trigPin2 = 7;

const int echoPin2 = 6;

long duration1;

long duration;

int seconddistance;

int heatramp1;

int distance;

void setup()

{

pinMode(trigPin1, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin1, INPUT); // Sets the echoPin as an Input

pinMode(trigPin2, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin2, INPUT); // Sets the echoPin as an Input

FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );

FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );

}

// *** REPLACE FROM HERE ***

void loop() {

Fire1(60,120,20);

Seconddistance();

Distance();

}

void Seconddistance(){

// Clears the trigPin

digitalWrite(trigPin1, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin1, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin1, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration1 = pulseIn(echoPin1, HIGH);

// Calculating the distance

seconddistance= duration1*0.034/2;

}

void Distance(){

// Clears the trigPin

digitalWrite(trigPin2, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin2, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin2, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin2, HIGH);

// Calculating the distance

distance= duration*0.034/2;

if (seconddistance <= 60){

FastLED.setBrightness(255-(seconddistance*4.25));

}

if (distance <= 60){

FastLED.setBrightness(255-(distance*4.25));

}

else if (distance > 60 and seconddistance > 60){

FastLED.setBrightness(0);

}

// Prints the distance on the Serial Monitor

Serial.print("Distance: ");

Serial.println(seconddistance);

}

void Fire1(int Cooling, int Sparking, int SpeedDelay) {

static byte heat[NUM_LEDS];

int cooldown;

// Step 1. Cool down every cell a little

for( int i = 0; i < NUM_LEDS; i++) {

cooldown = random(0, ((Cooling * 10) / NUM_LEDS) + 2);

if(cooldown>heat[i]) {

heat[i]=0;

} else {

heat[i]=heat[i]-cooldown;

}

}

// Step 2. Heat from each cell drifts 'up' and diffuses a little

for( int k= NUM_LEDS - 1; k >= 2; k--) {

heat[k] = (heat[k - 1] + heat[k - 2] + heat[k - 2]) / 3;

}

// Step 3. Randomly ignite new 'sparks' near the bottom

if( random(255) < Sparking ) {

int y = random(3);

//heat[y] = heat[y] + random(160,170);

heat[y] = random(160,170);

}

// Step 4. Convert heat to LED colors

for( int j = 0; j < NUM_LEDS; j++) {

setPixelHeatColor(j, heat[j] );

}

showStrip();

delay(SpeedDelay);

}

void setPixelHeatColor (int Pixel, byte temperature) {

// Scale 'heat' down from 0-255 to 0-191

byte t192 = round((temperature/255.0)*191);

// calculate ramp up from

byte heatramp1 = t192 & 0x3F; // 0..63

heatramp1 <<= 2; // scale up to 0..252

// figure out which third of the spectrum we're in:

if( t192 > 0x80) { // hottest

setPixel(Pixel, 255, 255, heatramp1);

} else if( t192 > 0x40 ) { // middle

setPixel(Pixel, 255, heatramp1, 0);

} else { // coolest

setPixel(Pixel, heatramp1, 0, 0);

}

}

// *** REPLACE TO HERE ***

void showStrip() {

#ifdef ADAFRUIT_NEOPIXEL_H

// NeoPixel

strip.show();

#endif

#ifndef ADAFRUIT_NEOPIXEL_H

// FastLED

FastLED.show();

#endif

}

void setPixel(int Pixel, byte red, byte green, byte blue) {

#ifdef ADAFRUIT_NEOPIXEL_H

// NeoPixel

strip.setPixelColor(Pixel, strip.Color(red, green, blue));

#endif

#ifndef ADAFRUIT_NEOPIXEL_H

// FastLED

leds[Pixel].r = red;

leds[Pixel].g = green;

leds[Pixel].b = blue;

#endif

}

void setAll(byte red, byte green, byte blue, byte ) {

for(int i = 0; i < NUM_LEDS; i++ ) {

setPixel(i, red, green, blue);

}

showStrip();

}

Step 8: Finished!

Once you've uploaded the code, the sweater is finished and ready to be worn!