loading
mo.momi

Led strips are amazing! Firewalker-led-sneakers(http://learn.adafruit.com/firewalker-led-sneakers) by Adafruit inspired me.

I wanna change a way to control it, instead of "pressure-sensitive", I use a accelerometer sensor judging the motion of slipper.

It's simple, I complete this version only calculating the acceleration on "z" axis, weather i'm speed up or slow down. Led will "flow" if I'm moving, and stop as I stop.

Step 1: Materials & Tools

Xadow main board
Xadow 3-axis
Xadow breakout
W2828 programmable RGB Led Strips(with integrated driver)
shoe and model!


There is already a 3.7V lipo battery shipped with Xadow, due  to my experience this voltage can light up a short segment of RGB Led strip, if necessary you can calculate the max length it can support based on your specific one. For me, this is a W2818 programmable RGB Led strip with integrated driver.

If you wanna a more "blink" experience, please use an external 5V DC power or make a 5V booster  by yourself.

Step 2: Connect

How to:

Xadow main board <- I2C -> Xadow 3-axis <-> Strip

There is already breakout on accelerometer sensor, so you don't have to add "Xadow breakout".

Xadow use FFC between two modules, this 12Pin cable just fix the Xadow compatible interface.

For more info, please checkout wiki http://www.seeedstudio.com/wiki/Xadow_IO_pin_mapping

Some solder works should be done: you have to connect pins to the breakout on Xadow.

Step 3: Blink Test

Since this is the same as NeoPixel Digital RGB LED by adafruit http://www.adafruit.com/products/1461, if you wanna a quick implementation of beautiful animation with it, I highly recommend the code example  by Adafruit http://learn.adafruit.com/firewalker-led-sneakers/test-circuit.

Deploy their library https://github.com/adafruit/Adafruit_NeoPixel, have a try on "example"

Also deploy https://github.com/reeedstudio/xadow, try the demos related with 3-axis. I made some modification and use it on Xadow.

Step 4: Software

#include <Adafruit_NeoPixel.h>
#include <Wire.h>
#include "xadow.h"

#define ADDRACC         0x53

#define Register_ID     0
#define Register_2D     0x2D
#define Register_X0     0x32
#define Register_X1     0x33
#define Register_Y0     0x34
#define Register_Y1     0x35
#define Register_Z0     0x36
#define Register_Z1     0x37

#define PIN 15

double az1;

// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(14, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  Serial.begin(115200);
  //while(!Serial);
  Xadow.init();
  Wire.begin();
  adxl_init();
  cout << "init accelermeter over!" << endl;

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
 
  double ax, ay, az2, diff, delaytime;
 
  readAcc(&ax, &ay, &az2);                   // get acc
  diff = abs(az1 - az2);
  az1 = az2;
 
  //cout << "az2 = " << az2 << '\t';
  //cout << "az1 = " << az1 << '\t';
  cout << "diff = " << diff << endl;

  // Some example procedures showing how to display to the pixels:
  //colorWipe(strip.Color(255, 0, 0), 50); // Red
  //colorWipe(strip.Color(0, 255, 0), 50); // Green
  //colorWipe(strip.Color(0, 0, 255), 50); // Blue
  //rainbow(10);
 
  diff = diff * 100;
  cout << "diff = " << diff << endl;
 
  delaytime = double(map(diff, 1, 250, 1000, 1))/1000;
  cout << "delay = " << delaytime << endl;
  rainbowCycle(delaytime);
}


void adxl_init()
{
    Wire.beginTransmission(ADDRACC);
    Wire.write(Register_2D);
    Wire.write(8);                          //measuring enable
    Wire.endTransmission();                 // stop transmitting
}

unsigned char readAcc(double *Xg, double *Yg, double *Zg)
{
    int X_out;
    int Y_out;
    int Z_out;
    Wire.beginTransmission(ADDRACC);        // transmit to device
    Wire.write(Register_X0);
    Wire.write(Register_X1);
    Wire.endTransmission();
    Wire.requestFrom(ADDRACC,2);
    if(Wire.available()<=2)
    {
        int X0 = Wire.read();
        int X1 = Wire.read();
        X1=X1<<8;
        X_out=X0+X1;
    }
    //------------------Y
    Wire.beginTransmission(ADDRACC);        // transmit to device
    Wire.write(Register_Y0);
    Wire.write(Register_Y1);
    Wire.endTransmission();
    Wire.requestFrom(ADDRACC,2);
    if(Wire.available()<=2)
    {
        int Y0 = Wire.read();
        int Y1 = Wire.read();
        Y1=Y1<<8;
        Y_out=Y0+Y1;
    }
    //------------------Z
    Wire.beginTransmission(ADDRACC);        // transmit to device
    Wire.write(Register_Z0);
    Wire.write(Register_Z1);
    Wire.endTransmission();
    Wire.requestFrom(ADDRACC,2);
    if(Wire.available()<=2)
    {
        int Z0 = Wire.read();
        int Z1 = Wire.read();
        Z1=Z1<<8;
        Z_out=Z0+Z1;
    }
    *Xg=X_out/256.0;
    *Yg=Y_out/256.0;
    *Zg=Z_out/256.0;
}

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

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);
  }
}

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

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

// 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) {
  if(WheelPos < 85) {
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
}

Step 5: Final

It's simple, using double-sided adhesive to fix the strip on the slipper~.
Since is so small Xadow, you don't need extra sewing works. Just put the Xadow on your feet, sorry for the brutal idea.
<p>Hi, what battery beside the xadow 3.7v lipo battery are you using&gt;?</p>
video would be nice !
A ne555 would be a lot easyer.
That's awesome!
Hi xadow, that's very nice.

About This Instructable

14,155views

99favorites

License:

Bio: This is creator of Xadow modules
More by xadow:Color-Changing Cat The not so smart Xadow smartwatch Slipper Shining with LED strip & Xadow 
Add instructable to: