//Ashley #include #define PIN 6 int armStripLength = 44; int torsoStripLength = 73; int legStripLength = 60; int totalStripLength = 177; boolean ledsStatus[177]; //int armStripLength = 14; //int torsoStripLength = 25; //int legStripLength = 20; //int totalStripLength = 59; //boolean ledsStatus[59]; boolean clearNext = false; boolean toClear = false; int legStart = armStripLength + torsoStripLength; int halfwayStart = totalStripLength/2; int fsr1; //Wrist int fsr2; //Hip int fsr3; //Back boolean fsr1IsTouched = false; boolean fsr2IsTouched = false; boolean fsr3IsTouched = false; int fsr1Count = 0; int fsr2TorsoCount = 0; int fsr2LegCount = 0; int fsr3UpCount = 0; int fsr3DownCount = 0; boolean allLedsOn = false; long danceLength = 300000; int lastStep; int currentStep; int stepLength; Adafruit_NeoPixel strip = Adafruit_NeoPixel(totalStripLength, PIN, NEO_GRB + NEO_KHZ800); float red = 90.0; float green = 47.0; float blue = 146.0; int r, g, b; //format : (endColor-startColor) / 100.0; float firstRed = (159-90) / 100.0; float firstGreen = (30-47) / 100.0; float firstBlue = (94-146) / 100.0; float secondRed = (219-159) / 100.0; float secondGreen = (57-30) / 100.0; float secondBlue = (32-94) / 100.0; int fsr1Pin = 2; //analog pin 0 int fsr2Pin = 4; int fsr3Pin = 0; int pulseNum = 0; boolean pulseUp = true; void setup() { Serial.begin(9600); strip.begin(); strip.show(); currentStep = 0; currentStep = millis(); stepLength = 1000; strip.setBrightness(32); } void loop() { initStrip(); clearLEDs(); changeColor(); checkSensors(); updateStrips(); strip.show(); delay(10); } void initStrip() { if (!clearNext) { clearNext = false; toClear = true; } else { if (toClear) { for (int i=0; i -20) { pulseNum--; } else { pulseUp = true; } } if (r+pulseNum < 255 && r+pulseNum > 0) r+=pulseNum; if (g+pulseNum < 255 && g+pulseNum > 0) g+=pulseNum; if (b+pulseNum < 255 && b+pulseNum > 0) b+=pulseNum; delay(10); } void spark(int fromLed, int toLed) { for (int i=fromLed; i<=toLed; i++) { strip.setPixelColor(i,r,g,b); ledsStatus[i] = true; } } void updateStrips() { //Wrist Sensor// if (fsr1 > 512) { if (fsr1IsTouched) { if (fsr1Count > armStripLength-2) { //randomFlash(0,armStripLength); ledPulse(); } else { //Serial.println(fsr); fsr1Count++; ledsStatus[fsr1Count] = true; } } else { ledsStatus[fsr1Count] = true; fsr1IsTouched = true; } } else if (fsr1IsTouched && fsr1 < 256) { if (fsr1Count < armStripLength) { spark(0, armStripLength-1); clearNext = true; } toClear = true; fsr1IsTouched = false; fsr1Count = 0; } //Hip Sensor// if (fsr2 > 512) { if (fsr2IsTouched) { if (fsr2TorsoCount > -torsoStripLength+2) { //randomFlash(armStripLength,totalStripLength); //Up torso fsr2TorsoCount--; ledsStatus[legStart-1+fsr2TorsoCount] = true; if (fsr2LegCount < legStripLength) { //Down leg fsr2LegCount++; ledsStatus[fsr2LegCount+legStart-1] = true; } } else { ledPulse(); } } else { ledsStatus[legStart-1-fsr2TorsoCount] = true; ledsStatus[fsr2LegCount+legStart-1] = true; fsr2IsTouched = true; } } else if (fsr2IsTouched && fsr2 < 256) { if (fsr2TorsoCount > -torsoStripLength) { spark(armStripLength, totalStripLength); clearNext = true; } toClear = true; fsr2IsTouched = false; fsr2TorsoCount = 0; fsr2LegCount = 0; } //Back Sensor// if (fsr3 > 512) { if (fsr3IsTouched) { if (fsr3UpCount < -halfwayStart) { //randomFlash(0,totalStripLength); ledPulse(); } else { //up torso fsr3UpCount--; ledsStatus[halfwayStart-1+fsr3UpCount] = true; if (fsr3DownCount > halfwayStart) { ledsStatus[fsr3DownCount+halfwayStart] = false; } else { //down leg fsr3DownCount++; ledsStatus[fsr3DownCount+halfwayStart] = true; } } } else { ledsStatus[halfwayStart-1-fsr3UpCount] = true; ledsStatus[fsr3DownCount+halfwayStart] = true; fsr3IsTouched = true; } } else if (fsr3IsTouched && fsr3 < 256) { if (fsr3UpCount > -halfwayStart) { spark(0, totalStripLength); clearNext = true; } toClear = true; fsr3IsTouched = false; fsr3UpCount = 0; fsr3DownCount = 0; } ///////////////////////////////////////////////// for (int i=0; i stepLength) { if (millis() < danceLength/3) { red += firstRed; green += firstGreen; blue += firstBlue; } else if (millis() >= danceLength/3 && millis() < 2*(danceLength/3)) { red += secondRed; green += secondGreen; blue += secondBlue; } else { // Serial.println(millis()); // Serial.print(red); // Serial.print(' '); // Serial.print(green); // Serial.print(' '); // Serial.println(blue); } lastStep = currentStep; } r = red; g = green; b = blue; }