Washing Machine Halloween Costume
It's been awhile since I've posted, so I thought I'd hightlight an oldie, but goodie.
We have to go back to Halloween 2016. My daughter came to me and said that she and a friend wanted to be a washing machine and dryer. Well, that got my brain spinning, and I had an idea of what I could do.
Here's what I ended up with.
Pretty cool, right? So how did I get there. I honestly can't remember if I started with a 3D model or a trip Sparkfun.com. Probably Sparkfun. Here is a wishlist with all the parts I used.
I had recently started using Autodesk Fusion 360 to do 3D modeling, so I used it to create a model of my washer/dryer idea.
Once I had the basic model and all the parts, it was a frantic weekend before Halloween to get these things built. Prototyping electronics, 3D printing parts, cutting cardboard, soldering final electronics, and final assembly. All 2x!
Here is the code used drive the costume. An Arduino Pro is the brains behind it.
#include <Adafruit_NeoPixel.h>
#define LED1 2
#define LED2 3
#define LED3 4
#define LED4 5
#define SW1 6
#define SW2 7
#define SW3 8
#define SW4 9
#define LED_STRIP_PIN 10
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, LED_STRIP_PIN, NEO_GRB + NEO_KHZ800);
const int startButton = 12;
int isRunning = LOW;
int buttonState;
int lastButtonState = HIGH;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 50;
unsigned long lastStepTime = 0;
unsigned long stepTime = 4;
int step = 0;
int rainbowStep = 0;
void setup() {
Serial.begin(9600);
pinMode(SW1, INPUT_PULLUP);
pinMode(SW2, INPUT_PULLUP);
pinMode(SW3, INPUT_PULLUP);
pinMode(SW4, INPUT_PULLUP);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(startButton, INPUT_PULLUP);
lastStepTime = millis();
strip.begin();
strip.show();
}
void loop() {
switchTopLeds();
//readStartButton();
setStripLeds();
}
void switchTopLeds() {
// Read swtiches
int sw1State = digitalRead(SW1);
int sw2State = digitalRead(SW2);
int sw3State = digitalRead(SW3);
int sw4State = digitalRead(SW4);
// Set LEDS
digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
if(sw1State == LOW) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, LOW);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
} else if(sw2State == LOW) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, LOW);
digitalWrite(LED4, LOW);
} else if(sw3State == LOW) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, LOW);
} else if(sw4State == LOW) {
digitalWrite(LED1, HIGH);
digitalWrite(LED2, HIGH);
digitalWrite(LED3, HIGH);
digitalWrite(LED4, HIGH);
}
}
void readStartButton() {
int reading = digitalRead(startButton);
//Serial.println(reading);
//
// if(reading != lastButtonState) {
// lastDebounceTime = millis();
// }
//
// if((millis() - lastDebounceTime) > debounceDelay) {
// if(reading != buttonState) {
// buttonState = reading;
// Serial.println(buttonState);
// if(buttonState == HIGH) {
// isRunning = !buttonState;
// }
// }
// }
if(reading == LOW) {
red();
}
lastButtonState = reading;
}
void setStripLeds() {
unsigned long currentTime = millis();
if((currentTime - lastStepTime) > stepTime) {
if(step >= strip.numPixels()) {
step = 0;
}
int sw1State = digitalRead(SW1);
int sw2State = digitalRead(SW2);
int sw3State = digitalRead(SW3);
int sw4State = digitalRead(SW4);
int bigButtonState = digitalRead(startButton);
//Piper
// if(bigButtonState == LOW) {
// red();
// } else if(sw1State == LOW) {
// blueBlackSpin(step);
// } else if(sw2State == LOW) {
// blueGreenSpin(step);
// } else if(sw3State == LOW) {
// redBlackSpin(step);
// } else if(sw4State == LOW) {
// rainbow();
// } else {
// blue();
// }
//Lotus
if(bigButtonState == LOW) {
blue();
} else if(sw1State == LOW) {
yellowRedSpin(step);
} else if(sw2State == LOW) {
redPinkSpin(step);
} else if(sw3State == LOW) {
blueGreenSpin(step);
} else if(sw4State == LOW) {
rainbow();
} else {
red();
}
//rainbow();
//blueBlackSpin(step);
//redBlackSpin(step);
//yellowRedSpin(step);
//colorWhiteSpin(step);
lastStepTime = currentTime;
step++;
}
}
void fullWhite() {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0,0,0, 255 ) );
}
strip.show();
}
void blue() {
uint16_t i;
int b = -210;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0,0,abs(b)));
b = b + 7;
}
strip.show();
}
void red() {
uint16_t i;
int r = -210;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(abs(r),0,0));
r = r + 7;
}
strip.show();
}
void blueBlackSpin(int step) {
uint16_t i;
int b = -210;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(computeOffset(i,step), strip.Color(0,0,abs(b)));
b = b + 7;
}
strip.show();
}
void redBlackSpin(int step) {
uint16_t i;
int r = -210;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(computeOffset(i,step), strip.Color(abs(r),0,0));
r = r + 7;
}
strip.show();
}
void yellowRedSpin(int step) {
uint16_t i;
int g = -210;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(computeOffset(i,step), strip.Color(255,abs(g),0));
g = g + 7;
}
strip.show();
}
void redPinkSpin(int step) {
uint16_t i;
int b = -210;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(computeOffset(i,step), strip.Color(255,0,abs(b)));
b = b + 7;
}
strip.show();
}
void colorWhiteSpin(int step) {
uint16_t i;
int r = -120;
int g = -120;
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(computeOffset(i,step), strip.Color(abs(r),abs(g),255));
r = r + 4;
g = g + 4;
}
strip.show();
}
void blueGreenSpin(int) {
uint16_t i;
int g = 0;
int b = 255;
for(i=0; i<strip.numPixels(); i++) {
if(g > 255) {
g = 255;
}
if(b < 0) {
b = 0;
}
strip.setPixelColor(computeOffset(i,step), strip.Color(0,g,b));
g = g + 8;
b = b - 8;
}
strip.show();
}
int computeOffset(int loc, int step) {
int newLoc = loc + step;
if(newLoc >= strip.numPixels()) {
newLoc = newLoc - strip.numPixels();
}
return newLoc;
}
void rainbow() {
uint16_t i, j;
if(rainbowStep > 255) {
rainbowStep = 0;
}
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+rainbowStep) & 255));
}
strip.show();
rainbowStep++;
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}