Simple LightBox

About: Im a curious maker, but am currently new to Instructables. Will post several projects the next year!

Pretty mutch this project is a box that changes colour when the button is pressed. Its green in the first mode and turns red in the second mode. If the button is hold down for 2 seconds it will go to the party mode.

I mainly use this for longer meetings where people start talking about personal stuff. This is to indicate that we should rather continiue the meeting then talking shit.

3D model:

https://a360.co/2DpVs0O

Code written in PlatformIO:

https://github.com/kattemjau/LightCube

<p>#include <br>#ifdef __AVR__
  #include 
#endif</p><p>#define PIN 6</p><p>// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 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)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);</p><p>// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.</p><p>int r=3,g=4,b=5;</p><p>void setup() {
  // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
  #if defined (__AVR_ATtiny85__)
    if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
  #endif
  // End of trinket special code</p><p>//button pin2
  pinMode(2, INPUT_PULLUP);
  pinMode(r, OUTPUT);
  pinMode(g, OUTPUT);
  pinMode(b, OUTPUT);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}
// 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);
}</p><p>// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i</p><p>void rainbow(uint8_t wait) {
  uint16_t i, j;</p><p>  for(j=0; j<256; j++) {
    for(i=0; i</p><p>// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint16_t i, j;</p><p>  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}</p><p>//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();</p><p>      delay(wait);</p><p>      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}</p><p>//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
      }
      strip.show();</p><p>      delay(wait);</p><p>      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}
int state =0, glow=127;</p><p>void loop() {
  // Some example procedures showing how to display to the pixels:
  //colorWipe(strip.Color(255, 0, 0), 50); // Red
//  colorWipe(strip.Color(0, 255, 0), 50); // Green
//  colorWipe(strip.Color(0, 0, 255), 50); // Blue
//colorWipe(strip.Color(0, 0, 0, 255), 50); // White RGBW
  // Send a theater pixel chase in...
//  theaterChase(strip.Color(127, 127, 127), 50); // White
////  theaterChase(strip.Color(0, 0, 127), 50); // Blue</p><p>  if(digitalRead(2)!=HIGH){
    int counter=0;
    while(digitalRead(2)!=HIGH){
      counter++;
      delay(10);
    }
    if(counter>= 150){
      if(state==4){
          state=0;
      }else{
        state=4;
      }
    }else{
      state++;
    }
  }
  if(state==0){
    //reset All
    // for (uint16_t i=0; i < strip.numPixels(); i++) {
    //   strip.setPixelColor(i, strip.Color(0, 0, 0));    //turn every third pixel on
    // }
    digitalWrite(r,0);
    digitalWrite(g,0);
    digitalWrite(b,0);
    state=1;
  }
  if(state ==1){
    //green flashing
    digitalWrite(g,1);
    for (uint16_t i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, strip.Color(0, glow, 0));    //turn every third pixel on
    }
    strip.show();
  }if(state==2){
    //red flashing
    digitalWrite(b,1);
    for (uint16_t i=0; i < strip.numPixels(); i++) {
      strip.setPixelColor(i, strip.Color(glow, 0, 0));    //turn every third pixel on
    }
    strip.show();
  }if(state==3){
    state=0;
  }if(state==4){
    //partymode if button hold for 2 sek
    digitalWrite(r,1);
    rainbow(10);
    //rainbowCycle(20);</p><p>  }if(state==5){
    state=0;
  }</p><p>//theaterChaseRainbow(50);
}</p>

Step 1: Step 1: Leds and Controller

Cut led strip to length and solder them together. Remeber that the data pin is directional, and goes from pin 6 on the arduino nano. The RGB diodes goes from pin 3-5, and the switch is connected to pin2.

Step 2:

Solder battery together with a 1s BMS unit from ebay. This acts like a charger and a protection ic. The switch is connected between the battery and the bms to prevent vampire drain. Cut holes to the USB connector and the switch.

Flash the mcu with the included code and ur done. It needs the adafruit neopixel libary.

Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Games Contest

      Games Contest
    • Planter Challenge

      Planter Challenge

    2 Discussions

    0
    None
    randofo

    5 months ago

    Hello again,

    Thanks for expanding on your project and showing us how it was made.

    However, there is still a word in your introduction that runs afoul of our community standards (hint: four letter word that starts with 's'). I was wondering if you would mind changing that word so that I can go ahead and publish this?

    Thank You,
    Randy

    0
    None
    randofo

    5 months ago

    Hello there!

    We're glad you want to share something with the Instructables community!

    And we’re here to help you out.

    Due to some recent changes on the site, we are no longer able to publish stand-alone videos and other forms of incomplete posts. In order to be published live on the site, Instructables must consist of the following things:

    - Multiple steps showing how you made your project

    - Written instructions in each step

    - Your own original images

    Beyond making your Instructable simply publishable, this guide (https://www.instructables.com/id/How-to-Create-a-Feature-Worthy-Instructable/) explains what is required to have your Instructables featured by our site editors. It’s very helpful, and definitely worth checking out.

    We would love to review your project again after you have made the necessary edits, and we will publish your project if it is eligible.

    If you have any questions, please feel free to ask right here or send us an email at service@instructables.com.

    Best,

    Instructables Community Manager