会发光的鞋！

2Teensy 2.0微控制器

4Flexiforce 压力传感器（100lbs）

2个4*AA 碱性电池组 或 2个3*AAA可充电的镍锌电池组

4个1N4001二极管（用4*AA 碱性电池组时才要用到它，如果你用可充电电池，则不需要它）

2只厚底鞋

2个1000uF电容

4个1M的电阻

2个10k的电阻

(via instructables)

Step 2： 给Teensy编程

=======以下是代码======

//thanks to Adafruit for the example RGB LED code and libraries

#include "SPI.h"
/**********************************************/

// Number of RGB LEDs in strand:
int nLEDs = 20;

// Chose a pin for output; can be any valid output pin:
int dataPin  = 15;

//make an instance of the strip object

//runs on power on
void setup() {
// Start up the LED strip
strip.begin();

// Update the strip, to start they are all 'off'
strip.show();
}

//repeats while on
void loop() {
//read the front(A0) and back(A1) force sensor values

//iterate throught the LEDs(only half way because the shoe is a mirror image
for (int i=0; i < strip.numPixels()/2; i++) {
//set the current LED and its mirrored pair to a combination of the front and back force sensor readings, proportional to their distance from each sensor
}
//send the new colors to the strip
strip.show();
}

//helper function that shifts and scales the force reading to a range of 0-384(for the color wheel function)
uint32_t getColorFromForce(int force){
//the shift and scaling factors were found experimentally
int color=(force-350)/1.3;
if (color>350){
color=350;
}
else if (color<0){
color=0;
}
//return the color that matches the force
return Wheel(color);
}

//Input a value 0 to 384 to get a color value.
//The colours are a transition b - g -r - back to b
uint32_t Wheel(uint16_t WheelPos)
{
byte r, g, b;
switch(WheelPos / 128)
{
case 0:
b = 127 - WheelPos % 128;   //blue down
g = WheelPos % 128;      // Green up
r = 0;                  //red off
break;
case 1:
g = 127 - WheelPos % 128;  //green down
r = WheelPos % 128;      //red up
b = 0;                  //blue off
break;
case 2:
r = 127 - WheelPos % 128;  //red down
b = WheelPos % 128;      //blue up
g = 0;                  //green off
break;
}
return(strip.Color(r,g,b));
}

Step 4： 安装所有的东西

1. 我大多数都是用胶带粘，但回想起来，这么做不太好，用胶带粘传感器没问题，但是那些乱七八糟的线，最好还是把它们缝在鞋内侧的边上，看着会整齐很多。

2. 我Teensy装在了鞋外侧的脚后跟的位置，太容易坏了！我还是建议把Teensy缝在鞋上（最好在鞋舌头的内侧）。把它焊完后，Teensy上会有大量的空间，能够穿针引线

Step 5： 打开吧！

yanlin2016-12-20 15:31:21

5粉丝 1作品 0随笔