Materials:
1 Neopixel ring
9 jumper wires
1 soldering iron
1 soldering wire
1 FLORA board
3 thin wires
1 decorative bra/costume top
1 3.3v battery
wire clippers
wire strippers
1 accelerometer
needle & thread
1. I use clip wires to connect the accelerometer to the FLORA board and the neopixel ring to clip to the board, then plug it into my laptop to start coding. The idea behind the accelerometer was that at a music festival, the motion of dancing would click the sensor repeatedly in order for the pattern of lighting to go off on the neopixel ring after the rainbow cycle.
2. Once the code was working, I sewed the FLORA board to the side of the bra.
3. I stuck 3 jumper pins through the padding of the bra into the the pins of the neopixel ring. I solderd 3 jumper wires into power, ground, and input of the ring. Then on the other side of the jumper wire, i clips the pin parts off, stripped the wires, then soldered each jumper wire to 3 thinner grey wires. Then, put a heat shrink over the exposed wires that were soldered together
4. These three wires were then soldered onto the FLORA board. Power to power, ground to ground, input to Pin #6.
5. I then took the 6 pins from the accelerometer and soldered them onto the appropriate pins on the FLORA board. Power to power, ground to ground, SDA to SDA 2, SLA to SLA 3, SDO to pin #10, and CS to pin #9.
6. Finally, I plugged the FLORA board into the computer and uploaded the code to the board.
Code:
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_NeoPixel.h>
#define PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
int ringRightSide[] = {0, 1, 2, 3, 4, 5};
int ringLeftSide[] = {11, 10, 9, 8, 7, 6, 5};
// Used for software SPI
//#define LIS3DH_CLK 13
//#define LIS3DH_MISO 12
#define LIS3DH_MOSI 10
// Used for hardware & software SPI
#define LIS3DH_CS 9
// software SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
Adafruit_LIS3DH lis = Adafruit_LIS3DH();
#if defined(ARDUINO_ARCH_SAMD)
// for Zero, output on USB Serial console, remove line below if using programming port to program the Zero!
#define Serial SerialUSB
#endif
// Adjust this number for the sensitivity of the ‘click’ force
// this strongly depend on the range! for 16G, try 5-10
// for 8G, try 10-20. for 4G try 20-40. for 2G try 40-80
#define CLICKTHRESHHOLD 60
void setup(void) {
strip.begin();
strip.show(); // Initialize all pixels to ‘off’
#ifndef ESP8266
while (!Serial); // will pause Zero, Leonardo, etc until serial console opens
#endif
Serial.begin(9600);
Serial.println(“Adafruit LIS3DH Tap Test!”);
if (! lis.begin(0x18)) { // change this to 0x19 for alternative i2c address
Serial.println(“Couldnt start”);
while (1);
}
// Serial.println(“LIS3DH found!”);
lis.setRange(LIS3DH_RANGE_2_G); // 2, 4, 8 or 16 G!
//Serial.print(“Range = “); Serial.print(2 << lis.getRange());
// Serial.println(“G”);
// 0 = turn off click detection & interrupt
// 1 = single click only interrupt output
// 2 = double click only interrupt output, detect single click
// Adjust threshhold, higher numbers are less sensitive
lis.setClick(2, CLICKTHRESHHOLD);
delay(100);
}
int pos = 0;
int pos2 = 0;
void loop() {
rainbow(1);
uint8_t click = lis.getClick();
if (click == 0) return;
if (! (click & 0x30)) return;
Serial.print(“Click detected (0x”); Serial.print(click, HEX); Serial.print(“): “);
if (click & 0x10 || click & 0x6A || click & 0x6C || click & 0x61 || click & 0x1A) {
Serial.print(” single click”);
lights();
}
// if (click & 0x20) {
// Serial.print(” double click”);
// lights();
// }
//colorWipe(strip.Color(0, 0, 0, 255), 50); // black RGBW
// strip.Color(0, 0, 0);
strip.show(); // Initialize all pixels to ‘off’
Serial.println();
delay(10);
return;
}
void lights() {
for (int x=0; x<9; x++) {
// Draw 5 pixels centered on pos. setPixelColor() will clip any
// pixels off the ends of the strip, we don’t need to watch for that.
strip.setPixelColor(ringRightSide[abs((pos – 2) % 7)], strip.Color(0, 0, 80)); // Dark blue
strip.setPixelColor(ringLeftSide[abs((pos – 2) % 7)], strip.Color(0, 0, 80)); // Dark blue
strip.setPixelColor(ringRightSide[abs((pos – 1) % 7)], strip.Color(0, 0, 150)); // Medium blue
strip.setPixelColor(ringRightSide[abs((pos ) % 7)], strip.Color(15, 15, 200)); // Center pixel is brightest
strip.setPixelColor(ringRightSide[abs((pos + 1) % 7)], strip.Color(0, 0, 150)); // Medium blue
strip.setPixelColor(ringRightSide[abs((pos + 2) % 7)], strip.Color(0, 0, 80)); // Dark blue
strip.setPixelColor(ringLeftSide[abs((pos – 2) % 7)], strip.Color(0, 0, 80)); // Dark blue
strip.setPixelColor(ringLeftSide[abs((pos – 1) % 7)], strip.Color(0, 0, 150)); // Medium blue
strip.setPixelColor(ringLeftSide[abs((pos ) % 7)], strip.Color(15, 15, 200)); // Center pixel is brightest
strip.setPixelColor(ringLeftSide[abs((pos + 1) % 7)], strip.Color(0, 0, 150)); // Medium blue
strip.setPixelColor(ringLeftSide[abs((pos + 2) % 7)], strip.Color(0, 0, 80)); // Dark blue
//strip.setPixelColor(singlePixels[abs(pos2 – 1)], strip.Color(0, 0, 80)); // Dark blue
//strip.setPixelColor(singlePixels[abs(pos2 )], strip.Color(15, 15, 200)); // Center pixel is brightest
//strip.setPixelColor(singlePixels[abs(pos2 + 1)], strip.Color(0, 0, 80)); // Dark blue
strip.show();
delay(200);
// Rather than being sneaky and erasing just the tail pixel,
// it’s easier to erase it all and draw a new one next time.
for (int j = -2; j <= 1; j++) {
strip.setPixelColor(ringRightSide[(pos + j) % 9], 0);
strip.setPixelColor(ringLeftSide[(pos + j) % 9], 0);
// strip.setPixelColor(singlePixels[(pos2+j)%5], 0);
}
pos += 1;
if (pos < 0) {
pos = 1;
} else if (pos >= 7) {
pos = 0;
}
pos2 += 1;
if (pos2 < 0) {
pos2 = 1;
} else if (pos2 >= 1) {
// } else if(pos2 >= 6) {
pos2 = 0;
}
}
}
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);
}
}
// 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);
}
Video: