Flux Capacitor inside a Track car

Long time lover first time poster/project,

Hi Guys and Gals I'm hoping i can get some help with my fluxy.

I've 3d printed the casing and began setting up the arduino UNO

My idea is to have the leds change their speed depending on rpm value, the signal from the ecu i think is PWM 50% duty cycle, 5v amplitude (in Hz) rpm/60, 6000RPM = 100Hz,
so as the rpms increase so does the led speed (shooting star effect) until it hits a threshold of 6000rpm at which all LEDS flash fast RED


If rpm pwm input is too complicated then just an input going LOW should stop the shooting star effect and begin the red flash, the tacho i use at the moments already has a 12v output for optional shift light, i can use this to energise a relay and use the contacts for input control
Come on i know this sounds pretty damn cool who can help me?

the code I have for it at the moment is the following


#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(19, 8, 19, 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: Rainbow - LEDS: 19
    // Steps: 15 - Delay: 32
    // Colors: 10 (0.255.0, 255.255.255, 0.0.0, 0.0.0, 0.0.0, 0.0.0, 0.0.0, 0.0.0, 0.0.0, 0.0.0)
    // Options: rainbowlen=15, toLeft=false, 
  if(millis() - strip_0.effStart < 32 * (strip_0.effStep)) return 0x00;
  float factor1, factor2;
  uint16_t ind;
  for(uint16_t j=0;j<19;j++) {
    ind = 15 - (uint16_t)(strip_0.effStep - j * 1) % 15;
    switch((int)((ind % 15) / 1.5)) {
      case 0: factor1 = 1.0 - ((float)(ind % 15 - 0 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 0) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 255 * factor2, 255 * factor1 + 255 * factor2, 0 * factor1 + 255 * factor2);
              break;
      case 1: factor1 = 1.0 - ((float)(ind % 15 - 1 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 1.5) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 255 * factor1 + 0 * factor2, 255 * factor1 + 0 * factor2, 255 * factor1 + 0 * factor2);
              break;
      case 2: factor1 = 1.0 - ((float)(ind % 15 - 2 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 3) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2);
              break;
      case 3: factor1 = 1.0 - ((float)(ind % 15 - 3 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 4.5) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2);
              break;
      case 4: factor1 = 1.0 - ((float)(ind % 15 - 4 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 6) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2);
              break;
      case 5: factor1 = 1.0 - ((float)(ind % 15 - 5 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 7.5) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2);
              break;
      case 6: factor1 = 1.0 - ((float)(ind % 15 - 6 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 9) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2);
              break;
      case 7: factor1 = 1.0 - ((float)(ind % 15 - 7 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 10.5) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2);
              break;
      case 8: factor1 = 1.0 - ((float)(ind % 15 - 8 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 12) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2, 0 * factor1 + 0 * factor2);
              break;
      case 9: factor1 = 1.0 - ((float)(ind % 15 - 9 * 1.5) / 1.5);
              factor2 = (float)((int)(ind - 13.5) % 15) / 1.5;
              strip_0.strip.setPixelColor(j, 0 * factor1 + 0 * factor2, 0 * factor1 + 255 * factor2, 0 * factor1 + 0 * factor2);
              break;
    }
  }
  if(strip_0.effStep >= 15) {strip_0.Reset(); return 0x03; }
  else strip_0.effStep++;
  return 0x01;
}

Your post was MOVED to its current location as it is more suitable.

Please follow the advice given in the link below when posting code , use code tags and post the code here to make it easier to read and copy for examination

You should post code by using code-tags
There is an automatic function for doing this in the Arduino-IDE
just three steps

  1. press Ctrl-T for autoformatting your code
  2. do a rightclick with the mouse and choose "copy for forum"
  3. paste clipboard into write-window of a posting

best regards Stefan

Thanks guys i think ive done the code right?