Here is the code, I assumed X = if it is accelerating, since that is what the teacher said, so the code is meant to light up while the shirt is accelerating. If not, then it does nothing. It currently will not stop lighting up regardless if the shirt is still or moving. Please help :o
void setup() {
CircuitPlayground.begin();
pinMode(vibeMotor, OUTPUT);
}
void loop() {
X = CircuitPlayground.motionX();
while (X > 4){
digitalWrite(vibeMotor, LOW);
for (int n = 0; n < 3; n++) {
for (int i = 10; i >= 0; i--) {
CircuitPlayground.setPixelColor (i, 255, 255, 255 );
delay (30);
for (int i = 10; i >= 0; i--) {
CircuitPlayground.setPixelColor (i, 0, 0, 0 );
delay (30);
}
}
digitalWrite(vibeMotor, LOW);
CircuitPlayground.setPixelColor (0, 255, 0, 0);
CircuitPlayground.setPixelColor (9, 255, 0, 0);
delay (100);
CircuitPlayground.setPixelColor (1, 255, 0, 0);
CircuitPlayground.setPixelColor (8, 255, 0, 0);
delay (100);
CircuitPlayground.setPixelColor (2, 255, 0, 0);
CircuitPlayground.setPixelColor (7, 255, 0, 0);
delay (100);
CircuitPlayground.setPixelColor (3, 255, 0, 0);
CircuitPlayground.setPixelColor (6, 255, 0, 0);
delay (100);
CircuitPlayground.setPixelColor (4, 255, 0, 0);
CircuitPlayground.setPixelColor (5, 255, 0, 0);
delay (100);
}
break;
}
delay (10);
if (X < 4){
digitalWrite(vibeMotor, HIGH);
}
}
thanks in advance!