0

Colorwipe no delay
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: Colorwipe no delay

by Joe36 on Fri Apr 05, 2019 10:29 pm

That's exactly what I was looking for, Thank you so much.

Joe36
 
Posts: 43
Joined: Tue Dec 27, 2016 10:36 am

Re: Colorwipe no delay

by Joe36 on Fri Apr 05, 2019 10:38 pm

Send me a PM if you can. I cant seem to send one.

Joe36
 
Posts: 43
Joined: Tue Dec 27, 2016 10:36 am

Re: Colorwipe no delay

by kcl1s on Sat Apr 06, 2019 9:14 am

Glad you are happy with the code.

Keith
lohmeyer.keith@gmail.com

kcl1s
 
Posts: 1289
Joined: Tue Aug 30, 2016 12:06 pm

Re: Colorwipe no delay

by Joe36 on Tue Oct 01, 2019 3:00 pm

Keith,
I have been using this code for most of the summer now. I ended up making a shorter strip than the original 144 and I am now down to 28 and using that as a multi function rear lamp on a golf cart. I would like to add front turn signals and run them off the same arduino but I cannot get the arduino to light up multiple strings. I have a bench test setup and I know the strips all function because I can switch the pin numbers and get the other strings to light. am I missing something here? I am calling out the new front strips separately and I called them in the setup to begin and show but I still get nothing. I have attached the latest code.

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>
#define LTURN         10
#define RTURN          9
#define STOP          11
#define RUNNING_LIGHT 12
#define HAZARD         4
#define AUX            7
#define REVERSE        8
#define LENGTHREAR    28
#define LENGTHFRONT   12


Adafruit_NeoPixel strip = Adafruit_NeoPixel(LENGTHREAR, 6, NEO_GRB + NEO_KHZ800); // Blue Wire Pin 3 on the 4 pin Rear Connector 
Adafruit_NeoPixel lfstrip = Adafruit_NeoPixel(LENGTHFRONT, 5, NEO_GRB + NEO_KHZ800); // Yellow Wire Pin 3 on the 4 pin
Adafruit_NeoPixel rfstrip = Adafruit_NeoPixel(LENGTHFRONT, 3, NEO_GRB + NEO_KHZ800); // Green Wire Pin 4 on the 4 pin





const uint32_t colorBlack = strip.Color(0, 0, 0);
const uint32_t colorBlackLF = lfstrip.Color(0, 0, 0);
const uint32_t colorBlackRF = rfstrip.Color(0, 0, 0);
const uint32_t colorRunning = strip.Color(30, 0, 0);
const uint32_t colorRunningLeftFront = lfstrip.Color(30, 15, 0);
const uint32_t colorRunningRightFront = rfstrip.Color(30, 15, 0);
const uint32_t colorStop = strip.Color(255, 0, 0);
const uint32_t colorTurn = strip.Color(255, 175, 0);
const uint32_t colorReverse = strip.Color(255, 255, 170);
const uint32_t colorBlue = strip.Color(0, 0, 255);
const uint32_t colorGreen = strip.Color(0, 255, 0);
const int LTurnIn = 14;
const int RTurnIn = 14;
const int turnPixels = 14;

uint32_t backColor = colorBlack;
uint32_t backColorLeftFront = colorBlackLF;
uint32_t backColorRightFront = colorBlackRF;

byte LTurnCt = 0;
byte RTurnCt = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(LTURN,         INPUT_PULLUP);
  pinMode(RTURN,         INPUT_PULLUP);
  pinMode(STOP,          INPUT_PULLUP);
  pinMode(RUNNING_LIGHT, INPUT_PULLUP);
  pinMode(HAZARD,        INPUT_PULLUP);
  pinMode(AUX,           INPUT_PULLUP);
  pinMode(REVERSE,       INPUT_PULLUP);


 
  strip.begin();
  strip.show();
 
  lfstrip.begin();
  lfstrip.show();

  rfstrip.begin();
  rfstrip.show();
   
  Serial.begin(9600);
}
 
void loop() {
  // put your main code here, to run repeatedly:
  backColor = colorBlack;
  backColorLeftFront = colorBlackLF;
  backColorRightFront = colorBlackRF;
 
  if (digitalRead(RUNNING_LIGHT) == LOW) {
   backColor = colorRunning;
   backColorLeftFront = colorRunningLeftFront;
   backColorRightFront = colorRunningRightFront;
}
 
     
  //if (digitalRead(RUNNING_LIGHT) == LOW) backColor = colorRunning;
  if (digitalRead(STOP) == LOW) backColor = colorStop;
  if (digitalRead(REVERSE) == LOW) backColor = colorReverse;
  if (digitalRead(LTURN) == LOW && digitalRead(HAZARD) == LOW) backColor = colorBlue;
  if (digitalRead(RTURN) == LOW && digitalRead(HAZARD) == LOW) backColor = colorGreen;
   for (int i = 0; i < LENGTHREAR; i++) strip.setPixelColor(i, backColor);
       if (digitalRead(HAZARD) == LOW && ! digitalRead(LTURN)  == LOW && ! digitalRead(RTURN) == LOW) hazardOn();
  else if (digitalRead(AUX)    == LOW &&   digitalRead(STOP) ==  HIGH && ! digitalRead(LTURN)  == LOW && ! digitalRead(RTURN) == LOW) RWB();
  else if (digitalRead(LTURN) ==  LOW && ! digitalRead(HAZARD) == LOW) LSignal();
  else if (digitalRead(RTURN) ==  LOW && ! digitalRead(HAZARD) == LOW) RSignal();


  else {
    Serial.print("else ");
    RTurnCt = 0;
    LTurnCt = 0;

 
    strip.show();
    lfstrip.show();
    rfstrip.show();
  }
  delay(80);
}

void LSignal() {
  for (int i = LTurnIn; i >= (LTurnIn - LTurnCt); i--) strip.setPixelColor(i, colorTurn);
  LTurnCt++;
  if (LTurnCt > turnPixels) LTurnCt = 0;
  strip.show();
}

void RSignal() {
  for (int i = RTurnIn; i <= (RTurnIn + RTurnCt); i++) strip.setPixelColor(i, colorTurn);
  RTurnCt++;
  if (RTurnCt > turnPixels) RTurnCt = 0;
  strip.show();
}

void hazardOn() {
  for (int i = LTurnIn; i >= (LTurnIn - LTurnCt); i--) strip.setPixelColor(i, colorTurn);
  LTurnCt++;
  if (LTurnCt > turnPixels) LTurnCt = 0;
  for (int i = RTurnIn; i <= (RTurnIn + RTurnCt); i++) strip.setPixelColor(i, colorTurn);
  RTurnCt++;
  if (RTurnCt > turnPixels) RTurnCt = 0;
  strip.show();
}



void rainbow() {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
  //  delay(wait);
  }
}

  void RWB() {

    strip.setPixelColor(0, 255, 0,0);
    strip.setPixelColor(1, 255, 0,0);
    strip.setPixelColor(2, 255, 0,0);
    strip.setPixelColor(3, 255, 0,0);
    strip.setPixelColor(4, 255, 0,0);
    strip.setPixelColor(5, 255, 0,0);
    strip.setPixelColor(6, 255, 0,0);
    strip.setPixelColor(7, 255, 0,0);
    strip.setPixelColor(8, 255, 0,0);
    strip.setPixelColor(9, 255, 0,0);
    strip.setPixelColor(10, 255, 255,255);
    strip.setPixelColor(11, 255, 255,255);
    strip.setPixelColor(12, 255, 255,255);
    strip.setPixelColor(13, 255, 255,255);
    strip.setPixelColor(14, 255, 255,255);
    strip.setPixelColor(15, 255, 255,255);
    strip.setPixelColor(16, 255, 255,255);
    strip.setPixelColor(17, 255, 255,255);
    strip.setPixelColor(18, 255, 255,255);
    strip.setPixelColor(19, 0, 0,255);
    strip.setPixelColor(20, 0, 0,255);
    strip.setPixelColor(21, 0, 0,255);
    strip.setPixelColor(22, 0, 0,255);
    strip.setPixelColor(23, 0, 0,255);
    strip.setPixelColor(24, 0, 0,255);
    strip.setPixelColor(25, 0, 0,255);
    strip.setPixelColor(26, 0, 0,255);
    strip.setPixelColor(27, 0, 0,255);
    strip.show();
   }

   

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}



Joe36
 
Posts: 43
Joined: Tue Dec 27, 2016 10:36 am

Re: Colorwipe no delay

by kcl1s on Tue Oct 01, 2019 7:50 pm

Yeah. That has been a while ago and you have added to the code a bit for the rear strip. From a quick look I don't think you are ever setting pixels for the new strips. The call would be something like ...
lfstrip.setPixelColor(10, 255, 175, 0);

Keith

kcl1s
 
Posts: 1289
Joined: Tue Aug 30, 2016 12:06 pm

Re: Colorwipe no delay

by Joe36 on Sun Oct 13, 2019 8:52 am

I see where I was missing that. I have it somewhat working the way I want now. sometimes its something so simple that is easily missed.
Thank you.

Joe36
 
Posts: 43
Joined: Tue Dec 27, 2016 10:36 am

Re: Colorwipe no delay

by Joe36 on Sun Oct 13, 2019 9:48 am

I have it working now with 3 different strips of pixels on 3 different outputs. one strip for the rear and 2 separate strips for the front. Thanks again for the help. Here's the code.

Code: Select all | TOGGLE FULL SIZE
//Include and Define things Do Not change these values
//They are whats in the potted box and are now default.
//Orange/Wht is on pin 2 as a spare output.
#include <Adafruit_NeoPixel.h>
#define LTURN         10
#define RTURN          9
#define STOP          11
#define RUNNING_LIGHT 12
#define HAZARD         4
#define AUX            7
#define REVERSE        8
#define LENGTHREAR    28
#define LENGTHFRONT   12
//Define the pixel stings as outputs.

Adafruit_NeoPixel strip = Adafruit_NeoPixel(LENGTHREAR, 6, NEO_GRB + NEO_KHZ800); // Blue Wire Pin 3 on the 4 pin Rear Connector
Adafruit_NeoPixel lfstrip = Adafruit_NeoPixel(LENGTHFRONT, 5, NEO_GRB + NEO_KHZ800); // Yellow Wire Pin 3 on the 4 pin
Adafruit_NeoPixel rfstrip = Adafruit_NeoPixel(LENGTHFRONT, 3, NEO_GRB + NEO_KHZ800); // Green Wire Pin 4 on the 4 pin

const uint32_t colorBlack = strip.Color(0, 0, 0) && lfstrip.Color(0, 0, 0) && rfstrip.Color(0, 0, 0);
const uint32_t colorRunning = strip.Color(30, 0, 0);
const uint32_t colorRunningFront = strip.Color(30, 20, 0);
const uint32_t colorStop = strip.Color(255, 0, 0);
const uint32_t colorTurn = strip.Color(255, 175, 0);
const uint32_t colorReverse = strip.Color(255, 255, 170);
const uint32_t colorBlue = strip.Color(0, 0, 255);
const uint32_t colorGreen = strip.Color(0, 255, 0);
const int LTurnIn = 12;
const int RTurnIn = 12;
const int turnPixels = 12;
uint32_t backColorRear = colorBlack;
uint32_t backColorFront = colorBlack;
byte LTurnCt = 0;
byte RTurnCt = 0;

void setup() {
  // put your setup code here, to run once:
  pinMode(LTURN,         INPUT_PULLUP);
  pinMode(RTURN,         INPUT_PULLUP);
  pinMode(STOP,          INPUT_PULLUP);
  pinMode(RUNNING_LIGHT, INPUT_PULLUP);
  pinMode(HAZARD,        INPUT_PULLUP);
  pinMode(AUX,           INPUT_PULLUP);
  pinMode(REVERSE,       INPUT_PULLUP);
  strip.begin();
  strip.show();
  lfstrip.begin();
  lfstrip.show();
  rfstrip.begin();
  rfstrip.show();
  Serial.begin(9600);
}
 
void loop() {
  // put your main code here, to run repeatedly:
  backColorRear = colorBlack;
  backColorFront = colorBlack;
  //backColorRightFront = colorBlackRF;
 
  if (digitalRead(RUNNING_LIGHT) == LOW) {
    backColorRear = colorRunning;
    backColorFront = colorRunningFront;
}
  if (digitalRead(STOP) == LOW) backColorRear = colorStop;
  if (digitalRead(REVERSE) == LOW) backColorRear = colorReverse;
  if (digitalRead(LTURN) == LOW && digitalRead(HAZARD) == LOW){
    backColorRear = colorBlue;
    backColorFront = colorBlue;
  }
  if (digitalRead(RTURN) == LOW && digitalRead(HAZARD) == LOW){
    backColorRear = colorGreen;
   backColorFront = colorGreen;
  }
   for (int i = 0; i < LENGTHREAR; i++) strip.setPixelColor(i, backColorRear);
   for (int lf = 0; lf < LENGTHFRONT; lf++) lfstrip.setPixelColor(lf, backColorFront);
   for (int rf = 0; rf < LENGTHFRONT; rf ++) rfstrip.setPixelColor(rf, backColorFront);
       if (digitalRead(HAZARD) == LOW && ! digitalRead(LTURN)  == LOW && ! digitalRead(RTURN) == LOW) hazardOn();
  else if (digitalRead(AUX)    == LOW &&   digitalRead(STOP) ==  HIGH && ! digitalRead(LTURN)  == LOW && ! digitalRead(RTURN) == LOW) RWB();
  else if (digitalRead(LTURN) ==  LOW && ! digitalRead(HAZARD) == LOW) LSignal();
  else if (digitalRead(RTURN) ==  LOW && ! digitalRead(HAZARD) == LOW) RSignal();


  else {
    Serial.print("else ");
    RTurnCt = 0;
    LTurnCt = 0;

 
    strip.show();
    lfstrip.show();
    rfstrip.show();
  }
  delay(80);
}

void LSignal() {
  for (int i = LTurnIn; i >= (LTurnIn - LTurnCt); i--) strip.setPixelColor(i, colorTurn);
  for (int l = LTurnIn; l >= (LTurnIn - LTurnCt); l--) lfstrip.setPixelColor(l, colorTurn);
  LTurnCt++;
  if (LTurnCt > turnPixels) LTurnCt = 0;
  strip.show();
  lfstrip.show();
}

void RSignal() {
  for (int i = RTurnIn; i <= (RTurnIn + RTurnCt); i++) strip.setPixelColor(i, colorTurn);
  for (int l = RTurnIn; l >= (RTurnIn - RTurnCt); l--) rfstrip.setPixelColor(l, colorTurn);
  //for (int r = RTurnIn; r <= (RTurnIn + RTurnCt); r++) rfstrip.setPixelColor(r, colorTurn);
  RTurnCt++;
  if (RTurnCt > turnPixels) RTurnCt = 0;
  strip.show();
  rfstrip.show();
}

void hazardOn() {
  for (int i = LTurnIn; i >= (LTurnIn - LTurnCt); i--) strip.setPixelColor(i, colorTurn);
  for (int l = LTurnIn; l >= (LTurnIn - LTurnCt); l--) lfstrip.setPixelColor(l, colorTurn);
  LTurnCt++;
  if (LTurnCt > turnPixels) LTurnCt = 0;
  for (int i = RTurnIn; i <= (RTurnIn + RTurnCt); i++) strip.setPixelColor(i, colorTurn);
  for (int l = RTurnIn; l >= (RTurnIn - RTurnCt); l--) rfstrip.setPixelColor(l, colorTurn);
  RTurnCt++;
  if (RTurnCt > turnPixels) RTurnCt = 0;
  strip.show();
  lfstrip.show();
  rfstrip.show();
}

void rainbow() {
  uint16_t i, j;

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
  //  delay(wait);
  }
}

  void RWB() {

    strip.setPixelColor(0, 255, 0,0);
    strip.setPixelColor(1, 255, 0,0);
    strip.setPixelColor(2, 255, 0,0);
    strip.setPixelColor(3, 255, 0,0);
    strip.setPixelColor(4, 255, 0,0);
    strip.setPixelColor(5, 255, 0,0);
    strip.setPixelColor(6, 255, 0,0);
    strip.setPixelColor(7, 255, 0,0);
    strip.setPixelColor(8, 255, 0,0);
    strip.setPixelColor(9, 255, 0,0);
    strip.setPixelColor(10, 255, 255,255);
    strip.setPixelColor(11, 255, 255,255);
    strip.setPixelColor(12, 255, 255,255);
    strip.setPixelColor(13, 255, 255,255);
    strip.setPixelColor(14, 255, 255,255);
    strip.setPixelColor(15, 255, 255,255);
    strip.setPixelColor(16, 255, 255,255);
    strip.setPixelColor(17, 255, 255,255);
    strip.setPixelColor(18, 255, 255,255);
    strip.setPixelColor(19, 0, 0,255);
    strip.setPixelColor(20, 0, 0,255);
    strip.setPixelColor(21, 0, 0,255);
    strip.setPixelColor(22, 0, 0,255);
    strip.setPixelColor(23, 0, 0,255);
    strip.setPixelColor(24, 0, 0,255);
    strip.setPixelColor(25, 0, 0,255);
    strip.setPixelColor(26, 0, 0,255);
    strip.setPixelColor(27, 0, 0,255);
    strip.show();
   }

   

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}


Joe36
 
Posts: 43
Joined: Tue Dec 27, 2016 10:36 am

Please be positive and constructive with your questions and comments.