Skip to content

Instantly share code, notes, and snippets.

@lewayotte
Last active October 30, 2018 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lewayotte/60947111671dd18b96a5c79ae732eefd to your computer and use it in GitHub Desktop.
Save lewayotte/60947111671dd18b96a5c79ae732eefd to your computer and use it in GitHub Desktop.
Arduino script used for lighting up the shoulders and headphones of the DJ Yonder cosplay...
#include <FastLED.h>
//Using these LEDs: https://amzn.to/2qkaduF
//INVOLT WS2812B LED Strip Individually Addressable 60LED/M 3.2FT 1M, No Waterproof Flexible for DIY Decoration, DC 5V with Smart IC Chip Built-in Self Adhesive
#define LED_PIN 3 //Using pin 3 on an Adafruit Pro Trinket - 3V 12MHz: https://amzn.to/2yKQMQp
#define NUM_LEDS 52 //Didn't use all the LEDs in the strip
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
#define BRIGHTNESS 255
//I'm using a cellphone battery pack (for portable charging your cellphone).
//If there isn't enough current draw, it automatically turns off...
//For what I'm using, these brightness settings kept the battery pack turned on.
int MAX_BRIGHTNESS = 30;
int MIN_BRIGHTNESS = 10;
unsigned long shoulder_time = 0;
int shoulder_delay_interval = 0;
int shoulder_delays[] = {100, 100, 50, 50, 50};
int shoulder_loop = 0;
int min_shoulder_loop[] = {11, 12, 13, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
unsigned long ear_time = 0;
int ear_delay = 50;
int ear_loop = 0;
int min_ear_loop[] = {37, 38, 39, 28, 29, 30, 31, 32, 33, 34, 34, 36};
//I accidentally adhered these backwards on the Left ear. To make it easier
//I'm creating a static left ear loop for setting the min brightness
int min_left_ear_loop[] = {42, 41, 40, 51, 50, 49, 48, 47, 46, 45, 44, 43};
CRGB leds[NUM_LEDS];
// Colors from: https://htmlcolorcodes.com/color-names/
void setup() {
LEDS.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>( leds, NUM_LEDS );
FastLED.setBrightness( BRIGHTNESS );
//Right Shoulder
for ( int i = 0; i <= 7; i++ ) {
leds[i] = CRGB::HotPink;
}
leds[8] = CRGB::DeepSkyBlue;
leds[9] = CRGB::DeepSkyBlue;
leds[10] = CRGB::Lime;
leds[11] = CRGB::Lime;
leds[12] = CRGB::Gold;
leds[13] = CRGB::Gold;
//Left Shoulder
for ( int i = 14; i <= 21; i++ ) {
leds[i] = CRGB::HotPink;
}
leds[22] = CRGB::DeepSkyBlue;
leds[23] = CRGB::DeepSkyBlue;
leds[24] = CRGB::Lime;
leds[25] = CRGB::Lime;
leds[26] = CRGB::Gold;
leds[27] = CRGB::Gold;
//Right Ear
leds[28] = CRGB::HotPink;
leds[29] = CRGB::DeepSkyBlue;
leds[30] = CRGB::HotPink;
leds[31] = CRGB::Gold;
leds[32] = CRGB::DeepSkyBlue;
leds[33] = CRGB::HotPink;
leds[34] = CRGB::HotPink;
leds[35] = CRGB::DeepSkyBlue;
leds[36] = CRGB::Gold;
leds[37] = CRGB::Lime;
leds[38] = CRGB::HotPink;
leds[39] = CRGB::Lime;
//Left Ear
//Wired backwards... so same colors, but reverse order as the Right ear... meh
leds[40] = CRGB::Lime;
leds[41] = CRGB::HotPink;
leds[42] = CRGB::Lime;
leds[43] = CRGB::Gold;
leds[44] = CRGB::DeepSkyBlue;
leds[45] = CRGB::HotPink;
leds[46] = CRGB::HotPink;
leds[47] = CRGB::DeepSkyBlue;
leds[48] = CRGB::Gold;
leds[49] = CRGB::HotPink;
leds[50] = CRGB::DeepSkyBlue;
leds[51] = CRGB::HotPink;
for ( int i = 0; i <= 51; i++ ) {
leds[i].maximizeBrightness( MIN_BRIGHTNESS );
}
FastLED.show();
}
void loop() {
// Shoulders: LED 0 - 27 (28 LEDS )
// Ears: LED 28 - 51 (24 LEDS )
// 52 LEDs total
// Good article on using millis() instead of delay() for non-blocking actions, like we need for this cosplay
// https://www.norwegiancreations.com/2017/09/arduino-tutorial-using-millis-instead-of-delay/
//Shoulders
if ( shoulder_loop > 13 ) {
shoulder_loop = 0;
shoulder_delay_interval++;
}
if ( shoulder_delay_interval > 5 ) {
shoulder_delay_interval = 0;
}
if ( millis() > shoulder_time + shoulder_delays[ shoulder_delay_interval ] ) {
leds[shoulder_loop].maximizeBrightness( MAX_BRIGHTNESS ); //Right Shoulder
leds[shoulder_loop + 14].maximizeBrightness( MAX_BRIGHTNESS ); //Left Shoulder
leds[min_shoulder_loop[shoulder_loop]].maximizeBrightness( MIN_BRIGHTNESS ); //Right Shoulder
leds[min_shoulder_loop[shoulder_loop] + 14].maximizeBrightness( MIN_BRIGHTNESS ); //Left Shoulder
shoulder_loop++;
shoulder_time = millis();
}
//Ears
if ( ear_loop > 11 ) {
ear_loop = 0;
}
if ( millis() > ear_time + ear_delay ) {
leds[ear_loop + 28].maximizeBrightness( MAX_BRIGHTNESS ); //Right Ear
leds[51 - ear_loop].maximizeBrightness( MAX_BRIGHTNESS ); //Left Ear
leds[min_ear_loop[ear_loop]].maximizeBrightness( MIN_BRIGHTNESS ); //Right Ear
leds[min_left_ear_loop[ear_loop]].maximizeBrightness( MIN_BRIGHTNESS ); //Left Ear
ear_loop++;
ear_time = millis();
}
FastLED.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment