Adafruit Neo_pixel - Colour NOT changing

Hi,
My name is Alen. I’m trying to make my own library for Adafruit Neopixel RGB LEDs.
I’m able to select the particular LEDs, but I’m not able to change the colour or the intensity of any of the LEDs in the strip.

This is the code i’m using

/***************************************************************************
WS2811 code WS2811 code another timing

0 code - 0.5us+2us = 2.5us .4
400ns+850ns .85

1 code - 1.2us+1.3us = 2.5us .8
.45
1NOP = 250ns
0 code
2NOP = 500ns 400ns = 1.6 2NOP = 500ns
4NOP = 2000ns 850ns = 3.4 3NOP = 750ns 4NOP = 1000ns

1 code
4.8NOP = 1200ns 800ns = 3.2 3NOP = 750ns
5.2NOP = 1300ns 450ns = 1.8 2NOP = 500ns

Reset_Time>=50usec

Here the code is generated using the "asm NOP operations as we don’t have
built -in nanoseconds delay function.

***************************************************************************/
#define TRUE 1
#define FALSE 0

#define OUT_PIN1 6
#define OUT_PIN2 4

#define CLK16_P125 TRUE
#define CLK16_P25 FALSE

#if CLK16_P125
#define CODE0_HIGH asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);

#define CODE0_LOW asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);

#define CODE1_HIGH asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);

#define CODE1_LOW asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
#endif

#if CLK16_P25
#define CODE0_HIGH asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);

#define CODE0_LOW asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);

#define CODE1_HIGH asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);

#define CODE1_LOW asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
asm(“NOP \n”);
#endif

void setup()
{
pinMode(OUT_PIN1, OUTPUT);
pinMode(OUT_PIN2, OUTPUT);
Serial.begin(9600);
}

void loop()
{
//unsigned char r_led_val=0xFF,g_led_val=0xFF,b_led_val=0xFF;
//unsigned char led[3]={0xFF,0xFF,0xFF};
//unsigned char led[3]={0xAA,0xAA,0xAA};
//unsigned char led[3]={0x55,0x55,0x55}; //ok all white without delay(1)
//unsigned char led[3]={0x7F,0x7F,0x7F};
//unsigned char led[3]={0xFF,0x00,0x00}; // only 1st Green
unsigned char led[3]={0xFF,0xFC,0xFF};
unsigned char i,j,k;

for(k=0; k<4; k++)
{
for(j=0; j<3; j++)
{
for(i=0; i<8; i++)
{
if(0x80&(led[j]<<i))
{
digitalWrite(OUT_PIN1, HIGH);
CODE1_HIGH; //0.5usec
digitalWrite(OUT_PIN1, LOW);
CODE1_LOW; //2usec

digitalWrite(OUT_PIN2, HIGH);
}
else
{

digitalWrite(OUT_PIN1, HIGH);
CODE0_HIGH; //1.2usec
digitalWrite(OUT_PIN1, LOW);
CODE0_LOW; //1.3usec

digitalWrite(OUT_PIN2, LOW);
}
}
//delayMicroseconds(200);
//delay(1);
}
}
digitalWrite(OUT_PIN1, LOW);
delayMicroseconds(60);
}

////////////*************************

Please note that

“asm(“NOP \n”);”

is given to create a delay after sending HIGH or LOW pulses.

Expecting all the help.

Thankyou.

Hi there!

I am also starting to work with neopixels, namely the neopixel shield. Upon going through the example codes and seeing what functions need to be called at what points, I see that for any change to be sent to the LED(s), the show() function needs to be called. Do you have the essence of this function in your library somewhere?

Please, someone help me with this. I've gone through every website that google is showing me. Still nowhere. Looking forward to finding a solution.

You have all that code to precisely define a time delay and then you go and use the digitalWrite function that takes 4uS. You need to be using direct port addressing.

Also you don’t seem to be sending a header or the trailing bits. Look at the WS2812 data sheet for what you need.