Burning Man sign

Shaun and Kevin worked on a sign for Shaun’s tribe at Burning Man – POC People of Color.

Shaun used the ShopBot CNC to cut out the POC logo and space for the Arduino Nano.

Final result is a random selection of colors.

 

 

Arduino code to randomize the bottom sign and pick 5 random colors for the people in the logo.

/**
 * People of Color - Burning Man
 */

#define DATA_PIN (5)
#define CLOCK_PIN (6)

#define LIGHT_COUNT (10)

uint32_t pixels[LIGHT_COUNT];

uint32_t rainbowColor[5];
#define pinModeFast(x, y) pinMode(x, y)
#define digitalWriteFast(x, y) digitalWrite(x, y)
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
 #include <avr/power.h>
#endif

#define PINSTAR 9
#define PINPOC 10
#define NUM_LEDSSTAR 60
#define NUM_LEDSPOC 30

#define BRIGHTNESS 50

Adafruit_NeoPixel stripStar = Adafruit_NeoPixel(NUM_LEDSSTAR, PINSTAR, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel stripPOC = Adafruit_NeoPixel(NUM_LEDSPOC, PINPOC , NEO_GRB + NEO_KHZ800);



void setup() {
 pinModeFast(DATA_PIN, OUTPUT);
 pinModeFast(CLOCK_PIN, OUTPUT);
 digitalWriteFast(DATA_PIN, LOW);
 digitalWriteFast(CLOCK_PIN, LOW);
 stripStar.setBrightness(BRIGHTNESS);
 stripStar.begin();
 stripStar.show(); // Initialize all pixels to 'off'
 stripPOC.setBrightness(BRIGHTNESS);
 stripPOC.begin();
 stripPOC.show(); // Initialize all pixels to 'off'
 setRainbowColors();
}

void setRainbowColors (){
 for(int i = 0 ; i < 5 ; i++){
 rainbowColor[i] = stripPOC.Color(random(0,255) ,random(0,255),random(0,255)); 
 }
}
int currentPixel = 0;
int currentColor = 0;

uint8_t red(uint32_t c) {
 return (c >> 16);
}
uint8_t green(uint32_t c) {
 return (c >> 8);
}
uint8_t blue(uint32_t c) {
 return (c);
}
 
void loop() {
 setRainbowColors ();
 for(int i = 0; i < LIGHT_COUNT; i++){
 //solid_color(simple_color(0));
 //set_pixel(i,simple_color(currentColor));
 set_pixel(i,rainbowColor[ i / 2]);
 show();
 }
 
 for(int j = 0;j < NUM_LEDSSTAR;j++){
 stripStar.setPixelColor(j, rainbowColor[ j / 12]);
 stripStar.show();
 }

rainbowCycle(5);
}

void fadeColors(int pos){
 int redVal, greenVal, blueVal;
 
}
void colorWipe1(uint32_t c, uint8_t wait) {
 for(uint16_t i=0; i<stripStar.numPixels(); i++) {
 stripStar.setPixelColor(i, c);
 stripStar.show();
 delay(wait);
 }
}
void colorWipe2(uint32_t c, uint8_t wait) {
 for(uint16_t i=0; i<stripPOC.numPixels(); i++) {
 stripPOC.setPixelColor(i, c);
 stripPOC.show();
 stripPOC.show();
 delay(wait);
 }
}

static void set_pixel(uint8_t index, uint32_t color) {
 pixels[index] = color & 0x00FFFFFF;
}

static void set_pixel_rgb(uint8_t index, uint32_t r, uint32_t g, uint32_t b) {
 set_pixel(index, r | (g << 8) | (b << 16));
}

static void toggle_clock() {
 digitalWriteFast(CLOCK_PIN, HIGH);
 digitalWriteFast(CLOCK_PIN, LOW);
}

static void write_pixel(uint8_t i) {
 const uint32_t MASK = ((uint32_t)(1) << 24);
 uint32_t p = pixels[i] | MASK;
 int j = 25;
 while (j--) {
 digitalWriteFast(DATA_PIN, (p & MASK) ? HIGH : LOW);
 toggle_clock();
 p <<= 1;
 }
}

static void write_blank_pixel() {
 int j = 25;
 while (j--) {
 digitalWriteFast(DATA_PIN, 0);
 toggle_clock();
 }
}

static void show() {
 digitalWriteFast(DATA_PIN, LOW);
 for (int i = 0; i < 50; i++) {
 toggle_clock();
 }
 for (int i = 0; i < LIGHT_COUNT; ++i) {
 write_pixel(i);
 }
 write_blank_pixel();
 delay(1);
}

static void solid_color(uint32_t color) {
 for (int i = 0; i < LIGHT_COUNT; ++i) {
 set_pixel(i, color);
 }
}

static uint32_t simple_color(uint8_t color) {
 switch (color) {
 case 0:
 return 0x0000ff00; // Green
 case 1:
 return 0x00ffff00; // Yellow
 case 2:
 return 0x00ff0000; // Red 
 default:
 return 0x00000000;
 }
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
 uint16_t i, j;

for(j=0; j<256 * 5; j++) { // 5 cycles of all colors on wheel
 for(i=0; i< stripPOC.numPixels(); i++) {
 stripPOC.setPixelColor(i, Wheel(((i * 256 / stripPOC.numPixels()) + j) & 255));
 }
 stripPOC.show();
 delay(wait);
 }
}



// 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 stripPOC.Color(255 - WheelPos * 3, 0, WheelPos * 3,0);
 }
 if(WheelPos < 170) {
 WheelPos -= 85;
 return stripPOC.Color(0, WheelPos * 3, 255 - WheelPos * 3,0);
 }
 WheelPos -= 170;
 return stripPOC.Color(WheelPos * 3, 255 - WheelPos * 3, 0,0);
}



static void scroll(int8_t delta) {
 size_t bytes_to_move = (LIGHT_COUNT - delta) * sizeof(uint32_t);
 if (delta > 0) {
 memmove(&pixels[delta], &pixels[0], bytes_to_move);
 } else {
 memmove(&pixels[0], &pixels[-delta], bytes_to_move);
 }
}

static void wipe(uint8_t delay_msec) {
 for (int i = 0; i < LIGHT_COUNT; ++i) {
 scroll(1);
 set_pixel(0, 0);
 show();
 delay(delay_msec);
 }
}

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.