Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#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
You can’t perform that action at this time.