This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430G2553: Controlling neopixel led using Msp430G22553

Part Number: MSP430G2553

Hello i have found a library to control ws2812b neopixel led and i could figured out how this library works.Basically i know that ws2812 has data line and we use SPİ to send data but there is no explanation that how this LED RECİEVE bits, 

İ need to draw a cirlcle clockwise and counter clockwise, if someone can tell me a little about how to send data to draw a circle i would be realy appreciate :)

actually the  " void showStrip() " was the one i cant understant.

  • Hi Hakan,

    I think the showStrip() sends out the RGB values for each LED in the outer for loop:: for (i = 0; i < NUM_LEDS; i++) {

    In the 2nd for loop, as the comments indicate, it sends out the value corresponding to green, then red, then blue: for (j = 0; j < 3; j++) {

    In the 3rd loop, (while (mask != 0) {), it sends out each bit in the array for rgb[] of size 3.

    You can see that the green, red & blue in the LED definition.

    // WS2812 takes GRB format
    typedef struct {
    u_char green;
    u_char red;
    u_char blue;
    } LED;

    Hope that helps.

    Srinivas

  • Hello again, my project worked but sometimes push button (p2.3) work as if i pressed it.What is problem with my code can you hellp me?

    you can see below in my code the diffrentColour(); function sometimes works without pressing the button.

    note: i connected button directly to ground and used internal pull up resister

    #include "io430.h"
    #include "ws2812.h"
    //#include "in430.h"

    void gradualFill(u_int n, u_char r, u_char g, u_char b);
    void counterClockwise(u_int, u_char, u_char, u_char);
    void Flahshing(u_int, u_char, u_char, u_char);
    void diffrentColour(void);
    int main(void) {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT

    if (CALBC1_16MHZ==0xFF) // If calibration constant erased
    {
    while(1); // do not load, trap CPU!!
    }

    // configure clock to 16 MHz
    BCSCTL1 = CALBC1_16MHZ; // DCO = 16 MHz
    DCOCTL = CALDCO_16MHZ;

    // initialize LED strip
    initStrip();
    //ilk 4 giris ayarla
    P2DIR &= 0xE0;
    P2OUT |= BIT0 + BIT2 + BIT3 + BIT4;
    P2REN |= BIT0 + BIT2 + BIT3 + BIT4;

    // set strip color red
    fillStrip(0x00, 0x00, 0x00);
    showStrip(); // refresh strip

    while (1)
    {
    if(!(P2IN&BIT0)) // check if switch is pressed or not
    {
    __delay_cycles(50000);
    counterClockwise(NUM_LEDS, 0x20, 0x00, 0x00);
    fillStrip(0x00, 0x00, 0x00);

    }
    if(!(P2IN&BIT4))
    {
    __delay_cycles(50000);
    gradualFill(NUM_LEDS, 0x20, 0x00, 0x00);
    fillStrip(0x00, 0x00, 0x00);

    }
    if(!(P2IN&BIT2))
    {
    __delay_cycles(50000);
    Flahshing(NUM_LEDS, 0x20, 0x00, 0x00);
    }
    if(!(P2IN&BIT3))
    {
    __delay_cycles(50000);
    diffrentColour();
    }
    }

    }

    void counterClockwise(u_int n, u_char r, u_char g, u_char b)
    {
    for (int i = n-1; i >= 0; i--){ // n is number of LEDs
    setLEDColor(i, r, g, b);
    showStrip();
    __delay_cycles(8000000); // lazy delay
    }
    }
    void Flahshing(u_int n, u_char r, u_char g, u_char b)
    {

    fillStrip(0x20, 0x00, 0x00);
    __delay_cycles(5000000); // lazy delay
    fillStrip(0x00, 0x00, 0x00);
    __delay_cycles(5000000); // lazy delay
    fillStrip(0x20, 0x00, 0x00);
    __delay_cycles(5000000); // lazy delay
    fillStrip(0x00, 0x00, 0x00);


    }
    void gradualFill(u_int n, u_char r, u_char g, u_char b){
    for (int i = 0; i < n; i++){ // n is number of LEDs
    setLEDColor(i, r, g, b);
    showStrip();
    __delay_cycles(8000000); // lazy delay
    }
    }
    void diffrentColour(void)
    {
    setLEDColor(0,0,0,128);
    setLEDColor(1,255,255,255);
    setLEDColor(2,0,128,128);
    setLEDColor(3,0,255,0);
    setLEDColor(4,0,0,255);
    setLEDColor(5,255,255,0);
    setLEDColor(6,0,255,255);
    setLEDColor(7,255,0,255);
    setLEDColor(8,192,192,192);
    setLEDColor(9,0,128,0);
    setLEDColor(10,128,0,0);
    setLEDColor(11,128,0,128);
    showStrip();


    }

  • What kind of buttons are you using? You might have one that makes intermittent contact. When you say that it "sometimes works without pressing the button" do you mean that it will activate while just sitting there, or that it seems to act multiple times with one button press?

  • Hi thank you for answering,

    No there is no bouncing affect for my project,because function process times  are pretty enough to debounce. İ was saying that if there is somthing wrong with my if blocks or is it because of internal pull ups.

    But you know its stoped working unexpetedly.so its okey if there is noting wrong with my code

    Here is button;

**Attention** This is a public forum