And the dancing continues (an innovative switch project)

For my innovative switch project, I wanted to continue with my illuminated dancewear theme. I decided to utilize the existing conductive surfaces on the bottom of tap shoes for my switch.

This concept uses each of the plates (front and back on each shoe) to close a switch with a conductive ground surface. It reads each of those switches separately, and uses the 16 possible combinations to control the LED color/effect.

Construction was relatively straightforward. I unscrewed the metal plates on the shoes and pinched a wire underneath them to form one side of the switches. I then sewed a sheet of conductive fabric to put on the floor for the other side of the switch. I used Adafruit NeoPixels RGB 60/m LED strip cut down to size for my illuminated shoe straps.

20151029_203154 20151104_151202 20151104_145310 20151104_112311

My code is also straightforward, but long and somewhat inefficient. It reads whether each switch (for each metal plates) is open or closed, then based on what the combination is, assigns a color value.

#include <EEPROM.h>

//variables
int inputPinRF = 2;
int inputPinRB = 3;
int inputPinLF = 4;
int inputPinLB = 5;
int valRF = 0;
int valRB = 0;
int valLF = 0;
int valLB = 0;
int r = 0;
int g = 0;
int b = 0;
int pause = 20;

//setup NeoPixel
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN            6
#define NUMPIXELS      9
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  pinMode(inputPinRF, INPUT);
  pinMode(inputPinRB, INPUT);
  pinMode(inputPinLF, INPUT);
  pinMode(inputPinLB, INPUT);
  pixels.begin(); // This initializes the NeoPixel library.
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop(){
  valRF = digitalRead(inputPinRF);
  valRB = digitalRead(inputPinRB);
  valLF = digitalRead(inputPinLF);
  valLB = digitalRead(inputPinLB);

  //solid colors
  if ((valRF==1) && (valRB==0) && (valLF==0) && (valLB==0)){                           //Front Right Tap Only - Red
    setColor(strip.Color(255,0,0), pause);
 
    } else if ((valRF==1) && (valRB==1) && (valLF==0) && (valLB==0)){                  //Right Foot Only - Pink
    setColor(strip.Color(85,5,5), pause);
      
    } else if ((valRF==0) && (valRB==1) && (valLF==0) && (valLB==0)){                  //Right Heel Only - Blue
    setColor(strip.Color(0, 0, 255), pause);    
      
    } else if ((valRF==0) && (valRB==1) && (valLF==1) && (valLB==1)){                  //Left Foot and Right Heel - Green
    setColor(strip.Color(0,255,0), pause);
      
    } else if ((valRF==0) && (valRB==0) && (valLF==1) && (valLB==0)){                  //Front Left Tap Only - Aqua
    setColor(strip.Color(0,255,255), pause);
      
    } else if ((valRF==0) && (valRB==0) && (valLF==1) && (valLB==1)){                  //Left Foot Only - Yellow
    setColor(strip.Color(255,255,0), pause);
       
    } else if ((valRF==0) && (valRB==0) && (valLF==0) && (valLB==1)){                  //Left Heel Only - Orange
    setColor(strip.Color(85,5,0), pause);
      
    } else if ((valRF==1) && (valRB==1) && (valLF==0) && (valLB==1)){                  //Right Foot and Left Heel - White
    setColor(strip.Color(255,255,255), pause);
      
    } else if ((valRF==0) && (valRB==1) && (valLF==0) && (valLB==1)){                  //Both Heels - Purple
    setColor(strip.Color(37,0,75), pause);

    } else if ((valRF==1) && (valRB==1) && (valLF==1) && (valLB==0)){                  //Right Foot and Front Right Tap - Lime Green
    setColor(strip.Color(124, 252, 0), pause);
    
    } else if ((valRF==1) && (valRB==0) && (valLF==1) && (valLB==1)){                  //Left Foot and Right Toe - Coral
    setColor(strip.Color(255, 127, 80), pause);
    }
  
//Chases
                    
    else if ((valRF==0) && (valRB==0) && (valLF==0) && (valLB==0)){                  //Both Feet - Strobe Blue
    theaterChase(strip.Color(0, 0, 255), pause);                
    }
  
//Duplex
    else if ((valRF==0) && (valRB==1) && (valLF==1) && (valLB==0)){                  //Front Left Tap and Back Right Tap - Duplex Yellow and Green
    setColorHalf(strip.Color(255,255,0), strip.Color(0,255,0), pause);
     
    } else if ((valRF==1) && (valRB==0) && (valLF==0) && (valLB==1)){                  //Right Toe and Left Heel - Duplex Red and Purple  
    setColorHalf(strip.Color(255,0,0), strip.Color(37,0,75), pause);
    }
//Rainbow
     else if ((valRF==1) && (valRB==0) && (valLF==1) && (valLB==0)){                  //Both Toes - Rainbow
      rainbow(1);
    } 
    
//No Contact    
    else{                                                                            //No Contact
    setColor(strip.Color(0,0,0), pause);
    }
      
}

void setColor(uint32_t c, uint8_t wait){
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
    }
    strip.show();
    delay(wait);
}

void setColorHalf(uint32_t c1, uint32_t c2, uint8_t wait){
  for(uint16_t i=0; i<4; i++) {
      strip.setPixelColor(i, c1);
    }
  for(uint16_t j=5; j<strip.numPixels(); j++){
    strip.setPixelColor(j,c2);
  }
    
    strip.show();
    delay(wait);
}

void rainbow(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

 //Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

What is most exciting for me about this project is the number of possibilities for future iterations. This round I chose to focus on changing colors for each foot position. However there are many potential variations, just from changing the code. These include color based on combinations or patterns of foot motion and educational tools that change color based on “correctness” of a step. Further, more work could be done to consolidate the wiring and electronics to eventually make this a wireless product.

20151104_195039

 

2 thoughts on “And the dancing continues (an innovative switch project)”

Comments are closed.