-->
Page 1 of 12

[SOLVED] Anyone get NeoPixel / WS8212 LEDs working?

PostPosted: Fri Apr 24, 2015 4:41 pm
by Ben Baron
I've seen some example code for the regular ESP sdk, but nothing that works with the Arduino SDK. I've been trying to port over this library: https://github.com/sfranzyshen/ws2812esp8266 but while I got it building in the Arduino IDE, I haven't had success yet getting it to work.

Does anyone have a working library for NeoPixels / WS8212 LEDs that they can share?

Re: Anyone get NeoPixel / WS8212 addressable LEDs working?

PostPosted: Fri Apr 24, 2015 6:40 pm
by Makuna
Sorry, nothing to share yet, but this is on my list for next week to start looking into.

Re: Anyone get NeoPixel / WS8212 addressable LEDs working?

PostPosted: Fri Apr 24, 2015 7:19 pm
by andrew melvin
This and the u8glib... are my most wanted modules....

I'm well out of my league trying to get them to work myself though... I've only been writing c / arduino for 4w.

:)

Re: Anyone get NeoPixel / WS8212 addressable LEDs working?

PostPosted: Sat Apr 25, 2015 10:20 pm
by natetrue
I've got it working on my project just using the SPI driver. Connect the WS2812 input pin to GPIO13.

Call SPI.begin() in your setup() code. Then, this (I have led_colors[] as an array of unsigned ints with 0xRRGGBB values):
Code: Select all  for (int i = 0; i < NUM_LEDS; i++)
  {
    uint32_t out = (led_colors[i] & 0xFF) | ((led_colors[i] & 0xFF00) << 8) | ((led_colors[i] & 0xFF0000) >> 8);
    for (int b = 0; b < 24; b++)
    {
    SPI.transfer((out & 0x800000) ? 0xFF : 0xE0);
    out <<= 1;
    }
  }


I tried at first using just GPIO bit banging but every once in a while there's a delay inserted (I assume it's an interrupt for something) which throws off the protocol.