Scrolling Red-White-Blue Bars

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
adavegetable
 
Posts: 20
Joined: Mon Jan 20, 2014 2:47 pm

Scrolling Red-White-Blue Bars

Post by adavegetable »

This code - slightly modifed from LeftCoast - makes three color bars scroll from left to right. The required LeftCoast Libraries were moved on GitHub - but I've updated their links.

Code: Select all

/*
  04APR22 Arduno IDE 1.8.19 Compiled for Leonardo
  Sketch uses 8996 bytes (31%) of program storage space. Maximum is 28672 bytes.
  Global variables use 348 bytes (13%) of dynamic memory, leaving 2212 bytes for local variables. Maximum is 2560 bytes.

  03APR22 Arduno IDE 1.8.5 Compiled for Leonardo
  Sketch uses 8872 bytes (30%) of program storage space. Maximum is 28672 bytes.
  Global variables use 348 bytes (13%) of dynamic memory, leaving 2212 bytes for local variables. Maximum is 2560 bytes.

*/

#include <Adafruit_NeoPixel.h>

// From LeftCoast https://github.com/leftCoast/LC_baseTools
#include <colorObj.h>
#include <mapper.h>
#include <multiMap.h>
#include <timeObj.h>

// From LeftCoast https://github.com/leftCoast/LC_neoPixel
#include <neoPixel.h>


#define STRING_PIN        6
#define NUM_PIXELS        60
#define MS_PER_MOVE       50
#define PIXELS_PER_COLOR  5

neoPixel  theString(NUM_PIXELS, STRING_PIN);
timeObj   moveDelay(MS_PER_MOVE);

int           colorCount;
colorObj      currentColor;
enum          colorChoices { colorRd, colorWt, colorBl };
colorChoices  colorChoice;


void setup() {
  theString.setBrightness(63);// Global Brightness (0-256) attached to string name;
  theString.begin();
  theString.show();
  moveDelay.start();
  colorCount = 0;
  colorChoice = colorRd;
  currentColor.setColor(&red);
}


void setupNextMove(void) {
  colorObj  tempColor;
  for (int i = NUM_PIXELS - 1; i >= 1; i--) {
    tempColor = theString.getPixelColor(i - 1);
    theString.setPixelColor(i, &tempColor);
  }
  if (colorCount >= PIXELS_PER_COLOR) {
    switch (colorChoice) {
      case colorRd :
        colorChoice = colorWt;
        currentColor.setColor(&white);
        break;
      case colorWt :
        colorChoice = colorBl;
        currentColor.setColor(&blue);
        break;
      case colorBl :
        colorChoice = colorRd;
        currentColor.setColor(&red);
        break;
    }
    colorCount = 0;
  }
  //currentColor.blend(&black,50);  // <<-- Try this for a cool effect.
  theString.setPixelColor(0, &currentColor);
  colorCount++;
}


void loop() {

  if (moveDelay.ding()) {
    moveDelay.stepTime();
    theString.show();
    setupNextMove();
  }
}

User avatar
tepalia02
 
Posts: 104
Joined: Sun Apr 24, 2022 6:53 am

Re: Scrolling Red-White-Blue Bars

Post by tepalia02 »

Is there any video demonstration too? Thanks.

User avatar
adavegetable
 
Posts: 20
Joined: Mon Jan 20, 2014 2:47 pm

Re: Scrolling Red-White-Blue Bars

Post by adavegetable »

I'll try to setup and record a video in a couple of days.

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”