Can I use two for statements at once?

Hello everyone,

I am trying to simultaneously increase one RGB LED value and decrease another to create a smooth transition between RED and GREEN. I am currently using two FOR statements however it only seems to execute the one that comes first. Is there a way of re phrasing what I’m trying to do or is it not possible?

P.s I’m still fairly new to Arduino.

for(int i=0; i<=255; i = i + x) //Turn GREEN LED brightness UP. 
 for(int i2=0; i2<=255; i2 = i2 - x) //Turn RED LED brightness DOWN. 
 {
 pixels.setPixelColor(7, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(i2,i,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(10); // Time taken for the brightness to reach 255 (in milliseconds).

As you have discovered what you have written are ‘nested’ loops. One one the outside, the other on the inner and for each step of the outer loop the inner one runs 255 times!

Why not try just one loop (incrementing i), but

pixels.Color(i2,i,0)

becomes

pixels.Color(255-i,i,0)

?

While you are at it, why not another loop to iterate over the first argument to setPixelColor()?

Please consider writing a minimal sketch that illustrates the problem. It would be helpful if that sketch didn't use libraries that we don't have. It would also help if that sketch used the serial monitor for output rather than LEDs that we may not have, and don't want to hook up. If you post such a sketch, please post the whole sketch, rather than just a part of it, so we can easily download it, compile it, run it, and see the symptoms that you report. Tell us what you expected, and tell us how what you got is different from that.

What happens when you try to assign a negative value to the color of an LED?

dannable:

pixels.Color(255-i,i,0)

+1 to this approach.

DuaneDegn:
+1 to this approach.

Nice, but...
The effect would be from pure red to mixture of red / green to pure green.
Is that the what the OP wants?

tmd3:
Please consider writing a minimal sketch that illustrates the problem. It would be helpful if that sketch didn't use libraries that we don't have. It would also help if that sketch used the serial monitor for output rather than LEDs that we may not have, and don't want to hook up. If you post such a sketch, please post the whole sketch, rather than just a part of it, so we can easily download it, compile it, run it, and see the symptoms that you report. Tell us what you expected, and tell us how what you got is different from that.

What happens when you try to assign a negative value to the color of an LED?

An interesting approach basically putting the burden of the proof back to the OP.
I don't feel that is how it should work.
The OP is asking for help and if you cannot help using the code posted so far - why bother?
You can ask for clarification , but expecting the OP to rebuild the code ( removing libraries references ?) so YOU can work on it is not realistic.

Not to be smart about the matter, but in this case of "FOR statements not working" - what was preventing you to "cut and paste" just the for loops without the actual processing and replacing it with Serial.print(x,y)? The "for" loops variables are the key, the actual process , be it color changes or whatever, is not that important.

Like this
loop()
{
for(x ...)
for(y...)
Serial print(x,y...);
...
}

Vaclav:
Nice, but...
The effect would be from pure red to mixture of red / green to pure green.
Is that the what the OP wants?

That's the way I understood the request.

LorenzoPDE:
I am trying to simultaneously increase one RGB LED value and decrease another to create a smooth transition between RED and GREEN.

Here's one of my experiments with NeoPixels.

I was trying for a hypnotic feel. I have a heck of a time trying to record LED projects. The LEDs don't look nearly as good in the video as they do in real life.

I've learned since making the above video, NeoPixels are one of the few 5V devices which don't work well with 3.3V logic. I've also learned NeoPixels work fine when powered with 3.3V. The also work well powered from a single cell LiPo (though I don't think you're supposed to use logic levels higher than Vdd, so don't drive LiPo powered Pixels with 5V logic).

Did you not notice that you have seven replies?

(This was in response to a post by the OP that they have now deleted.)

Thanks for the replies! I will start implementing what everyone has told me and keep you posted!

This is what I have so far…

//pixels.setPixelColor(7, pixels.Color(255,0,0)); // RED color.
//pixels.setPixelColor(7, pixels.Color(255,150,0)); // AMBER color.
//pixels.setPixelColor(7, pixels.Color(0,255,0)); // GREEN color.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            12

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      8

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

void setup() {

  pixels.begin(); // This initializes the NeoPixel library.
  pixels.setBrightness(10);

}

void loop() {

  int x = 1;
  for(int i=0; i<=255; i = i + x){

 pixels.setPixelColor(7, pixels.Color(i,0,0)); // 
 pixels.setPixelColor(6, pixels.Color(i,0,0)); // 
 pixels.setPixelColor(5, pixels.Color(i,0,0)); // 
 pixels.setPixelColor(4, pixels.Color(i,0,0)); // 
 pixels.setPixelColor(3, pixels.Color(i,0,0)); // 
 pixels.setPixelColor(2, pixels.Color(i,0,0)); // 
 pixels.setPixelColor(1, pixels.Color(i,0,0)); // 
 pixels.setPixelColor(0, pixels.Color(i,0,0)); // 
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(10); // Time taken for the brightness to reach 255 (in milliseconds).
   }
  int RED = 255;
  if ( RED >= 255)
  {
 pixels.setPixelColor(7, pixels.Color(RED,0,0)); // 
 pixels.setPixelColor(6, pixels.Color(RED,0,0)); // 
 pixels.setPixelColor(5, pixels.Color(RED,0,0)); // 
 pixels.setPixelColor(4, pixels.Color(RED,0,0)); // 
 pixels.setPixelColor(3, pixels.Color(RED,0,0)); // 
 pixels.setPixelColor(2, pixels.Color(RED,0,0)); //
 pixels.setPixelColor(1, pixels.Color(RED,0,0)); // 
 pixels.setPixelColor(0, pixels.Color(RED,0,0)); // 
 pixels.show();// This sends the updated pixel color to the hardware.
 delay(3000); //Stay on Red Colour for 3 seconds. 
  }
 
  for(int i=0; i<=150; i = i + x){

 pixels.setPixelColor(7, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(RED,i,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(10); // Time taken for the brightness to reach 255 (in milliseconds).
}
  int AMBER = 150;
  if ( AMBER >= 150)
  {
 pixels.setPixelColor(7, pixels.Color(RED,AMBER,0)); // 
 pixels.setPixelColor(6, pixels.Color(RED,AMBER,0)); // 
 pixels.setPixelColor(5, pixels.Color(RED,AMBER,0)); // 
 pixels.setPixelColor(4, pixels.Color(RED,AMBER,0)); // 
 pixels.setPixelColor(3, pixels.Color(RED,AMBER,0)); // 
 pixels.setPixelColor(2, pixels.Color(RED,AMBER,0)); // 
 pixels.setPixelColor(1, pixels.Color(RED,AMBER,0)); // 
 pixels.setPixelColor(0, pixels.Color(RED,AMBER,0)); // 
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(3000); //Stay on Amber Colour for 3 seconds.
  }
 for(int i=0; i<=255; i = i + x) //Turn Green LED brightness ON and UP. 
 {
 pixels.setPixelColor(7, pixels.Color(255-i,150+i,0)); // 
 pixels.setPixelColor(6, pixels.Color(255-i,150+i,0)); // 
 pixels.setPixelColor(5, pixels.Color(255-i,150+i,0)); // 
 pixels.setPixelColor(4, pixels.Color(255-i,150+i,0)); // 
 pixels.setPixelColor(3, pixels.Color(255-i,150+i,0)); // 
 pixels.setPixelColor(2, pixels.Color(255-i,150+i,0)); // 
 pixels.setPixelColor(1, pixels.Color(255-i,150+i,0)); // 
 pixels.setPixelColor(0, pixels.Color(255-i,150+i,0)); // 
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(10); // Time taken for the brightness to reach 255 (in milliseconds).
 }
 int GREEN = 255;
  if ( GREEN >= 255)
  {
 pixels.setPixelColor(7, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.setPixelColor(6, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.setPixelColor(5, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.setPixelColor(4, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.setPixelColor(3, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.setPixelColor(2, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.setPixelColor(1, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.setPixelColor(0, pixels.Color(0,GREEN,0)); // GREEN Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(3000); // Stay on Green Colour for 3 seconds.
 }
}

As you can see I have tried an approach similar to thispixels.Color(255-i,i,0)

What the LED’s seem to do is 1)slowly light up to RED
2)hold for 3 seconds
3)slowly light up the Green LED’s value whilst holding the Red LEDS value to make amber
4)Hold for 3 seconds
5)Then it seems to increase Greens value, blink at REDS highest value, then increase the greens LED value again (which I don’t want.)

Can anyone see the problem written in the programming?

Are you being paid by the LOC, or do you just like typing the same thing over and over?

I'm still fairly new to Arduino.

Doesn't prevent you from reading all responses, like #2...

Another option is something like this:

int up, down;
for (up=0, down = 100; up<100; up++, down--)
{
//stuff
}

What the LED's seem to do is 1)slowly light up to RED
2)hold for 3 seconds
3)slowly light up the Green LED's value whilst holding the Red LEDS value to make amber
4)Hold for 3 seconds
5)Then it seems to increase Greens value, blink at REDS highest value, then increase the greens LED value again (which I don't want.)

Can anyone see the problem written in the programming?

There is ONE problem, this thread started as "using two for statements at once?".

A meek suggestion to your coding style - revisit "for" construct instead of using "cut and paste".
Maybe than you can answer the original question yourself.

BTW - "it seems" is vague - it either does or does not - use Serial to verify that.

Solved it!!! :fearful:

//pixels.setPixelColor(7, pixels.Color(255,0,0)); // RED color.
//pixels.setPixelColor(7, pixels.Color(255,150,0)); // AMBER color.
//pixels.setPixelColor(7, pixels.Color(0,255,0)); // GREEN color.

#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            12

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      8

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int GREEN = 0;

void setup() {

  pixels.begin(); // This initializes the NeoPixel library.
  pixels.setBrightness(255);

}

void loop() {

int y = 0.9;
int x = 1;

for (int RED=0; RED<255; RED = RED + x){

 pixels.setPixelColor(7, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(RED,0,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(5); // Time taken for the brightness to reach 255 (in milliseconds).
  }
 int RED = 255;
 if (RED == 255)
 {  
 pixels.setPixelColor(7, pixels.Color(255,0,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(255,0,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(255,0,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(255,0,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(255,0,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(255,0,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(255,0,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(255,0,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(3000); // Time taken for the brightness to reach 255 (in milliseconds).
 }
 for (int AMBER=0; AMBER<75; AMBER = AMBER + x){

 pixels.setPixelColor(7, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(RED,AMBER,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(5); // Time taken for the brightness to reach 255 (in milliseconds).
  }
 int AMBER = 75;
 if (AMBER == 75)
 {  
 pixels.setPixelColor(7, pixels.Color(255,75,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(255,75,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(255,75,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(255,75,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(255,75,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(255,75,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(255,75,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(255,75,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(3000); // Time taken for the brightness to reach 255 (in milliseconds).
 }
 
  for (int AMBER=75, RED2=255; AMBER<255, RED2>0; AMBER = AMBER + 1, RED2 = RED2 - 1.416){

 pixels.setPixelColor(7, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(RED2,AMBER,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(5); // Time taken for the brightness to reach 255 (in milliseconds).
  }
 int REDLIGHTOFF = 0;
 int GREEN = 180;
 if (GREEN == 180)
 if (REDLIGHTOFF == 0)
 {  
 pixels.setPixelColor(7, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.setPixelColor(6, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.setPixelColor(5, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.setPixelColor(4, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.setPixelColor(3, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.setPixelColor(2, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.setPixelColor(1, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.setPixelColor(0, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
 pixels.show(); // This sends the updated pixel color to the hardware.
 delay(3000); // Time taken for the brightness to reach 255 (in milliseconds).
 }
}

Moderator edit: language

int y = 0.9;

Hmmm

What is it you don't understand about integers?

Really - since when this forum cares about language?
Apparently it does not apply to frequent visitors.
How hypocritical can you get?

And since this forum is NOT the place to learn decent coding practices,
I’ll refrain from further comments on the “final working code”.
Kindly allow me to say this :" you can lead a horse to water, but you cannot make it drink".

LorenzoPDE:
Solved it!!! :fearful:

//pixels.setPixelColor(7, pixels.Color(255,0,0)); // RED color.

//pixels.setPixelColor(7, pixels.Color(255,150,0)); // AMBER color.
//pixels.setPixelColor(7, pixels.Color(0,255,0)); // GREEN color.

#include <Adafruit_NeoPixel.h>
#ifdef AVR
#include <avr/power.h>
#endif

// Which pin on the Arduino is connected to the NeoPixels?
#define PIN            12

// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS      8

// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter–see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int GREEN = 0;

void setup() {

pixels.begin(); // This initializes the NeoPixel library.
 pixels.setBrightness(255);

}

void loop() {

int y = 0.9;
int x = 1;

for (int RED=0; RED<255; RED = RED + x){

pixels.setPixelColor(7, pixels.Color(RED,0,0)); // Amberr Colour
pixels.setPixelColor(6, pixels.Color(RED,0,0)); // Amberr Colour
pixels.setPixelColor(5, pixels.Color(RED,0,0)); // Amberr Colour
pixels.setPixelColor(4, pixels.Color(RED,0,0)); // Amberr Colour
pixels.setPixelColor(3, pixels.Color(RED,0,0)); // Amberr Colour
pixels.setPixelColor(2, pixels.Color(RED,0,0)); // Amberr Colour
pixels.setPixelColor(1, pixels.Color(RED,0,0)); // Amberr Colour
pixels.setPixelColor(0, pixels.Color(RED,0,0)); // Amberr Colour
pixels.show(); // This sends the updated pixel color to the hardware.
delay(5); // Time taken for the brightness to reach 255 (in milliseconds).
 }
int RED = 255;
if (RED == 255)
{  
pixels.setPixelColor(7, pixels.Color(255,0,0)); // Amberr Colour
pixels.setPixelColor(6, pixels.Color(255,0,0)); // Amberr Colour
pixels.setPixelColor(5, pixels.Color(255,0,0)); // Amberr Colour
pixels.setPixelColor(4, pixels.Color(255,0,0)); // Amberr Colour
pixels.setPixelColor(3, pixels.Color(255,0,0)); // Amberr Colour
pixels.setPixelColor(2, pixels.Color(255,0,0)); // Amberr Colour
pixels.setPixelColor(1, pixels.Color(255,0,0)); // Amberr Colour
pixels.setPixelColor(0, pixels.Color(255,0,0)); // Amberr Colour
pixels.show(); // This sends the updated pixel color to the hardware.
delay(3000); // Time taken for the brightness to reach 255 (in milliseconds).
}
for (int AMBER=0; AMBER<75; AMBER = AMBER + x){

pixels.setPixelColor(7, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.setPixelColor(6, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.setPixelColor(5, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.setPixelColor(4, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.setPixelColor(3, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.setPixelColor(2, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.setPixelColor(1, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.setPixelColor(0, pixels.Color(RED,AMBER,0)); // Amberr Colour
pixels.show(); // This sends the updated pixel color to the hardware.
delay(5); // Time taken for the brightness to reach 255 (in milliseconds).
 }
int AMBER = 75;
if (AMBER == 75)
{  
pixels.setPixelColor(7, pixels.Color(255,75,0)); // Amberr Colour
pixels.setPixelColor(6, pixels.Color(255,75,0)); // Amberr Colour
pixels.setPixelColor(5, pixels.Color(255,75,0)); // Amberr Colour
pixels.setPixelColor(4, pixels.Color(255,75,0)); // Amberr Colour
pixels.setPixelColor(3, pixels.Color(255,75,0)); // Amberr Colour
pixels.setPixelColor(2, pixels.Color(255,75,0)); // Amberr Colour
pixels.setPixelColor(1, pixels.Color(255,75,0)); // Amberr Colour
pixels.setPixelColor(0, pixels.Color(255,75,0)); // Amberr Colour
pixels.show(); // This sends the updated pixel color to the hardware.
delay(3000); // Time taken for the brightness to reach 255 (in milliseconds).
}

for (int AMBER=75, RED2=255; AMBER<255, RED2>0; AMBER = AMBER + 1, RED2 = RED2 - 1.416){

pixels.setPixelColor(7, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.setPixelColor(6, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.setPixelColor(5, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.setPixelColor(4, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.setPixelColor(3, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.setPixelColor(2, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.setPixelColor(1, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.setPixelColor(0, pixels.Color(RED2,AMBER,0)); // Amberr Colour
pixels.show(); // This sends the updated pixel color to the hardware.
delay(5); // Time taken for the brightness to reach 255 (in milliseconds).
 }
int REDLIGHTOFF = 0;
int GREEN = 180;
if (GREEN == 180)
if (REDLIGHTOFF == 0)
{  
pixels.setPixelColor(7, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.setPixelColor(6, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.setPixelColor(5, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.setPixelColor(4, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.setPixelColor(3, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.setPixelColor(2, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.setPixelColor(1, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.setPixelColor(0, pixels.Color(REDLIGHTOFF,GREEN,0)); // Amberr Colour
pixels.show(); // This sends the updated pixel color to the hardware.
delay(3000); // Time taken for the brightness to reach 255 (in milliseconds).
}
}




Moderator edit: language

Really - since when this forum cares about language?

We're an open forum, with young members.

sp. " since when does this forum care about language?"

I'll refrain from further comments on the "final working code".

Ah! If that were the only thing you refrained from, Vaclav.

Sorry to aggravate everyone with my programming, it was not my intent. I will say thank you however for helping me out!