Cathy’s Halloween Costume

Little Darth Vader

Process

Material preparation – Soldering – Coding – Test – Drill – Spray Paint – Re-soldering – Add diffusion paper – Combining parts – Final test

Material List

  • Black boots – Borrow from second year students
  • Black cape – PartyCity
  • Vader’s helmet – PartyCity
  • Diffusion paper – Blick
  • Button – Adafruit kits
  • Wire – VFL
  • 12 inches Translucent Tube – Canal Plastic
  • Steel Tube – PoD scrap
  • Neopixel Strip – Adafruit
  • Plastic Cap – Homedepot
  • Spray Paint – Homedepot
  • Battery – Adafruit kits

Learning

  1. Soldering: shorten the cut parts of wires to avoid touching each other. Shrinking cover the wire and strip’s cover.

2. Hiding: think in advance how to hide the wire, battery, circuit, and especially how to put the button stably.

3. Diffusion: think about how to better diffuse light more equal in 360 degrees’ angles. (Drafting paper V.S. translucent polystyrene paper)

Coding

// Simple demonstration on using an input device to trigger changes on your
// NeoPixels. Wire a momentary push button to connect from ground to a
// digital IO pin. When the button is pressed it will change to a new pixel
// animation. Initial state has all pixels off — press the button once to
// start the first animation. As written, the button does not interrupt an
// animation in-progress, it works only when idle.

include

ifdef AVR

#include // Required for 16 MHz Adafruit Trinket

endif

// Digital IO pin connected to the button. This will be driven with a
// pull-up resistor so the switch pulls the pin to ground momentarily.
// On a high -> low transition the button press logic will execute.

define BUTTON_PIN 2

define PIXEL_PIN 1 // Digital IO pin connected to the NeoPixels.

define PIXEL_COUNT 34 // Number of NeoPixels

define BRIGHTNESS 220

int led = 1; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5;

// Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic ‘v1’ (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)

boolean oldState = HIGH;
boolean newState;
int modeNum = 0; // Currently-active animation mode, 0-9

void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
strip.begin(); // Initialize NeoPixel strip object (REQUIRED)
strip.show(); // Initialize all pixels to ‘off’
}

void loop() {
// Get current button state.
newState = digitalRead(BUTTON_PIN);

// Check if state changed from high to low (button press).
if((newState == LOW) && (oldState == HIGH)) {
// Short delay to debounce button.
delay(20);
// Check if button is still low after debounce.
newState = digitalRead(BUTTON_PIN);
if(newState == LOW) { // Yes, still low
modeNum = modeNum + 1;
if(modeNum > 3){
modeNum = 0;
}
if(modeNum == 0){
// turn off
colorWipe(strip.Color(0,0,0), 0);
delay(1000);
}
if(modeNum == 2){
// colorwipe to red then stop.
// this only run once after button click, so this part is
// put inside the button click block
colorWipe(strip.Color(255,0,0), 100);
}
/if(++mode > 3) mode = 0; // Advance to next mode, wrap around after #8 switch(mode) { // Start the new animation… case 0: colorWipe(strip.Color(255,0,0), 0); // Black/off break; case 1: colorAll(strip.Color(255,0,0), 50); // Red break; case 2: analogWrite(strip.Color(255,0,0), 50); // Red break; }/
}
}

// Set the last-read button state to the old state.
oldState = newState;

/if(modeNum == 0){ // turn off colorWipe(strip.Color(0,0,0), 0); delay(1000); }/
if(modeNum == 1){
// colorwipe red, then fully dark
colorWipe(strip.Color(255,0,0), 100);
colorWipe(strip.Color(0,0,0), 0);
}
/else if(modeNum == 2){ // this part cannot be run with loop }/
else if(modeNum == 3){
// all fade in and out
fadeInOutOnce(10);
}
}

// Fill strip pixels one after another with a color. Strip is NOT cleared
// first; anything there will be covered pixel by pixel. Pass in color
// (as a single ‘packed’ 32-bit value, which you can get by calling
// strip.Color(red, green, blue) as shown in the loop() function above),
// and a delay time (in milliseconds) between pixels.
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip…
strip.setPixelColor(i, color); // Set pixel’s color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}

void fadeInOutOnce(int wait) {
for(int j = 0; j < 160; j++){ for(int i=0; i 0; j–){
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip…
strip.setPixelColor(i, strip.Color(j,0,0)); // Set pixel’s color (in RAM)
strip.show(); // Update strip to match
}
delay(wait); // Pause for a moment
}
}

%d bloggers like this: