Go Down

Topic: Running Loop once and leaving LED lit until button released (Read 2927 times) previous topic - next topic

Grumpy_Mike

Can you explain why you need both center4 and b? Seems like center4 should already call out those numbers?
The variable center4 is an array, in C you need to access each element one at a time by using a sutiable index given in the square braces.

If you just used b then you would turn on just LEDs 0 to 3. As center4 is an array then the first element of that array returns 36. So center4[0] returns 36, that is the number of LED you want to turn on. The variable b is called the loop index that goes from zero to less than four which is 3.

Quote
Also what does b++ mean?
The operation ++ adds one to the variable it is placed next to. So b++ means what ever the value of b was, add one to it.



midwesta

So here is a shorter version that works except:

The brake code is looping - I want button three to do the code once and stay bright until I release.

The blinkers are working good - EXCEPT I would like the non blinking light to stay at the 10 brightness (DIM)

Code: [Select]


#include "FastLED.h"

// fast led constants
#define DATA_PIN    3        // change to your data pin
#define COLOR_ORDER GRB      // if colors are mismatched; change this
#define NUM_LEDS    256          // change to the number of LEDs in your strip
#define FRAMES_PER_SECOND  120
#define LED_TYPE    WS2812B
#define BRIGHTNESS          200
#define DIM         10

// constant variables
const int buttonPin1 = 5;     // the number of the pushbutton pin
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 10;

// variables will change:
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int oldButtonState3 = 0;

// this creates an LED array to hold the values for each led in your strip
CRGB leds[NUM_LEDS];

void setup()
{
    delay(3000); // 3 second delay for recovery
  
  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  //FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  // the wiki features a much more basic setup line:
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

Serial.begin(9600);

// initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT);
  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);
}

 void loop()
{  
      FastLED.setBrightness(DIM);
      
// Set the right tail light to black for 1 second
      for (int i = 0; i <= 63; i++)
              leds[i] = CRGB::Red;

// Set the left tail light to black for 1 second
      for (int j = 192; j <= 255; j++)
             leds[j] = CRGB::Red;
              FastLED.show();
  
// read the state of the pushbutton value:
    buttonState1 = digitalRead(buttonPin1);
    buttonState2 = digitalRead(buttonPin2);
    buttonState3 = digitalRead(buttonPin3);
    buttonState4 = digitalRead(buttonPin4);
  




 // check if the pushbutton is pressed.
 // if it is, the buttonState is HIGH:
          if (buttonState1 == HIGH) {


//LEFT TURN SIGNAL



// left tail light black
        for (int j = 192; j <= 255; j++)
              leds[j] = CRGB::Black;


        FastLED.setBrightness(BRIGHTNESS);
// Turn the first led red

        for (int a = 192; a <= 220; a++)
        leds[a] = CRGB::Red;
        FastLED.show();
        delay(100);
      
// Set the first led back to black
        for (int a = 192; a <= 220; a++)
        leds[a] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[207] = CRGB::Red;
       leds[209] = CRGB::Red;
       leds[221] = CRGB::Red;
       leds[227] = CRGB::Red;
       leds[228] = CRGB::Red;
       leds[218] = CRGB::Red;
       leds[214] = CRGB::Red;
       leds[200] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
      leds[207] = CRGB::Black;
      leds[209] = CRGB::Black;
      leds[221] = CRGB::Black;
      leds[227] = CRGB::Black;
      leds[228] = CRGB::Black;
      leds[218] = CRGB::Black;
      leds[214] = CRGB::Black;
      leds[200] = CRGB::Black;
      FastLED.show();
      delay(30);

// Turn the first led red for 1 second
       leds[208] = CRGB::Red;
       leds[222] = CRGB::Red;
       leds[226] = CRGB::Red;
       leds[236] = CRGB::Red;
       leds[235] = CRGB::Red;
       leds[229] = CRGB::Red;
       leds[217] = CRGB::Red;
       leds[215] = CRGB::Red;
       FastLED.show();
        delay(100);
      
// Set the first led back to black for 1 second
      leds[208] = CRGB::Black;
      leds[222] = CRGB::Black;
      leds[226] = CRGB::Black;
      leds[236] = CRGB::Black;
      leds[235] = CRGB::Black;
      leds[229] = CRGB::Black;
      leds[217] = CRGB::Black;
      leds[215] = CRGB::Black;
      FastLED.show();
      delay(30);

// Turn the first led red for 1 second
       leds[223] = CRGB::Red;
       leds[225] = CRGB::Red;
       leds[237] = CRGB::Red;
       leds[243] = CRGB::Red;
       leds[244] = CRGB::Red;
       leds[234] = CRGB::Red;
       leds[230] = CRGB::Red;
       leds[216] = CRGB::Red;
        FastLED.show();
        delay(100);
      
// Set the first led back to black for 1 second
      leds[223] = CRGB::Black;
      leds[225] = CRGB::Black;
      leds[237] = CRGB::Black;
      leds[243] = CRGB::Black;
      leds[244] = CRGB::Black;
      leds[234] = CRGB::Black;
      leds[230] = CRGB::Black;
      leds[216] = CRGB::Black;
      FastLED.show();
      delay(30);

// Turn the first led red for 1 second
       leds[224] = CRGB::Red;
       leds[238] = CRGB::Red;
       leds[242] = CRGB::Red;
       leds[252] = CRGB::Red;
       leds[251] = CRGB::Red;
       leds[245] = CRGB::Red;
       leds[233] = CRGB::Red;
       leds[231] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
      leds[224] = CRGB::Black;
      leds[238] = CRGB::Black;
      leds[242] = CRGB::Black;
      leds[252] = CRGB::Black;
      leds[251] = CRGB::Black;
      leds[245] = CRGB::Black;
      leds[233] = CRGB::Black;
      leds[231] = CRGB::Black;
      FastLED.show();
      delay(30);

      


  }

 


midwesta

Second half of the code:

Code: [Select]
// RIGHT TURN SIGNAL

if (buttonState2 == HIGH) {

FastLED.setBrightness(BRIGHTNESS);
  
// Set the first led back to black for 1 second
        for (int i = 0; i <= 63; i++)
            leds[i] = CRGB::Black;

// Turn the first led red for 1 second
       leds[56] = CRGB::Red;
       leds[57] = CRGB::Red;
       leds[58] = CRGB::Red;
       leds[59] = CRGB::Red;
       leds[60] = CRGB::Red;
       leds[61] = CRGB::Red;
       leds[62] = CRGB::Red;
       leds[63] = CRGB::Red;
       leds[49] = CRGB::Red;
       leds[50] = CRGB::Red;
       leds[51] = CRGB::Red;
       leds[52] = CRGB::Red;
       leds[53] = CRGB::Red;
       leds[54] = CRGB::Red;
       leds[42] = CRGB::Red;
       leds[43] = CRGB::Red;
       leds[44] = CRGB::Red;
       leds[45] = CRGB::Red;
       leds[35] = CRGB::Red;
       leds[36] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
       leds[56] = CRGB::Black;
       leds[57] = CRGB::Black;
       leds[58] = CRGB::Black;
       leds[59] = CRGB::Black;
       leds[60] = CRGB::Black;
       leds[61] = CRGB::Black;
       leds[62] = CRGB::Black;
       leds[63] = CRGB::Black;
       leds[49] = CRGB::Black;
       leds[50] = CRGB::Black;
       leds[51] = CRGB::Black;
       leds[52] = CRGB::Black;
       leds[53] = CRGB::Black;
       leds[54] = CRGB::Black;
       leds[42] = CRGB::Black;
       leds[43] = CRGB::Black;
       leds[44] = CRGB::Black;
       leds[45] = CRGB::Black;
       leds[35] = CRGB::Black;
       leds[36] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[48] = CRGB::Red;
       leds[55] = CRGB::Red;
       leds[46] = CRGB::Red;
       leds[41] = CRGB::Red;
       leds[37] = CRGB::Red;
       leds[34] = CRGB::Red;
       leds[28] = CRGB::Red;
       leds[27] = CRGB::Red;
       FastLED.show();
        delay(100);
      
// Set the first led back to black for 1 second
       leds[48] = CRGB::Black;
       leds[55] = CRGB::Black;
       leds[46] = CRGB::Black;
       leds[41] = CRGB::Black;
       leds[37] = CRGB::Black;
       leds[34] = CRGB::Black;
       leds[28] = CRGB::Black;
       leds[27] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[47] = CRGB::Red;
       leds[40] = CRGB::Red;
       leds[33] = CRGB::Red;
       leds[38] = CRGB::Red;
       leds[26] = CRGB::Red;
       leds[29] = CRGB::Red;
       leds[19] = CRGB::Red;
       leds[20] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
       leds[47] = CRGB::Black;
       leds[40] = CRGB::Black;
       leds[33] = CRGB::Black;
       leds[38] = CRGB::Black;
       leds[26] = CRGB::Black;
       leds[29] = CRGB::Black;
       leds[19] = CRGB::Black;
       leds[20] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[39] = CRGB::Red;
       leds[32] = CRGB::Red;
       leds[25] = CRGB::Red;
       leds[30] = CRGB::Red;
       leds[21] = CRGB::Red;
       leds[18] = CRGB::Red;
       leds[12] = CRGB::Red;
       leds[11] = CRGB::Red;
             FastLED.show();
      delay(100);
      
 // Set the first led back to black for 1 second
      leds[39] = CRGB::Black;
       leds[32] = CRGB::Black;
       leds[25] = CRGB::Black;
       leds[30] = CRGB::Black;
       leds[21] = CRGB::Black;
       leds[18] = CRGB::Black;
       leds[12] = CRGB::Black;
       leds[11] = CRGB::Black;
        FastLED.show();
        delay(30);

// Turn the first led red for 1 second
       leds[31] = CRGB::Red;
       leds[24] = CRGB::Red;
       leds[22] = CRGB::Red;
       leds[17] = CRGB::Red;
       leds[13] = CRGB::Red;
       leds[10] = CRGB::Red;
       leds[4] = CRGB::Red;
       leds[3] = CRGB::Red;
       FastLED.show();
       delay(100);
      
// Set the first led back to black for 1 second
      leds[31] = CRGB::Black;
      leds[24] = CRGB::Black;
      leds[22] = CRGB::Black;
      leds[17] = CRGB::Black;
      leds[13] = CRGB::Black;
      leds[10] = CRGB::Black;
      leds[4] = CRGB::Black;
      leds[3] = CRGB::Black;
      FastLED.show();
      delay(30);

  }

 

midwesta

Needed a third :(

Code: [Select]

//BRAKE LIGHT
       FastLED.setBrightness(BRIGHTNESS);
      if(buttonState3 == HIGH){
// Set the right tail light black
        for (int i = 0; i <= 63; i++)
              leds[i] = CRGB::Black;
              
// left tail light black
        for (int j = 192; j <= 255; j++)
            leds[j] = CRGB::Black;
              FastLED.show();
              delay(200);

// Turn the first led red for 1 second   leds[i] %= 192;
       leds[36]  = CRGB::Red;
       leds[35] = CRGB::Red;
       leds[28] = CRGB::Red;
       leds[27] = CRGB::Red;

// left brake light
       leds[227] = CRGB::Red;
       leds[228] = CRGB::Red;
       leds[219] = CRGB::Red;
       leds[220] = CRGB::Red;
        FastLED.show();
        delay(200);
        
// Turn the first led red for 1 second
       leds[42] = CRGB::Red;
       leds[43] = CRGB::Red;
       leds[44] = CRGB::Red;
       leds[45] = CRGB::Red;
       leds[37] = CRGB::Red;
       leds[29] = CRGB::Red;
       leds[21] = CRGB::Red;
       leds[20] = CRGB::Red;
       leds[19] = CRGB::Red;
       leds[18] = CRGB::Red;
       leds[26] = CRGB::Red;
       leds[34] = CRGB::Red;

// left brake light
       leds[234] = CRGB::Red;
       leds[235] = CRGB::Red;
       leds[236] = CRGB::Red;
       leds[237] = CRGB::Red;
       leds[226] = CRGB::Red;
       leds[221] = CRGB::Red;
       leds[210] = CRGB::Red;
       leds[211] = CRGB::Red;
       leds[212] = CRGB::Red;
       leds[213] = CRGB::Red;
       leds[218] = CRGB::Red;
       leds[229] = CRGB::Red;
        FastLED.show();
        delay(200);
      
// Turn the first led red for 1 second
       leds[49] = CRGB::Red;
       leds[50] = CRGB::Red;
       leds[51] = CRGB::Red;
       leds[52] = CRGB::Red;
       leds[53] = CRGB::Red;
       leds[46] = CRGB::Red;
       leds[38] = CRGB::Red;
       leds[30] = CRGB::Red;
       leds[22] = CRGB::Red;
       leds[14] = CRGB::Red;
       leds[13] = CRGB::Red;
       leds[12] = CRGB::Red;
       leds[11] = CRGB::Red;
       leds[10] = CRGB::Red;
       leds[9] = CRGB::Red;
       leds[17] = CRGB::Red;
       leds[25] = CRGB::Red;
       leds[33] = CRGB::Red;
       leds[41] = CRGB::Red;
       leds[54] = CRGB::Red;

// left brake light
       leds[241] = CRGB::Red;
       leds[242] = CRGB::Red;
       leds[243] = CRGB::Red;
       leds[244] = CRGB::Red;
       leds[245] = CRGB::Red;
       leds[246] = CRGB::Red;
       leds[233] = CRGB::Red;
       leds[230] = CRGB::Red;
       leds[217] = CRGB::Red;
       leds[214] = CRGB::Red;
       leds[201] = CRGB::Red;
       leds[202] = CRGB::Red;
       leds[203] = CRGB::Red;
       leds[204] = CRGB::Red;
       leds[205] = CRGB::Red;
       leds[206] = CRGB::Red;
       leds[209] = CRGB::Red;
       leds[222] = CRGB::Red;
       leds[225] = CRGB::Red;
       leds[238] = CRGB::Red;  
        FastLED.show();
         delay(200);
      
// Turn the first led red for 1 second
       leds[63] = CRGB::Red;
       leds[62] = CRGB::Red;
       leds[61] = CRGB::Red;
       leds[60] = CRGB::Red;
       leds[59] = CRGB::Red;
       leds[58] = CRGB::Red;
       leds[57] = CRGB::Red;
       leds[56] = CRGB::Red;
       leds[55] = CRGB::Red;
       leds[47] = CRGB::Red;
       leds[39] = CRGB::Red;
       leds[31] = CRGB::Red;
       leds[23] = CRGB::Red;
       leds[15] = CRGB::Red;
       leds[7] = CRGB::Red;
       leds[6] = CRGB::Red;
       leds[5] = CRGB::Red;
       leds[4] = CRGB::Red;
       leds[3] = CRGB::Red;
       leds[2] = CRGB::Red;
       leds[1] = CRGB::Red;
       leds[8] = CRGB::Red;
       leds[16] = CRGB::Red;
       leds[24] = CRGB::Red;
       leds[32] = CRGB::Red;
       leds[40] = CRGB::Red;
       leds[48] = CRGB::Red;
       leds[0] = CRGB::Red;
      
// left brake light
       leds[255] = CRGB::Red;
       leds[254] = CRGB::Red;
       leds[253] = CRGB::Red;
       leds[252] = CRGB::Red;
       leds[251] = CRGB::Red;
       leds[250] = CRGB::Red;
       leds[249] = CRGB::Red;
       leds[248] = CRGB::Red;
       leds[247] = CRGB::Red;
       leds[232] = CRGB::Red;
       leds[231] = CRGB::Red;
       leds[216] = CRGB::Red;
       leds[215] = CRGB::Red;
       leds[200] = CRGB::Red;
       leds[199] = CRGB::Red;
       leds[198] = CRGB::Red;
       leds[197] = CRGB::Red;
       leds[196] = CRGB::Red;
       leds[195] = CRGB::Red;
       leds[194] = CRGB::Red;
       leds[193] = CRGB::Red;
       leds[192] = CRGB::Red;
       leds[207] = CRGB::Red;
       leds[208] = CRGB::Red;
       leds[223] = CRGB::Red;
       leds[224] = CRGB::Red;
       leds[239] = CRGB::Red;
       leds[240] = CRGB::Red;
        FastLED.show();
        delay(30);

  
        oldButtonState3 = HIGH; // so this block can only run once

}

// "stop braking" code here
// turn LED off:
          if(buttonState3 == LOW) {
        delay(30);
      
          oldButtonState3 == LOW;
          FastLED.setBrightness(BRIGHTNESS);

  }
 

}    

Grumpy_Mike

This is heavy going.

The reply #15 was to show you how to light LEDs in a loop where the LED number do not follow each other but are in an arbitrary sequence. I gave you one short example. I expected you to apply that technique to all the rest of the turged code you had, so you did not need three posts to get your code over.

INTP

Code: [Select]
// Set the left tail light to black for 1 second
      for (int j = 192; j <= 255; j++)
             leds[j] = CRGB::Red;
              FastLED.show();

midwesta

Better but still away to go.
When you have a load of LEDs that do not have consecutive numbers you use an other array as a list or look up table of these array numbers. So for example when you want to turn on the center four lights you first define the array that contains the numbers and then use the array contents as the LED array you want to change.

Code: [Select]

// outside of a function define:-
byte center4 = {36,35,28,27};

// then inside a function use
for (int b = 0; b<4; b++;) {
 leds[center4[b]] = CRGB::RED;
}

That will help a lot the longer the list goes on.
Can you double check your coding here - because it is not working.

INTP

byte center4 []= {36,35,28,27};


just forgot the []

which you should've picked up on if you read up on arrays once they were mentioned. Maybe you're unaware there's a reference section.

midwesta

how do i declare b in the scope? I figured out the brackets but can't figure out how to declare b


INTP

And this, since you'll ask about it without trying to find it yourself.

Grumpy_Mike

how do i declare b in the scope? I figured out the brackets but can't figure out how to declare b
Looks like you typed in the code wrong for that bit. It is delclaired inside the if statement and is in scope between the {.   } of the if.

midwesta

Figured it out - you had an extra ) and ; i think.

Here is my code thats around 22% memory and not 56+% memory like before.


So how do I get the brightness to stay dim on the non directional light and for the brake code to stop looping?




Code: [Select]
#include "FastLED.h"

// fast led constants
#define DATA_PIN    3        // change to your data pin
#define COLOR_ORDER GRB      // if colors are mismatched; change this
#define NUM_LEDS    256          // change to the number of LEDs in your strip
#define FRAMES_PER_SECOND  120
#define LED_TYPE    WS2812B
#define BRIGHTNESS          200
#define DIM         10


// constant variables
const int buttonPin1 = 5;     // the number of the pushbutton pin
const int buttonPin2 = 6;
const int buttonPin3 = 7;
const int buttonPin4 = 10;



// variables will change:
int buttonState1 = 0;         // variable for reading the pushbutton status
int buttonState2 = 0;
int buttonState3 = 0;
int buttonState4 = 0;
int oldButtonState3 = 0;

// this creates an LED array to hold the values for each led in your strip
CRGB leds[NUM_LEDS];

void setup()
{
    delay(3000); // 3 second delay for recovery

  // tell FastLED about the LED strip configuration
  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds,NUM_LEDS).setCorrection(TypicalLEDStrip);


  // the wiki features a much more basic setup line:
  FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);

Serial.begin(9600);

// initialize the pushbutton pin as an input:
  pinMode(buttonPin1, INPUT);
  // set master brightness control
  FastLED.setBrightness(BRIGHTNESS);


}

 void loop()



{
      FastLED.setBrightness(DIM);

// Set the right tail light to black for 1 second
      for (int i = 0; i <= 63; i++)
              leds[i] = CRGB::Red;

// Set the left tail light to black for 1 second
      for (int j = 192; j <= 255; j++)
             leds[j] = CRGB::Red;
              FastLED.show();

// read the state of the pushbutton value:
    buttonState1 = digitalRead(buttonPin1);
    buttonState2 = digitalRead(buttonPin2);
    buttonState3 = digitalRead(buttonPin3);
    buttonState4 = digitalRead(buttonPin4);





 // check if the pushbutton is pressed.
 // if it is, the buttonState is HIGH:
          if (buttonState1 == HIGH) {


//LEFT TURN SIGNAL



// left tail light black
        for (int f = 192; f <= 255; f++)
              leds[f] = CRGB::Black;


        FastLED.setBrightness(BRIGHTNESS);


// Set the first led back to black
        for (int a = 192; a <= 220; a++)
        leds[a] = CRGB::Black;
        FastLED.show();
        delay(30);


// FIRST ARROW RED

byte firstArrow20[] = {192,193,194,195,196,197,198,199,201,202,203,204,205,206,210,211,212,213,219,220};

for (int g = 0; g<20; g++) {
 leds[firstArrow20[g]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// FIRST ARROW BLACK

for (int g = 0; g<20; g++) {
 leds[firstArrow20[g]] = CRGB::Black;
}
FastLED.show();
 delay (30);



// SECOND ARROW RED

byte secondArrow8[] = {207,209,221,227,228,218,214,200};

for (int h = 0; h<8; h++) {
 leds[secondArrow8[h]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// SECOND ARROW BLACK

for (int h = 0; h<8; h++) {
 leds[secondArrow8[h]] = CRGB::Black;
}
FastLED.show();
 delay (30);


// THIRD ARROW RED

byte thirdArrow8[] = {208,222,226,236,235,229,217,215};

for (int k = 0; k<8; k++) {
 leds[thirdArrow8[k]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// THIRD ARROW BLACK

for (int k = 0; k<8; k++) {
 leds[thirdArrow8[k]] = CRGB::Black;
}
FastLED.show();
 delay (30);



 // FOURTH ARROW RED

byte fourthArrow8[] = {223,225,237,243,244,234,230,216};

for (int l = 0; l<8; l++) {
 leds[fourthArrow8[l]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// FOURTH ARROW BLACK

for (int l = 0; l<8; l++) {
 leds[fourthArrow8[l]] = CRGB::Black;
}
FastLED.show();
 delay (30);

 

 // FIFTH ARROW RED

byte fifthArrow8[] = {224,238,242,252,251,245,233,231};

for (int m = 0; m<8; m++) {
 leds[fifthArrow8[m]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// FIFTH ARROW BLACK

for (int m = 0; m<8; m++) {
 leds[fifthArrow8[m]] = CRGB::Black;
}
FastLED.show();
 delay (30);


  }

// RIGHT TURN SIGNAL

if (buttonState2 == HIGH) {

FastLED.setBrightness(BRIGHTNESS);

// Set the first led back to black for 1 second
        for (int i = 0; i <= 63; i++)
            leds[i] = CRGB::Black;

FastLED.show();
        delay(30);


// SIXTH ARROW RED

byte sixthArrow20[] = {56,57,58,59,60,61,62,63,49,50,51,52,53,54,42,43,44,45,35,36};

for (int n = 0; n<20; n++) {
 leds[sixthArrow20[n]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// SIXTH ARROW BLACK

for (int n = 0; n<20; n++) {
 leds[sixthArrow20[n]] = CRGB::Black;
}
FastLED.show();
 delay (30);



// SEVENTH ARROW RED

byte seventhArrow8[] = {48,55,46,41,37,34,28,27};

for (int o = 0; o<8; o++) {
 leds[seventhArrow8[o]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// SEVENTH ARROW BLACK

for (int o = 0; o<8; o++) {
 leds[seventhArrow8[o]] = CRGB::Black;
}
FastLED.show();
 delay (30);


// EIGTH ARROW RED

byte eigthArrow8[] = {47,40,33,38,26,29,19,20};

for (int p = 0; p<8; p++) {
 leds[eigthArrow8[p]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// EIGHT ARROW BLACK

for (int p = 0; p<8; p++) {
 leds[eigthArrow8[p]] = CRGB::Black;
}
FastLED.show();
 delay (30);



 // NINTH ARROW RED

byte ninthArrow8[] = {39,32,25,30,21,18,12,11};

for (int q = 0; q<8; q++) {
 leds[ninthArrow8[q]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// NINTH ARROW BLACK

for (int q = 0; q<8; q++) {
 leds[ninthArrow8[q]] = CRGB::Black;
}
FastLED.show();
 delay (30);

 

 // TENTH ARROW RED

byte tenthArrow8[] = {31,24,22,17,13,10,4,3};

for (int r = 0; r<8; r++) {
 leds[tenthArrow8[r]] = CRGB::Red;
}
FastLED.show();
 delay (100);

// TENTH ARROW BLACK

for (int r = 0; r<8; r++) {
 leds[tenthArrow8[r]] = CRGB::Black;
}
FastLED.show();
 delay (30);

  }

//BRAKE LIGHT
       FastLED.setBrightness(BRIGHTNESS);
      if(buttonState3 == HIGH){
// Set the right tail light black
        for (int i = 0; i <= 63; i++)
              leds[i] = CRGB::Black;

// left tail light black
        for (int j = 192; j <= 255; j++)
            leds[j] = CRGB::Black;
              FastLED.show();
              delay(200);

//CENTER 4
byte center4[] = {36,35,28,27,227,228,219,220};

for (int b = 0; b<8; b++) {
 leds[center4[b]] = CRGB::Red;
}
FastLED.show();
delay(200);

// FIRST RING
byte firstRing12[] = {42,43,44,45,37,29,21,20,19,18,26,34,234,235,236,237,226,221,210,211,212,213,218,229};

for (int c = 0; c<24; c++) {
 leds[firstRing12[c]] = CRGB::Red;
}
FastLED.show();
delay(200);


// SECOND RING
byte secondRing20[] = {49,50,51,52,53,46,38,30,22,14,13,12,11,10,9,17,25,33,41,54,241,242,243,244,245,246,233,230,217,214,201,202,203,204,205,206,209,222,225,238};

for (int d = 0; d<40; d++) {
 leds[secondRing20[d]] = CRGB::Red;
}FastLED.show();
 delay (200);


// THIRD RING
byte thirdRing28[] = {63,62,61,60,59,58,57,56,55,47,39,31,23,15,7,6,5,4,3,2,1,0,8,16,24,32,40,48,255,254,253,252,251,250,249,248,247,232,231,216,
215,200,199,198,197,196,195,194,193,192,207,208,223,224,239,240};

for (int e = 0; e<56; e++) {
 leds[thirdRing28[e]] = CRGB::Red;
}
FastLED.show();
 delay (200);



oldButtonState3 = HIGH; // so this block can only run once

}

// "stop braking" code here
// turn LED off:
if(buttonState3 == LOW) {

          oldButtonState3 == LOW;
          FastLED.setBrightness(BRIGHTNESS);

  }


}

INTP

Black is 0,0,0. You'll have to write crgb to whatever you think works for 'dim'. E.g. 80,0,0 for dim red.

midwesta

Black is 0,0,0. You'll have to write crgb to whatever you think works for 'dim'. E.g. 80,0,0 for dim red.
Is that to make the brake light stop looping? Because I am not calling black for the left and right non blinker sections.

Go Up