Skip to content

Instantly share code, notes, and snippets.

@denahemerson
Created December 10, 2014 19:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save denahemerson/51694ad2f25a6a825ad3 to your computer and use it in GitHub Desktop.
Save denahemerson/51694ad2f25a6a825ad3 to your computer and use it in GitHub Desktop.
#include "Adafruit_NeoPixel.h"
const int analogInPin = 9; // pressure sensor input
Adafruit_NeoPixel strip = Adafruit_NeoPixel(6, 6, NEO_GRB + NEO_KHZ800); //right shoe
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(6, 10, NEO_GRB + NEO_KHZ800); //left shoe
int sensorValue = 0; // value read from the pressure sensor
void setup() {
// initialize serial communications at 9600 bps:
Serial.begin(9600);
pinMode(9, INPUT_PULLUP);
strip.begin();
strip2.begin();
strip.show(); // Initialize all pixels to 'off'
strip2.show(); // Initialize all pixels to 'off'
}
void loop() {
// read the pressure sensor in value:
sensorValue = analogRead(analogInPin);
// print results to serial monitor:
Serial.print("sensor = " );
Serial.println(sensorValue);
if (sensorValue < 50){ //adjust threshhold as you test
Serial.println("leds triggered");
colorWipe(strip.Color(255, 0, 0), 25);
colorWipe(strip.Color(0, 0, 0), 25);
colorWipe(strip2.Color(255, 0, 0), 25);
colorWipe(strip2.Color(0, 0, 0), 25);
}
}
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
strip2.setPixelColor(i, c);
strip2.show();
delay(wait);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment