Skip to content

mohitbhoite/neopixel-lightbar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Neopixel Lightbar

I made a neopixel lightbar controller to add color to my macro photographs. I usually just use mono colored LEDs to accomplish that, but thought something like this will give me more control.

The design uses the Adafruit Trinket M0 as the main controller. The light bar is an Adafruit RGBW Neopixel stick. I used four potentiometers to control intensity of each color (Red, Green, Blue, and White). By varying the individual pots, you can create a multitude of different colors.

Parts List

Wiring

Schematic

Assembly

The 3D STL files for the enclosure and the lid are under the /cad folder. They were printed on a Prusa i3 MK3 printer.

You can secure the Neopixel strip and the Trinket M0 with small #2 wood screws.

The knobs should press fit onto the potentiometers.

I used brass #2 wood screws to secure the lid on to the enclosure body.

Code

Code available under the /code folder

NOTE: You'll need to install and add the Adafruit Neopixel library for this code to work. Instructions to add this in your code are available here.

#include <Adafruit_NeoPixel.h>
int red,green,blue,white = 0;

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIN 4
#define NUMPIXELS 8

//Initialize the neopixel strip
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_RGBW + NEO_KHZ800);

void setup() {
    //Set the pins connected to the potentiometer as inputs
    pinMode(0,INPUT);
    pinMode(1,INPUT);
    pinMode(2,INPUT);
    pinMode(3,INPUT);
    
   strip.begin();
   strip.show(); // Initialize all pixels to 'off'
   rainbowCycle(1);//Flash rainbows at the begining
}

void loop() {

    //Read and store the potentiometer values
    //We are scaling them from a 12bit scale to an 8 bit scale
    red = map(analogRead(A0), 0, 4095, 0, 255);
    green = map(analogRead(A1), 0, 4095, 0, 255);
    blue = map(analogRead(A2), 0, 4095, 0, 255);
    white = map(analogRead(A3), 0, 4095, 0, 255);

    //set colors of all the eight neopixles
    for(int pixel=0;pixel<8;pixel++)
    {
        strip.setPixelColor(pixel, red, green, blue, white);
    }
    strip.show();//Update the strip with new color values
    delay(50);
}

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< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Helper function for rainbows
// 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);
}

About

A RGBW lightbar for macro photography

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages