# Connect to WS2812 error

**URL:** <https://community.particle.io/t/connect-to-ws2812-error/17691>\
**Category:** Troubleshooting\
**Created:** [November 22, 2015, 6:44pm UTC](https://community.particle.io/t/connect-to-ws2812-error/17691 "2015-11-22T18:44:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![helxsz](https://avatars.discourse-cdn.com/v4/letter/h/f0a364/32.png) [@helxsz](https://community.particle.io/u/helxsz)\
**Post date:** [November 22, 2015, 6:44pm UTC](https://community.particle.io/t/connect-to-ws2812-error/17691/1 "2015-11-22T18:44:35Z")

</div>

i am connecting 2 WS2812 rgb led to the particle core, as shown in the image below, where the control pin is D7 along with 3.3v and ground connected, I am using the WS2801 library. However the WS2812 led doesn’t light at all. if I connect the led circuit to the arduino board with the same pin, it works as shown in figure 2.

 ![](https://us1.discourse-cdn.com/flex026/uploads/particle/original/2X/c/ce86c5ec11d1755b49da2e8e7c0caa928d4cf7c0.jpg)

 ![](https://us1.discourse-cdn.com/flex026/uploads/particle/original/2X/3/3d20f946ba219e851eb29b6fe7659d96b941f5d2.jpg)

The code is shown as

```auto

#include "WS2801/WS2801.h"
#include "application.h"
int led1 = D0; // Instead of writing D0 over and over again, we'll write led1    
int led2 = D7; // Instead of writing D7 over and over again, we'll write led2

const int numPixel = 2;
Adafruit_WS2801 strip = Adafruit_WS2801(numPixel,D7);

void setup() {
 
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  strip.begin();
   
}

int red = 0;
int green = 0;
int blue = 0;

void loop() {
  digitalWrite(led1, HIGH);
  digitalWrite(led2, HIGH);
  delay(1000);

  digitalWrite(led1, LOW);
  digitalWrite(led2, LOW);

  delay(1000);
  
    red = 10; 
    green = 20; 
    blue = 100; 
    for (int i=0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i, red, green, blue);
        strip.show();
        delay(50);
    }  
}

```

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [November 22, 2015, 7:21pm UTC](https://community.particle.io/t/connect-to-ws2812-error/17691/2 "2015-11-22T19:21:24Z")

</div>

I’d reccomend you to take a look at this tutorial, might help you out.

> **[Powering NeoPixels | Adafruit NeoPixel Überguide | Adafruit Learning System](https://learn.adafruit.com/adafruit-neopixel-uberguide/powering-neopixels)**
>
> Everything you always wanted to know about Adafruit NeoPixels but were afraid to ask

Although you say you’ve hooked the board up in the same way on the Arduino, it appears to me that over there, it’s hooked up to the 5V. Considering that they’re 5V devices, that might make a difference 😉

---

<div class="post-metadata">

**Author:** ![peter\_a](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@peter\_a](https://community.particle.io/u/peter_a)\
**Post date:** [November 22, 2015, 9:22pm UTC](https://community.particle.io/t/connect-to-ws2812-error/17691/3 "2015-11-22T21:22:11Z")

</div>

As far as I know the WS2812s are NeoPixels and are driven by SPI .  
So led1 and led2 are just the clock and data in pin not a way to control each pixel.

Also if you see you see the line :-

Adafruit\_WS2801 strip = Adafruit\_WS2801(numPixel,D7);

You know that to control it with the library it would have to be strip.whatever() and not the pins directly .

---

<div class="post-metadata">

**Author:** ![Moors7](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/moors7/32/588_2.png) [@Moors7](https://community.particle.io/u/Moors7)\
**Post date:** [November 22, 2015, 9:35pm UTC](https://community.particle.io/t/connect-to-ws2812-error/17691/4 "2015-11-22T21:35:08Z")

</div>

Additionally, I’d recommend using the Neopixel library that’s on top of the libraries tab. That one is probably better supported since that’s what’s being used most. Also, it explicitly mentions support for the LEDs you’re using.  
If/when using that, take a look at the provided example to get a feel for the workings of the library before stumbling onto your own path.

Since I like to first check power related issues, I hadn’t yet bothered to check the code (assuming the EXACT same thing was running on the Arduino). The points mentioned by @peter_a should definitely be taken into consideration.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 22, 2015, 10:26pm UTC](https://community.particle.io/t/connect-to-ws2812-error/17691/5 "2015-11-22T22:26:19Z")

</div>

> [@peter\_a](#):
>
> As far as I know the WS2812s are NeoPixels and are driven by SPI

I might be wrong, but NeoPixels only have one control line where the clock timing (pulse-pause-ratio)also carries the data.

> **[Light\_WS2812 library V2.0 – Part I: Understanding the WS2812](https://cpldcpu.wordpress.com/2014/01/14/light_ws2812-library-v2-0-part-i-understanding-the-ws2812/)**
>
> WS2812 LEDs are amazing devices – they combine a programmable constant current controller chip with a RGB LED in a single package.  Each LED has one data input and one data output pin. By con…

---

<div class="post-metadata">

**Author:** ![peter\_a](https://avatars.discourse-cdn.com/v4/letter/p/cdc98d/32.png) [@peter\_a](https://community.particle.io/u/peter_a)\
**Post date:** [November 22, 2015, 11:51pm UTC](https://community.particle.io/t/connect-to-ws2812-error/17691/6 "2015-11-22T23:51:41Z")

</div>

Yes you are right , just thinking about dotstar .  
NeoPixels don`t have a clock just rely on strict timing. but you still can`t control them with the digitalWrite.

---

<div class="post-metadata">

**Author:** ![ScruffR](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/scruffr/32/6952_2.png) [@ScruffR](https://community.particle.io/u/ScruffR)\
**Post date:** [November 23, 2015, 8:02am UTC](https://community.particle.io/t/connect-to-ws2812-error/17691/7 "2015-11-23T08:02:59Z")

</div>

Not with `digitalWrite()` as it does quite a bit of sanity checking and stuff, but [`digitalWriteFast()`, `pinSetFast()` and `pinResetFast()`](https://docs.particle.io/reference/firmware/photon/#low-level-input-output) would be speedy enough but as @Moors7 said, why reinvent the wheel?

BTW: In case you ever wondered why your post sometimes format oddly, this comes from your use of the grave accent ( ` ) instead of the apostrophe ( ’ - the one you’d also use for `char` literals like `'\n'`) in your “don’t, can’t, …”.  
The parts between pairs of grave accents will be formatted as inline code.
