Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By Ben Baron
#15534 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?
Last edited by Ben Baron on Thu Aug 06, 2015 11:56 am, edited 1 time in total.
User avatar
By natetrue
#15643 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.