Neopixel Coding issues

Hi so I'm really new to coding, and I'm working on a project where the goal is to have one set of 29 red leds that fade to blue, and 31 blue leds fade to red. Countering each other in a loop. I tried to figure out how to fix my error on the code itself and was struggling, but I was hoping someone might be able to help or offer some guidance on the errors and if they notice anything in the code outright that might present an issue. I'm using an Arduino Uno, and Neopixel strip for the project

Here is the code

#include <Adafruit_NeoPixel.h>

class Strip
{
public:
  uint8_t   effect;
  uint8_t   effects;
  uint16_t  effStep;
  unsigned long effStart;
  Adafruit_NeoPixel strip;
  Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : strip(leds, pin, striptype) {
    effect = -1;
    effects = toteffects;
    Reset();
  }
  void Reset(){
    effStep = 0;
    effect = (effect + 1) % effects;
    effStart = millis();
  }
};

struct Loop
{
  uint8_t currentChild;
  uint8_t childs;
  bool timeBased;
  uint16_t cycles;
  uint16_t currentTime;
  Loop(uint8_t totchilds, bool timebased, uint16_t tottime) {currentTime=0;currentChild=0;childs=totchilds;timeBased=timebased;cycles=tottime;}
};

Strip strip_0(31, 8, 31, NEO_GRB + NEO_KHZ800);
struct Loop strip0loop0(1, false, 1);

void setup() {

  strip_0.strip.begin();
}

void loop() {

  strips_loop();
}

void strips_loop() {
  if(strip0_loop0() & 0x01)
    strip_0.strip.show();
}

uint8_t strip0_loop0() {
  uint8_t ret = 0x00;
  switch(strip0loop0.currentChild) {
    case 0: 
           ret = strip0_loop0_eff0();break;
  }
  if(ret & 0x02) {
    ret &= 0xfd;
    if(strip0loop0.currentChild + 1 >= strip0loop0.childs) {
      strip0loop0.currentChild = 0;
      if(++strip0loop0.currentTime >= strip0loop0.cycles) {strip0loop0.currentTime = 0; ret |= 0x02;}
    }
    else {
      strip0loop0.currentChild++;
    }
  };
  return ret;
}

uint8_t strip0_loop0_eff0() {
    // Strip ID: 0 - Effect: Fade - LEDS: 31
    // Steps: 996 - Delay: 1
    // Colors: 2 (0.0.255, 255.0.0)
    // Options: duration=996, every=1, 
  if(millis() - strip_0.effStart < 1 * (strip_0.effStep)) return 0x00;
  uint8_t r,g,b;
  double e;
  e = (strip_0.effStep * 1) / 996;
  r = ( e ) * 255 + 0 * ( 1.0 - e );
  g = ( e ) * 0 + 0 * ( 1.0 - e );
  b = ( e ) * 0 + 255 * ( 1.0 - e );
  for(uint16_t j=0;j<31;j++) {
    if((j % 1) == 0)
      strip_0.strip.setPixelColor(j, r, g, b);
    else
      strip_0.strip.setPixelColor(j, 0, 0, 0);
  }
  if(strip_0.effStep >= 996) {strip_0.Reset(); return 0x03; }
  else strip_0.effStep++;
  return 0x01;
}

#include <Adafruit_NeoPixel.h>

public:
  uint8_t   effect;
  uint8_t   effects;
  uint16_t  effStep;
  unsigned long effStart;
  Adafruit_NeoPixel strip;
  Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : Strip(leds, pin, striptype) {
    effect = -1;
    effects = toteffects;
    Reset();
  }
  void Reset(){
    effStep = 0;
    effect = (effect + 1) % effects;
    effStart = millis();
  }
};

struct Loop
{
  uint8_t currentChild;
  uint8_t childs;
  bool timeBased;
  uint16_t cycles;
  uint16_t currentTime;
  Loop(uint8_t totchilds, bool timebased, uint16_t tottime) {currentTime=0;currentChild=0;childs=totchilds;timeBased=timebased;cycles=tottime;}
};

Strip strip_0(29, 9, 29, NEO_GRB + NEO_KHZ800);
struct Loop strip0loop0(1, false, 1);

//[GLOBAL_VARIABLES]

void setup() {

  //Your setup here:

  strip_0.strip.begin();
}

void loop() {

  //Your code here:

  strips_loop();
}

void strips_loop() {
  if(strip0_loop0() & 0x01)
    strip_0.strip.show();
}

uint8_t strip0_loop0() {
  uint8_t ret = 0x00;
  switch(strip0loop0.currentChild) {
    case 0: 
           ret = strip0_loop0_eff0();break;
  }
  if(ret & 0x02) {
    ret &= 0xfd;
    if(strip0loop0.currentChild + 1 >= strip0loop0.childs) {
      strip0loop0.currentChild = 0;
      if(++strip0loop0.currentTime >= strip0loop0.cycles) {strip0loop0.currentTime = 0; ret |= 0x02;}
    }
    else {
      strip0loop0.currentChild++;
    }
  };
  return ret;
}

uint8_t strip0_loop0_eff0() {
    // Strip ID: 0 - Effect: Fade - LEDS: 29
    // Steps: 996 - Delay: 1
    // Colors: 2 (255.0.0, 0.11.255)
    // Options: duration=996, every=1, 
  if(millis() - strip_0.effStart < 1 * (strip_0.effStep)) return 0x00;
  uint8_t r,g,b;
  double e;
  e = (strip_0.effStep * 1) / 996;
  r = ( e ) * 0 + 255 * ( 1.0 - e );
  g = ( e ) * 11 + 0 * ( 1.0 - e );
  b = ( e ) * 255 + 0 * ( 1.0 - e );
  for(uint16_t j=0;j<29;j++) {
    if((j % 1) == 0)
      strip_0.strip.setPixelColor(j, r, g, b);
    else
      strip_0.strip.setPixelColor(j, 0, 0, 0);
  }
  if(strip_0.effStep >= 996) {strip_0.Reset(); return 0x03; }
  else strip_0.effStep++;
  return 0x01;
}

and the error message i'm receiving:

Arduino: 1.8.9 (Windows Store 1.8.21.0) (Windows 10), Board: "Arduino/Genuino Uno"

sketch_dec19a:101:17: error: expected ')' before 'leds'

   Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : Strip(leds, pin, striptype) {

                 ^

sketch_dec19a:95:1: error: expected unqualified-id before 'public'

 public:

 ^

sketch_dec19a:101:18: error: expected ')' before 'leds'

   Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : Strip(leds, pin, striptype) {

                  ^

C:\Users\The Pit One\Documents\Arduino\libraries\sketch_dec19a\sketch_dec19a.ino: In function 'void Reset()':

sketch_dec19a:108:5: error: 'effect' was not declared in this scope

     effect = (effect + 1) % effects;

     ^

C:\Users\The Pit One\Documents\Arduino\libraries\sketch_dec19a\sketch_dec19a.ino: At global scope:

sketch_dec19a:111:1: error: expected declaration before '}' token

 };

 ^

exit status 1
expected ')' before 'leds'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Any help or advice will be much appreciated. Thank you so much

Can you clean up your code. You had the same code twice in one file.

I tried to write the code so one side would be blue and go to a pin on the board, and one would be red on a different pin. Probably not the best way to do it

danelindquist:
I tried to write the code so one side would be blue and go to a pin on the board, and one would be red on a different pin. Probably not the best way to do it

Your code and this reply show that you are both at a very new and an intermediate level at the same time. Do you mind to clear it up a little bit?

This is my first attempt at coding, so I'm very new. I'm so sorry, I'm unclear on what you mean by clear it up a little bit? I'll go ahead and remove the repeat part of the code i have and try and clean it up.

I tried to clean up the code and get rid of the double code i had. I no longer have errors on it, so i'll hook it up and see if it does what i want it to. Here is the updated code.

#include <Adafruit_NeoPixel.h>

class Strip
{
public:
  uint8_t   effect;
  uint8_t   effects;
  uint16_t  effStep;
  unsigned long effStart;
  Adafruit_NeoPixel strip;
  Strip(uint16_t leds, uint8_t pin, uint8_t toteffects, uint16_t striptype) : strip(leds, pin, striptype) {
    effect = -1;
    effects = toteffects;
    Reset();
  }
  void Reset(){
    effStep = 0;
    effect = (effect + 1) % effects;
    effStart = millis();
  }
};

struct Loop
{
  uint8_t currentChild;
  uint8_t childs;
  bool timeBased;
  uint16_t cycles;
  uint16_t currentTime;
  Loop(uint8_t totchilds, bool timebased, uint16_t tottime) {currentTime=0;currentChild=0;childs=totchilds;timeBased=timebased;cycles=tottime;}
};

Strip strip_0(31, 8, 31, NEO_GRB + NEO_KHZ800);
struct Loop strip0loop0(1, false, 1);

void setup() {

  strip_0.strip.begin();
}

void loop() {

  strips_loop();
}

void strips_loop() {
  if(strip0_loop0() & 0x01)
    strip_0.strip.show();
}

uint8_t strip0_loop0() {
  uint8_t ret = 0x00;
  switch(strip0loop0.currentChild) {
    case 0:
           ret = strip0_loop0_eff0();break;
  }
  if(ret & 0x02) {
    ret &= 0xfd;
    if(strip0loop0.currentChild + 1 >= strip0loop0.childs) {
      strip0loop0.currentChild = 0;
      if(++strip0loop0.currentTime >= strip0loop0.cycles) {strip0loop0.currentTime = 0; ret |= 0x02;}
    }
    else {
      strip0loop0.currentChild++;
    }
  };
  return ret;
}

uint8_t strip0_loop0_eff0() {
    // Strip ID: 0 - Effect: Fade - LEDS: 31
    // Steps: 996 - Delay: 1
    // Colors: 2 (0.0.255, 255.0.0)
    // Options: duration=996, every=1,
  if(millis() - strip_0.effStart < 1 * (strip_0.effStep)) return 0x00;
  uint8_t r,g,b;
  double e;
  e = (strip_0.effStep * 1) / 996;
  r = ( e ) * 255 + 0 * ( 1.0 - e );
  g = ( e ) * 0 + 0 * ( 1.0 - e );
  b = ( e ) * 0 + 255 * ( 1.0 - e );
  for(uint16_t j=0;j<31;j++) {
    if((j % 1) == 0)
      strip_0.strip.setPixelColor(j, r, g, b);
    else
      strip_0.strip.setPixelColor(j, 0, 0, 0);
  }
  if(strip_0.effStep >= 996) {strip_0.Reset(); return 0x03; }
  else strip_0.effStep++;
  return 0x01;
}

Strip strip_1(29, 9, 29, NEO_GRB + NEO_KHZ800);
struct Loop strip1loop0(1, false, 1);

//[GLOBAL_VARIABLES]

uint8_t strip1_loop0() {
  uint8_t ret = 0x00;
  switch(strip1loop0.currentChild) {
    case 0:
           ret = strip1_loop0_eff0();break;
  }
  if(ret & 0x02) {
    ret &= 0xfd;
    if(strip1loop0.currentChild + 1 >= strip1loop0.childs) {
      strip1loop0.currentChild = 0;
      if(++strip1loop0.currentTime >= strip1loop0.cycles) {strip1loop0.currentTime = 0; ret |= 0x02;}
    }
    else {
      strip1loop0.currentChild++;
    }
  };
  return ret;
}

uint8_t strip1_loop0_eff0() {
    // Strip ID: 0 - Effect: Fade - LEDS: 29
    // Steps: 996 - Delay: 1
    // Colors: 2 (255.0.0, 0.11.255)
    // Options: duration=996, every=1,
  if(millis() - strip_1.effStart < 1 * (strip_1.effStep)) return 0x00;
  uint8_t r,g,b;
  double e;
  e = (strip_1.effStep * 1) / 996;
  r = ( e ) * 0 + 255 * ( 1.0 - e );
  g = ( e ) * 11 + 0 * ( 1.0 - e );
  b = ( e ) * 255 + 0 * ( 1.0 - e );
  for(uint16_t j=0;j<29;j++) {
    if((j % 1) == 0)
      strip_1.strip.setPixelColor(j, r, g, b);
    else
      strip_1.strip.setPixelColor(j, 0, 0, 0);
  }
  if(strip_1.effStep >= 996) {strip_1.Reset(); return 0x03; }
  else strip_1.effStep++;
  return 0x01;
}