My concept was to create a shoe that lit up as you walked. The idea was as you put pressure on your heel an led strip would light up in a fun animation. I took this concept and molded it to take information about the amount of pressure you put on throughout the day to display different data and change the colors and animation as you walked more and the total pressure increased.
I am using the FLORA arduino, an led strip, a pressure sensor, a photocell, a push button, triple a batteries, and a led matrix.
As you put pressure on the sensor the leds light up. The pressure sensor calculates the amount of pressure from your heel and adds it up. As the pressure adds up, it changes the color of the led strip and it displays your progress on the matrix. Once you complete your goal (which I set at a certain total level of pressure) the led strip blinks red and the led matrix displays a smiley face. The flora is also calculating the amount of steps and the total readings while the photocell is calculating how much light is in the environment and changes the brightness of the leds. If you push the button on the flora the total pressure resents to zero.
Concept:
Building:
Code:
#include <Adafruit_NeoPixel.h> #include <Wire.h> #include "Adafruit_LEDBackpack.h" #include "Adafruit_GFX.h" Adafruit_8x8matrix matrix = Adafruit_8x8matrix(); const int analogInPin = A9; // Pressue Sensure Pin Adafruit_NeoPixel strip = Adafruit_NeoPixel(25, 6, NEO_GRB + NEO_KHZ800); // Constructor: number of LEDs, pin number, LED type int sensorValue = 0; // value read from the pot int numberReading = 0; // How many time is it calculating int numberOfSteps = 0; // How many times is the heal hitting pressue sensure // adding in a delay for readings long previousMillis = 0; long interval = 400; // Amount of pressure and color values int totalPressure = 0; int r; int b; int g; // Push Button const int buttonPin = 12; // the pin that the pushbutton is attached to int buttonPushCounter = 0; // counter for the number of button presses int buttonState = 0; // current state of the button int lastButtonState = 0; // previous state of the button // Photocell int photocellPin = 10;// Photocell connected to analog pin 10 int photocellVal = 0; // define photocell variable static const uint8_t PROGMEM smile_bmp[] = { B00111100, B01000010, B10100101, B10000001, B10100101, B10011001, B01000010, B00111100 }, zero_bmp[] = { B00000000}; void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); pinMode(9, INPUT_PULLUP); strip.begin(); strip.show(); // Initialize all pixels to 'off' pinMode(buttonPin, INPUT); // initialize the button pin as a input: pinMode(photocellPin, INPUT); //Serial.println("8x8 LED Matrix Test"); matrix.begin(0x70); // pass in the address matrix.clear(); matrix.drawBitmap(0, 0, zero_bmp, 0, 0, LED_ON); matrix.writeDisplay(); } void loop() { // adding in a delay for readings unsigned long currentMillis = millis(); if(currentMillis - previousMillis > interval) { previousMillis = currentMillis; // Photocell photocellVal = analogRead(photocellPin);// read the analog from photocell Serial.print("Brightness Level = " ); Serial.println( photocellVal); // print to screen if (photocellVal > 1000) { strip.setBrightness(50); matrix.setBrightness(2); } if (photocellVal < 1000 && photocellVal > 900) { strip.setBrightness(15); matrix.setBrightness(2); } if (photocellVal < 900 && photocellVal > 800) { strip.setBrightness(95); matrix.setBrightness(4); } if (photocellVal < 800 && photocellVal > 700) { strip.setBrightness(115); matrix.setBrightness(4); } if (photocellVal < 700 && photocellVal > 600) { strip.setBrightness(135); matrix.setBrightness(6); } if (photocellVal < 600 && photocellVal > 500) { strip.setBrightness(155); matrix.setBrightness(6); } if (photocellVal < 500 && photocellVal > 400) { strip.setBrightness(175); matrix.setBrightness(8); } if (photocellVal < 400 && photocellVal > 300) { strip.setBrightness(195); matrix.setBrightness(8); } if (photocellVal < 300 && photocellVal > 200) { strip.setBrightness(215); matrix.setBrightness(10); } if (photocellVal < 200 && photocellVal > 100) { strip.setBrightness(235); matrix.setBrightness(10); } if (photocellVal < 100 && photocellVal > 0) { strip.setBrightness(255); matrix.setBrightness(12); } // read the analog in value: sensorValue = analogRead(analogInPin); sensorValue = map(sensorValue, 0, 1023, 500, 0); totalPressure = totalPressure + sensorValue; numberReading = numberReading + 1; // print the results to the serial monitor: Serial.print("Current Pressure = " ); Serial.println(sensorValue); Serial.print("Total Pressure = " ); Serial.println(totalPressure); Serial.print("Number of Readings = " ); Serial.println(numberReading); if (totalPressure > 0 && totalPressure < 1000) { r = 0; g = 155; b = 255; // Blue matrix.clear(); } if (totalPressure > 1000 && totalPressure < 2000) { r = 0; g = 255; b = 0; // Green matrix.clear(); matrix.fillRect(1,0, 2,8, LED_GREEN); // First Two Rows Light UP matrix.writeDisplay(); delay(10); // matrix.clear(); // matrix.fillRect(1,0, 0,0, LED_GREEN); // matrix.writeDisplay(); // delay(5000); // void fillScreen(uint16_t color); } if (totalPressure > 2000 && totalPressure < 3000) { r = 255; g = 255; b = 0 ; // Yellow matrix.clear(); matrix.fillRect(1,0, 4,8, LED_GREEN); // First Four Rows Light UP matrix.writeDisplay(); delay(10); matrix.clear(); } if (totalPressure > 3000 && totalPressure < 4000) { r = 255; g = 0; b = 255; // Purple matrix.clear(); matrix.fillRect(1,0, 6,8, LED_GREEN); // First Six Rows Light UP matrix.writeDisplay(); delay(10); matrix.clear(); } if (totalPressure > 5000 ) {r = 255; g = 0; b = 0;} // Red if (sensorValue > 40 && totalPressure < 5000 ) { Serial.println("Lights Triggered"); colorWipe(strip.Color(r, g, b), 20); colorWipe(strip.Color(0, 0, 0), 20); delay(10); matrix.clear(); } else if (sensorValue > 40 && totalPressure > 5000 && totalPressure < 7000 ) { Serial.println("All Colors Cycled"); colorWipe2(strip.Color(r, g, b), 100); colorWipe2(strip.Color(0, 0, 0), 100); matrix.clear(); matrix.drawBitmap(0, 0, smile_bmp, 8, 8, LED_ON); matrix.writeDisplay(); delay(10); } else if (sensorValue > 40 && totalPressure > 7000 ) { Serial.println("All Colors Cycled"); colorWipe(strip.Color(r, g, b), 35); colorWipe(strip.Color(0, 0, 0), 35); } // Calculate amount of times pressure is calculated/steps if (sensorValue > 50 ) { numberOfSteps++; Serial.print("Number of Steps = " ); Serial.println(numberOfSteps); } } // If the button is pushed, reset the total pressue to zero. // Still keep the number of readings. // Also counts the number of times button is pushed // read the pushbutton input pin: buttonState = digitalRead(buttonPin); // compare the buttonState to its previous state if (buttonState != lastButtonState) { // if the state has changed, increment the counter if (buttonState == HIGH) { // if the current state is HIGH then the button // wend from off to on: buttonPushCounter++; totalPressure = 0; numberOfSteps=0; Serial.println("on"); Serial.print("Amount of Resets: "); Serial.println(buttonPushCounter); matrix.setTextWrap(false); // we dont want text to wrap so it scrolls nicely matrix.setTextSize(1); matrix.setTextColor(LED_RED); for (int8_t x=7; x>=-45; x--) { matrix.clear(); matrix.setCursor(x,0); matrix.print("Cleared"); matrix.writeDisplay(); delay(50); matrix.clear(); } } } // save the current state as the last state, //for next time through the loop lastButtonState = buttonState; } // End of voidLoop // Delays each led before stopign to light up the next one 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); } } // Blinks LED instead of void colorWipe2(uint32_t c, uint8_t wait) { for(uint16_t i=0; i<strip.numPixels(); i++) { strip.setPixelColor(i, c); strip.show(); // delay(wait); } }
Student’s blog:
http://jeffreygochman.com/light-up-sneakers/
Leave a Reply