Jiacheng Jiang
Published © MIT

User-driven customizable garments - DOMAIN/我域

DOMAIN is a set of smart garments that aims to give the decision-making power of expression back from designers to users.

IntermediateWork in progressOver 1 day219

Things used in this project

Hardware components

Arduino Mega 2560
Arduino Mega 2560
×1
nLiten Forward-Emitting 30 LED strip
nLITEn Tech nLiten Forward-Emitting 30 LED strip
×1
ASCA | Free Form module
ASCA | Free Form module
×1
LOAMLIN WS2812B LED Strips
×1
FEETECH FS90R Continuour Servo Motor
×1
HC-06 Bluetooth Module
×1

Software apps and online services

Arduino IDE
Arduino IDE
MIT App Inventor 2
MIT App Inventor 2

Hand tools and fabrication machines

Soldering Station, 110 V
Soldering Station, 110 V
Sewing Machine
Drill / Driver, Cordless
Drill / Driver, Cordless

Story

Read more

Custom parts and enclosures

Box

Contains Arduino board, batteries, and power module

Bridge

A small 3D printed component used in the collar

Windlass

3D printed windlass component attached to the servo to scroll the strings

Schematics

Notes for wire connection

Notes for wire connection_2

Code

DOMAIN_Arduino_Code

C/C++
The Arduino Code for receiving and parsing data from the application, and controlling servos and LEDs on the garments
//include libraries
#include <FastLED.h>
#include <Servo.h>

//define LED numbers
#define NUM_LEDS_PER_STRIP    72
CRGB leds[NUM_LEDS_PER_STRIP];


char Action;
char character;
String palabra;

String Style;
String Speed;
String r1;
String g1;
String b1;
String r2;
String g2;
String b2;
String r3;
String g3;
String b3;
String r4;
String g4;
String b4;
String SleeveL;
String SleeveR;
String CollarL;
String CollarR;
String ShortsL;
String ShortsR;
int indSt;
int indSp;
int inda1;
int inda2;
int inda3;
int indb1;
int indb2;
int indb3;
int indc1;
int indc2;
int indc3;
int indd1;
int indd2;
int indd3;
int indSlL;
int indSlR;
int indCoL;
int indCoR;
int indShL;
int indShR;

//define integers for input
int SPD;
int R1;
int G1;
int BOne;
int R2;
int G2;
int B2;
int R3;
int G3;
int B3;
int R4;
int G4;
int B4;
int SlL;
int SlR;
int CoL;
int CoR;
int ShL;
int ShR;

//define servo names
Servo servoSlL;
Servo servoSlR;  
Servo servoCoL;
Servo servoCoR;
Servo servoShL;
Servo servoShR;  


void setup() {
  Serial.begin(9600);
  FastLED.addLeds<WS2812, 4>(leds, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<WS2812, 5>(leds, NUM_LEDS_PER_STRIP);
  FastLED.clear();//start with LED off
}

void loop() {
  if(Serial.available()) {
    //Parse incoming data from the Application
    character = Serial.read();
    palabra = palabra + character;
    if(character == '*') {    
      palabra = palabra.substring(0, palabra.length() - 1); // Delete last char *
      Serial.println(palabra);
      
      indSt = palabra.indexOf(',');
      Style = palabra.substring(0, indSt);
      
      indSp = palabra.indexOf(',', indSt+1);
      Speed = palabra.substring(indSt+1, indSp); 
      
           
      inda1 = palabra.indexOf(',', indSp+1);
      r1 = palabra.substring(indSp+1, inda1);
      inda2 = palabra.indexOf(',', inda1+1 );
      g1 = palabra.substring(inda1+1, inda2);
      inda3 = palabra.indexOf(',', inda2+1 );
      b1 = palabra.substring(inda2+1, inda3);

      indb1 = palabra.indexOf(',', inda3+1);
      r2 = palabra.substring(inda3+1, indb1);
      indb2 = palabra.indexOf(',', indb1+1 );
      g2 = palabra.substring(indb1+1, indb2);
      indb3 = palabra.indexOf(',', indb2+1 );
      b2 = palabra.substring(indb2+1, indb3);

      indc1 = palabra.indexOf(',', indb3+1);
      r3 = palabra.substring(indb3+1, indc1);
      indc2 = palabra.indexOf(',', indc1+1 );
      g3 = palabra.substring(indc1+1, indc2);
      indc3 = palabra.indexOf(',', indc2+1 );
      b3 = palabra.substring(indc2+1, indc3);

      indd1 = palabra.indexOf(',', indc3+1);
      r4 = palabra.substring(indc3+1, indd1);
      indd2 = palabra.indexOf(',', indd1+1 );
      g4 = palabra.substring(indd1+1, indd2);
      indd3 = palabra.indexOf(',', indd2+1 );
      b4 = palabra.substring(indd2+1, indd3);

      indSlL = palabra.indexOf(',', indd3+1);
      SleeveL = palabra.substring(indd3+1, indSlL);
      indSlR = palabra.indexOf(',', indSlL+1);
      SleeveR = palabra.substring(indSlL+1, indSlR);
 
      indCoL = palabra.indexOf(',', indSlR+1);
      CollarL = palabra.substring(indSlR+1, indCoL);      
      indCoR = palabra.indexOf(',', indCoL+1);
      CollarR = palabra.substring(indCoL+1, indCoR);
      
      indShL = palabra.indexOf(',', indCoR+1);
      ShortsL = palabra.substring(indCoR+1, indShL);
      indShR = palabra.indexOf(',', indShL+1);
      ShortsR = palabra.substring(indShL+1);
      
/////////////Print received data in Serial Port & trigger functions//////////////           
      Serial.print("Style = ");
      Serial.println(Style);

      Serial.print("Speed = ");
      Serial.println(Speed);
      SPD = Speed.toInt();

      Serial.print("r1 = ");
      Serial.print(r1);
      Serial.print(", g1 = ");
      Serial.print(g1);
      Serial.print(", b1 = ");
      Serial.println(b1);

      R1 = r1.toInt();
      G1 = g1.toInt();
      BOne = b1.toInt();    

      Serial.print("r2 = ");
      Serial.print(r2);
      Serial.print(", g2 = ");
      Serial.print(g2);
      Serial.print(", b2 = ");
      Serial.println(b2);

      R2 = r2.toInt();
      G2 = g2.toInt();
      B2 = b2.toInt();

      Serial.print("r3 = ");
      Serial.print(r3);
      Serial.print(", g3 = ");
      Serial.print(g3);
      Serial.print(", b3 = ");
      Serial.println(b3);

      R3 = r3.toInt();
      G3 = g3.toInt();
      B3 = b3.toInt();

      Serial.print("r4 = ");
      Serial.print(r4);
      Serial.print(", g4 = ");
      Serial.print(g4);
      Serial.print(", b4 = ");
      Serial.println(b4);

      R4 = r4.toInt();
      G4 = g4.toInt();
      B4 = b4.toInt();
      
      Serial.print("SleeveL = ");
      Serial.print(SleeveL);
        SlL = SleeveL.toInt();
        if (SlL > 0){
          SlLup();
        } 
        if (SlL < 0){
          SlLdown();
        }
        
      Serial.print(", SleeveR = ");
      Serial.println(SleeveR);
        SlR = SleeveR.toInt();
        if (SlR > 0){
          SlRup();
        }
        if (SlR < 0){
          SlRdown();
        }

      Serial.print("CollarL = ");
      Serial.print(CollarL);
        CoL = CollarL.toInt();
        if (CoL > 0){
          CoLup();
        } 
        if (CoL < 0){
          CoLdown();
        }
        
      Serial.print(", CollarR = ");
      Serial.println(CollarR);
        CoR = CollarR.toInt();
        if (CoR > 0){
          CoRup();
        }
        if (CoR < 0){
          CoRdown();
        }

      Serial.print("ShortsL = ");
      Serial.print(ShortsL);
        ShL = ShortsL.toInt();
        if (ShL > 0){
          ShLup();
        }
        if (ShL < 0){
          ShLdown();
        }
      Serial.print(", ShortsR = ");
      Serial.println(ShortsR);
        ShR = ShortsR.toInt();
        if (ShR > 0){
          ShRup();
        }
        if (ShR < 0){
          ShRdown();
        }

        if (Style == "1"){
          style1();
        }
        if (Style == "2"){
          style2();
        }
        if (Style == "3"){
          style3();
        }
        if (Style == "4"){
          Off();
        }
      Serial.println();
      palabra = "";
      delay(10);
    }  
  }
}

////////////////////////////////Everything About Servos//////////////////////////////
void SlLup(){  
  servoSlL.attach(7);
  servoSlL.write(180);
  delay(SlL);
  servoSlL.detach();
}

void SlLdown(){
  servoSlL.attach(7);
  servoSlL.write(0);
  delay(abs(SlL));
  servoSlL.detach();
}

void SlRup(){  
  servoSlR.attach(8);
  servoSlR.write(180);
  delay(SlR);
  servoSlR.detach();
}

void SlRdown(){
  servoSlR.attach(8);
  servoSlR.write(0);
  delay(abs(SlR));
  servoSlR.detach();
}

void CoLup(){  
  servoCoL.attach(9);
  servoCoL.write(180);
  delay(CoL);
  servoCoL.detach();
}

void CoLdown(){
  servoCoL.attach(9);
  servoCoL.write(0);
  delay(abs(CoL));
  servoCoL.detach();
}

void CoRup(){  
  servoCoR.attach(10);
  servoCoR.write(180);
  delay(CoR);
  servoCoR.detach();
}

void CoRdown(){
  servoCoR.attach(10);
  servoCoR.write(0);
  delay(abs(CoR));
  servoCoR.detach();
}

void ShLup(){  
  servoShL.attach(11);
  servoShL.write(180);
  delay(ShL);
  servoShL.detach();
}

void ShLdown(){
  servoShL.attach(11);
  servoShL.write(0);
  delay(abs(ShL));
  servoShL.detach();
}

void ShRup(){  
  servoShR.attach(12);
  servoShR.write(180);
  delay(ShR);
  servoShR.detach();
}

void ShRdown(){
  servoShR.attach(12);
  servoShR.write(0);
  delay(abs(ShR));
  servoShR.detach();
}

//////////////////////////LED/////////////////////////////
void style1() {
  while(Style == "1"){
    int spd = map(SPD, 0, 300, 5, 30);
    for (int i = 0; i <= 71; i++) {
      leds[i] = CRGB ( R1, G1, BOne);
      FastLED.show();
      delay(spd);
    }
    for (int n = 0; n <= 71; n++) {
      leds[n] = CRGB ( R2, G2, B2);
      FastLED.show();
      delay(spd);
    }
    for (int m = 0; m <= 71; m++) {
      leds[m] = CRGB ( R3, G3, B3);
      FastLED.show();
      delay(spd);
    }
    for (int r = 0; r <= 71; r++) {
      leds[r] = CRGB ( R4, G4, B4);
      FastLED.show();
      delay(spd);
    }
    
    if (Serial.available()){
      break;
    }
  }
}

void style2() {
  while (Style == "2"){
    int spd = map(SPD, 0, 300, 5, 30);
    for (int i = 0; i <= 71; i++) {
      leds[i] = CRGB ( R1, G1, BOne);
      FastLED.show();
      delay(spd);
    }
    for (int i = 71; i >= 0; i--) {
      leds[i] = CRGB ( R2, G2, B2);
      FastLED.show();
      delay(spd);
    }
    for (int n = 0; n <= 71; n++) {
      leds[n] = CRGB ( R3, G3, B3);
      FastLED.show();
      delay(spd);
    }
    for (int n = 71; n >= 0; n--) {
      leds[n] = CRGB ( R4, G4, B4);
      FastLED.show();
      delay(spd);
    }
    if (Serial.available()){
      break;
    }
  }
}

void style3() {
  while (Style == "3"){
    int spd = map(SPD, 0, 300, 300, 1000);
    
    fill_solid( leds, NUM_LEDS_PER_STRIP, CRGB( R1, G1, BOne));
    FastLED.show();
    delay(spd);
 
    fill_solid( leds, NUM_LEDS_PER_STRIP, CRGB( R2, G2, B2));
    FastLED.show();
    delay(spd);

    fill_solid( leds, NUM_LEDS_PER_STRIP, CRGB( R3, G3, B3));
    FastLED.show();
    delay(spd);

    fill_solid( leds, NUM_LEDS_PER_STRIP, CRGB( R4, G4, B4));
    FastLED.show();
    delay(spd);

    if (Serial.available()){
      break;
    }
  }
}

void Off(){
  while (Style == "4"){
    fill_solid( leds, NUM_LEDS_PER_STRIP, CRGB(0, 0, 0));
    FastLED.show();
    FastLED.clear();

    if (Serial.available()){
      break;
    }
  }
}

Application

Java
The app for control (available on Android devices)
No preview (download only).

Credits

Jiacheng Jiang

Jiacheng Jiang

1 project • 1 follower
Thanks to MokkaMusic.

Comments