Interactive Project – George Cepeda

The Frequency Light Glove
The adafruit flora takes in a frequency value from the headphone jack connected to it and uses that value to change the color of the neopixels that have been sewn into the glove.
Materials:

  • spool of 2 ply conductive thread
  • 60″ fabric cloth
  • 8 sewable neopixels
  • Neopixel ring (12)
  • AAA battery holder
  • Adafruit Flora
  • Headphone jack 
  • 2 alligator clips (opitional)
  • soldering iron
  • solder 
  • 2 wires
  • Black Nail Polish
Instructions:

  1. Cut two 10 by 20 inch rectangles out of the 60″ fabric and draw an outline of where the pixels and flora will be sewn on to on one of the rectangles. Alternatively one can also pin the different components in place. The Image to the right shows a rough trace of my arm to help me decide how to cut up the fabric and get a good idea of where I would place the components.
  2. Then follow up by sewing the data lines of all the neopixels to the correct port on the flora. In between pixels the knots were coated in black nail polish to insure they would stick and not pop out of the fabric. The Image below shows an example of a knot held together by nail polish.

  3. After all the data lines have been sewn and there are no conflicting lines sew in the ground wire and once satisfied with that sew in the power wire to complete the circuit. 
  4. After all the components have been fastened place the rectangle on the other piece such that the components are not visible. Sew two lines through both sides of the rectangle such that one can stick their arm through.
  5. Cut away any excess cloth and then flip the glove inside out such that the components are on the outside of the gloves.
  6. Next would be soldering wires to the headphone jack and then connecting them to the flora. Here one could use the alligator clips to connect to the flora to make it easily removable. 

The pictures below show the completed product in the off and on states without the headphone jack attached.



Code:
/*
 * Interactive Project
 * Frequency music Glove
 */

 #include <Adafruit_NeoPixel.h>

 //pins and their numbers
 #define PIN 10 //pin for the Neopixel Ring
 #define N_PIXELS 12 //it is a 12 neopixel ring

 #define PINR 6 //pin for pixels that go around the glove
 #define W_PIXEL 4 // a low number to start

 #define PINL 12
 #define L_PIXEL 4

 #define DATAPIN 9

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_RGB     Pixels are wired for RGB bitstream
//   NEO_GRB     Pixels are wired for GRB bitstream
//   NEO_KHZ400  400 KHz bitstream (e.g. FLORA pixels)
//   NEO_KHZ800  800 KHz bitstream (e.g. High Density LED strip)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripR = Adafruit_NeoPixel(W_PIXEL, PINR, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripL= Adafruit_NeoPixel(L_PIXEL, PINL, NEO_GRB + NEO_KHZ800);
int frequency = 0;
//note that the values of colors go in RGB (red,green and blue in that order i believe)
int R=0;
int B=0;
int G=0;
//RGB values for the ring
int RR =0;
int RB =0;
int RG=0;
//—————————————————————————————————————————————–
void setup() {
  // put your setup code here, to run once:
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code
  Serial.begin(9600);

  stripL.begin();
  stripL.show();
  stripR.begin();
  stripR.show(); // Initialize all pixels to ‘off’
  strip.begin();
  strip.show(); // Initialize all pixels to ‘off’

}//end of setup
//—————————————————————————————————————————————–
void loop() {
  // put your main code here, to run repeatedly:
  if(frequency == 0){
    R=100;
    B=100;
    G=100;
    }
  else if((frequency >0)&&(frequency < 20)){
    R=255;
    G=255;
    B=0;
  }
  else if((frequency >21)&&(frequency <40)){
    R=0;
    G=255;
    B=0;
  }
  else if((frequency >41)&&(frequency <60)){
    R=0;
    G=100;
    B=200;
  }
  else if((frequency >61)&&(frequency <80)){
    R=0;
    G=0;
    B=255;
  }
  else if((frequency >81)&&(frequency <100)){
    R=255;
    G=0;
    B=255;
  }
  else if((frequency >101)&&(frequency <120)){
    R=255;
    G=0;
    B=75;
  }
  else if((frequency >121)&&(frequency <140)){
    R=255;
    G=100;
    B=0;
  }
  else{
    R=255;
    G=0;
    B=0;
  }
  theaterChaseL(stripL.Color(R,G,B),50);
  theaterChaseR(stripR.Color(R,G,B),50);
  colorWipe(strip.Color(R, G, B), 50);
  //delay(100);
  //Note Function calls with R are for the radius neo pixels while normal calls are for the ring.
  //examples of fuction calls for both
  //colorWipe(strip.Color(255, 0, 0), 50); //red
  //colorWipeR(stripR.Color(R, G, B), 50);
  //list of color values i could use
  /*
   * Basic ones
   * Red = 255,0,0
   * Blue=0,0,255
   * Green= 0,255,0
   * Purple= 255,0,255
   * Yellow= 255,255,0 Green is a primary color instead of yellow when talking electronics
   * Orange=255,100,0
   * Gray= 100,100,100
   * Pink= 255,0,75
   * skyblue= 0,100,200
   */

}//end of loop
//—————————————————————————————————————————————–

//list of functions that will function for the ring
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
    strip.setPixelColor(i, c);
    strip.show();
    delay(wait);
  }
}//end of color wipe
//—————————————————————————————————————————————–
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);
  }
}//end rainbow
//—————————————————————————————————————————————–

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}//end rainbow cycle
//—————————————————————————————————————————————–

//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 (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}//end of theater chase
//—————————————————————————————————————————————–
//Theatre-style crawling lights.
void theaterChaseL(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 (uint16_t i=0; i < stripL.numPixels(); i=i+3) {
        stripL.setPixelColor(i+q, c);    //turn every third pixel on
      }
      stripL.show();

      delay(wait);

      for (uint16_t i=0; i < stripL.numPixels(); i=i+3) {
        stripL.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}//end of theater chase
//—————————————————————————————————————————————–
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}//end of theater chase rainbow
//—————————————————————————————————————————————–

// 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);
}//end of wheelPos

//—————————————————————————————————————————————–
//a list that will work for the surrounding NeoPixels
 // Fill the dots one after the other with a color
void colorWipeR(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<stripR.numPixels(); i++) {
    stripR.setPixelColor(i, c);
    stripR.show();
    delay(wait);
  }
}//end of colorWipeR
//—————————————————————————————————————————————–
void rainbowR(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<stripR.numPixels(); i++) {
      stripR.setPixelColor(i, Wheel((i+j) & 255));
    }
    stripR.show();
    delay(wait);
  }
}//end rainbowR
//—————————————————————————————————————————————–
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycleR(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< stripR.numPixels(); i++) {
      stripR.setPixelColor(i, Wheel(((i * 256 / stripR.numPixels()) + j) & 255));
    }
    stripR.show();
    delay(wait);
  }
}// end of rainbowCycleR
//—————————————————————————————————————————————–
//Theatre-style crawling lights.
void theaterChaseR(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 (uint16_t i=0; i < stripR.numPixels(); i=i+3) {
        stripR.setPixelColor(i+q, c);    //turn every third pixel on
      }
      stripR.show();

      delay(wait);

      for (uint16_t i=0; i < stripR.numPixels(); i=i+3) {
        stripR.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}//end theaterChaseR
//—————————————————————————————————————————————–
//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbowR(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < stripR.numPixels(); i=i+3) {
        stripR.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      stripR.show();

      delay(wait);

      for (uint16_t i=0; i < stripR.numPixels(); i=i+3) {
        stripR.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}//end theater chaseRainbowR
//—————————————————————————————————————————————–
// Input a value 0 to 255 to get a color value.
// The colours are a transition r – g – b – back to r.
uint32_t WheelR(byte WheelRPos) {
  WheelRPos = 255 – WheelRPos;
  if(WheelRPos < 85) {
    return stripR.Color(255 – WheelRPos * 3, 0, WheelRPos * 3);
  }
  if(WheelRPos < 170) {
    WheelRPos -= 85;
    return stripR.Color(0, WheelRPos * 3, 255 – WheelRPos * 3);
  }
  WheelRPos -= 170;
  return stripR.Color(WheelRPos * 3, 255 – WheelRPos * 3, 0);

}//end of WheelRpos