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.
#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);
}
}
I’d reccomend you to take a look at this tutorial, might help you out.
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
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.
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.
Yes you are right , just thinking about dotstar .
NeoPixels dont have a clock just rely on strict timing. but you still cant control them with the digitalWrite.
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.