Luís Afonso
Published © GPL3+

RGB Mood Lamp with MSP430G2553

A small gift I made. A RGB mood lamp using a MSP430G2553 for low power control.

BeginnerShowcase (no instructions)2,122
RGB Mood Lamp with MSP430G2553

Things used in this project

Hardware components

Texas Instruments MSP430G2 Launchpad
×1
Texas Instruments MSP430G2553
×1
Adafruit NEOPIXEL RING - 12 X WS2812 5050 RGB LED WITH INTEGRATED DRIVERS
×1
3.3V voltage regulator (generic)
×1
Capacitors for the regulator
×1
Veroboard
×1
47K 0,125W resistor
×1
Wire
×1
Switch
×1
Solder
×1

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Control board

The squares is where wires are soldered. Red=5V; Black=GND; Brown=switch; Blue=Signal

Code

RGB lamp code

Arduino
You require Energia and the library described in "story" to use this code
#include <WS2811Driver.h>

// 24 bits of color data stored GGRRBB

#define NumOfS2812 12
#define NumOfLED 36
#define Step 1
uint8_t leds[NumOfLED];


uint8_t r[NumOfS2812];
uint8_t g[NumOfS2812];
uint8_t b[NumOfS2812];


WS2811Driver ledStrip; // uses P1_7 as datapin connect to DIN on strip

void setup(void)
{
  ledStrip.setLEDCount(12); // setup for 4 leds on a strip
  ledStrip.begin();        // configure P1.7 for output
  randomSeed(analogRead(0));

  for(int i=0; i < NumOfS2812/2; i++)
    r[i]= 255;
  for(int i=0; i < NumOfS2812/2; i++)
    g[i] = (i*51);   
  for(int i=0; i < NumOfS2812/2; i++)
    g[NumOfS2812/2+i]= 255;
  for(int i=0; i < NumOfS2812/2; i++)
    r[NumOfS2812/2+i] = 255-(i*51);   
  /* for(int i=0; i < NumOfS2812/3; i++)
   g[2*NumOfS2812/3+i]= 255;
   for(int i=0; i < NumOfS2812/3; i++)
   b[2*NumOfS2812/3+i] = (i*85);   */

}

void loop() {


  
  for(int i=0; i <NumOfS2812;i++){
    //red up
    if(b[i]==255 && g[i] == 0  && r[i] != 255) 
      r[i] += Step; 
    //blue down 
    else if(r[i]==255 && b[i] != 0)  
      b[i] -= Step;  
    //green up  
    else if(r[i]==255 && b[i]==0 && g[i] != 255) 
      g[i] += Step;
    //red down  
    else if(g[i]==255 && r[i] != 0)
      r[i] -= Step; 
    //blue up  
    else if(g[i]==255 && r[i] == 0  && b[i] != 255)  
      b[i] += Step;
    //green down
    else if(b[i]==255 && g[i] != 0)  
      g[i] -= Step;  

    /*if(r[i] > 255)
      r[i] = 255;
    if(g[i] > 255)
      g[i] = 255;
    if(b[i] > 255)
      b[i] = 255;

    if(r[i] < 0)
      r[i] = 0;
    if(g[i] < 0)
      g[i] = 0;
    if(b[i] < 0)
      b[i] = 0;*/
  }
  for(int k=0; k < NumOfS2812; k++){
    leds[k*3+1] = r[k];
    leds[k*3] = g[k];
    leds[k*3+2] = b[k];     

  } 

  ledStrip.write(leds);               // set leds to red,green,blue,white

  int time = random(1,20);
  sleep(time); 
  //delayMicroseconds(time*100);  

}

Credits

Luís Afonso

Luís Afonso

7 projects • 11 followers
Thanks to Rickta59 and areynolds15.

Comments