Code review

Anybody fancy taking a peek through my code and telling me if there is any better way to do half the things im doing... It appears the code is sloppy (first arduino prog), and when the device is in mode 3, (red/blue flashing) the lights 'freeze' after a while and stop rotating colors. If somebody could show me how i'm meant to be doing things like this, it would be handy.

Thanks, R4 (project file: http://rapidshare.com/files/403688285/r4.pde.html max 10 downloads, if more needed just reply and ill re-up)

Most people wouldn't trust a blind download like the one you've included. I recommend you place the code inline with your post.

Paste the code at the end of your post. Go back and select your in-lined code and then press the '#' button found in the middle top row of the posting toolbar. Use the "Preview" until you see your post present something like:

void setup()
{
}

void loop()
{
}

Then hit "Post"

Like so?

I’m intending to change all the Serial.println into a log(level, message) function that will log to the serial and a file if the level is high enough to warrent it (i plan to add ‘overheat’ warnings etc…)

And yes, the temp code is all useless, i can’t get reliable data out of my sensor (just a componant i robbed off another ciruit, gonna buy the right one soon)

But my main question is is the structure right or should i be doing it differently, I don’t like the fact that the RGB LED fading function actually blocks my LCD screen refreshing while the change is happened, thats why i put the tick() function in, but i’d rather have it all in one loop, but no idea howto structure it…

/**
 * R4000's Ardunio - XBOX360 LED/LCD controller.
 **
 * Fully functional LED controller with LCD controller.
 * Designed for use on my own XBOX360 with a semi-transparent case.
 **
 * For help or more information, contact: drewmoo@gmail.com
 **/
// MODE 0: All colors, cycling.
// MODE 1: Warm colors, cycling.
// MODE 2: Cold colors, cycling.
// MODE 3: Police lights, (red/blue alternating).
// MODE 4: Random lights (100% random RGB channels).
// MODE 5: Contrast controlled brightness.
// MODE 6: Lights out! (LCD is still lit)
// MODE 100: Hidden easter egg!

#include <LiquidCrystal.h>
#include <math.h>

LiquidCrystal LCD(12, 13, 2, 4, 7, 8);
int LED[2][3] = {
  {
    3, 6, 5        }
  , {
    10, 11, 9        }
};

int MAX_MODE = 6;

const byte RED[] = {
  255, 0, 0}; 
const byte ORANGE[] = {
  83, 4, 0}; 
const byte YELLOW[] = {
  255, 255, 0}; 
const byte GREEN[] = {
  0, 255, 0}; 
const byte BLUE[] = {
  0, 0, 255}; 
const byte INDIGO[] = {
  4, 0, 19}; 
const byte VIOLET[] = {
  23, 0, 22}; 
const byte CYAN[] = {
  0, 255, 255}; 
const byte MAGENTA[] = {
  255, 0, 255}; 
const byte WHITE[] = {
  255, 255, 255}; 
const byte BLACK[] = {
  0, 0, 0}; 
const byte PINK[] = {
  158, 4, 79}; 

int startTime = int(millis());
int temp = 0;
int mode = 0;
int button = 0;
int curcol = 0;
int curtime = 0;
int nextact = int(millis()) - 1;
int nextact1 = 0;
int startpress = 0;

byte heart[8] = {
  B00000,
  B01010,
  B11111,
  B01110,
  B00100,
  B00000,
  B00000,
};


void setup() {
  Serial.begin(9600);
  randomSeed(analogRead(5));
  LCD.begin(16, 2);
  LCD.createChar(0, heart);
  LCD.noCursor();

  for(int i=0;i<3;i++) {
    pinMode(LED[1][i], OUTPUT);
    analogWrite(LED[0][i], 255);
    pinMode(LED[2][i], OUTPUT);
    analogWrite(LED[1][i], 255);
  }

  Serial.println(">>> R4000's Arduino LED and LCD Controller.");
  Serial.println(">>> Successfully starting, initalizing bootup.");

  doStartup();
}

void doStartup() {
  LCD.clear();
  LCD.setCursor(0, 0);
  LCD.print("  -:[R4000]:-  ");
  delay(1000);
  LCD.setCursor(0, 1);
  LCD.print("Boot it all up!");

  Serial.println(">>> Testing RED color channel.");
  setColor(RED);
  delay(250);
  Serial.println(">>> Testing GREEN color channel.");
  setColor(GREEN);
  delay(250);
  Serial.println(">>> Testing BLUE color channel.");
  setColor(BLUE);
  delay(250);
  Serial.println(">>> Testing WHITE color channel.");
  setColor(WHITE);
  delay(250);
}

void tick() {
  curtime = int(millis());
  temp = analogRead(0)/5;
  int butval = analogRead(1);
  if(butval < 1000 && button == 1) {
    if(curtime > startpress && startpress != 0 && mode == 6) {
      mode = 100;
      startpress = 0;
    }
  }  
  else if(butval < 1000 && button == 0) {
    mode++;
    button = 1;
    curcol = 0;
    if(mode == 3) {
      setColor(LED[0], RED);
      setColor(LED[1], BLUE);
      nextact = int(millis()) + 100;
      nextact1 = 1;
    }
    if(mode > MAX_MODE) mode = 0;
    Serial.println(">>> Button Pressed");
    startpress = int(millis()) + 5000;
  } 
  else if(butval > 1000 && button == 1) {
    button = 0;
    startpress = 0;
    Serial.println(">>> Button UNpressed");
  } 
  else {
    startpress = 0;
  }

  Serial.print(">>> Temp: ");
  Serial.print(temp);
  Serial.print("C. Current Mode: ");
  Serial.print(mode);
  Serial.print(".\n");

  if(mode == 100) {
    LCD.clear();
    LCD.setCursor(0,0);
    LCD.print("  R4000 ");
    LCD.setCursor(8, 0);
    LCD.write(0);
    LCD.setCursor(10, 0);
    LCD.print("EMMA");
    LCD.setCursor(0,1);
    LCD.print("    FOREVER!    ");
  } 
  else {
    LCD.clear();
    LCD.setCursor(0, 0);
    LCD.print("  -:[R4000]:-  ");
    LCD.setCursor(10, 1);
    LCD.print("Mode:");
    LCD.setCursor(15, 1);
    LCD.print(mode);
    LCD.setCursor(0, 1);
    LCD.print("Temp:");
    LCD.setCursor(5, 1);
    LCD.print(temp);
    LCD.setCursor(7, 1);
    LCD.print("C");
  }
  delay(50);
}
void loop() {
  tick();
  if(mode == 0) {
    if(curcol == 0) fadeColor(RED, INDIGO,    "RED > INDIGO", 250, 0);
    if(curcol == 1) fadeColor(INDIGO, YELLOW, "INDIGO > YELLOW", 250, 0);
    if(curcol == 2) fadeColor(YELLOW, VIOLET, "YELLOW > VIOLET", 250, 0);
    if(curcol == 3) fadeColor(VIOLET, WHITE,  "VIOLET > WHITE", 250, 0);
    if(curcol == 4) fadeColor(WHITE, PINK,    "WHITE > PINK", 250, 0);
    if(curcol == 5) fadeColor(PINK, ORANGE,   "PINK > ORANGE", 250, 0);
    if(curcol == 6) fadeColor(ORANGE, BLUE,   "ORANGE > BLUE", 250, 0);
    if(curcol == 7) fadeColor(BLUE, GREEN,    "BLUE > GREEN", 250, 0);
    if(curcol == 8) fadeColor(GREEN, CYAN,    "GREEN > CYAN", 250, 0);
    if(curcol == 9) fadeColor(CYAN, VIOLET,   "CYAN > VIOLET", 250, 0);
    if(curcol == 10) fadeColor(VIOLET, GREEN,  "VIOLET > GREEN", 250, 0);
    if(curcol == 11) fadeColor(GREEN, MAGENTA, "GREEN > MAGENTA", 250, 0);
    if(curcol == 12) fadeColor(MAGENTA, RED,   "MAGENTA > RED", 250, 0);
    curcol++;
    if(curcol > 12) curcol = 0;
  } 
  else if (mode == 1) {
    if(curcol == 0) fadeColor(RED, ORANGE,    "RED > ORANGE", 250, 1);
    if(curcol == 1) fadeColor(ORANGE, YELLOW, "ORANGE > YELLOW", 250, 1);
    if(curcol == 2) fadeColor(YELLOW, GREEN, "YELLOW > GREEN", 250, 1);
    if(curcol == 3) fadeColor(GREEN, RED,   "GREEN > RED", 250, 1);
    curcol++;
    if(curcol > 3) curcol = 0;
  } 
  else if (mode == 2) {
    if(curcol == 0) fadeColor(BLUE, INDIGO,    "BLUE > INDIGO", 250, 2);
    if(curcol == 1) fadeColor(INDIGO, VIOLET, "INDIGO > VIOLET", 250, 2);
    if(curcol == 2) fadeColor(VIOLET, CYAN, "VIOLET > CYAN", 250, 2);
    if(curcol == 3) fadeColor(CYAN, MAGENTA,  "CYAN > MAGENTA", 250, 2);
    if(curcol == 4) fadeColor(MAGENTA, WHITE,    "MAGENTA > WHITE", 250, 2);
    if(curcol == 5) fadeColor(WHITE, BLUE,   "WHITE > BLUE", 250, 2);
    curcol++;
    if(curcol > 5) curcol = 0;
  } 
  else if(mode == 3) {
    if(curtime > nextact && nextact1 == 0) {
      setColor(LED[0], RED);
      setColor(LED[1], BLUE);
      nextact = curtime + 100;
      nextact1 = 1;
    } 
    else if(curtime > nextact && nextact1 == 1) {
      setColor(LED[1], RED);
      setColor(LED[0], BLUE);
      nextact = curtime + 100;
      nextact1 = 0;
    }
  } 
  else if(mode == 4) {
    int R = random(255);
    int G = random(255);
    int B = random(255);
    byte col[] = {
      R, G, B            };

    setColor(LED[0], col);
    int R2 = random(255);
    int G2 = random(255);
    int B2 = random(255);
    byte col2[] = {
      R2, G2, B2            };
    setColor(LED[1], col2);
  } 
  else if (mode == 5) {
    int val = analogRead(2);
    int R = (val /4)*2;
    int G = (val /4)*2;
    int B = (val /4)*2;
    byte col[] = {
      R, G, B            };
    setColor(LED[0], col);
    setColor(LED[1], col);
  } 
  else if (mode == 6) {
    setColor(LED[0], BLACK);
    setColor(LED[1], BLACK);
  }
  else if(mode = 100) {
    setColor(LED[0], RED);
    setColor(LED[1], RED);
  }
  tick();
}

void fadeColor(const byte* startColorA, const byte* endColorA, const char* message, int SPEED, int rlMODE){
  tick();
  byte startColor[] = {
    startColorA[0], startColorA[1], startColorA[2]        };
  byte endColor[] = {
    endColorA[0], endColorA[1], endColorA[2]        };

  int changeRed = endColor[0] - startColor[0];                           
  int changeGreen = endColor[1] - startColor[1];                         
  int changeBlue = endColor[2] - startColor[2];                          
  int steps = max(abs(changeRed),max(abs(changeGreen), abs(changeBlue)));

  for(int i = 0 ; i < steps; i++){
    byte newRed = startColor[0] + (i * changeRed / steps);
    byte newGreen = startColor[1] + (i * changeGreen / steps);
    byte newBlue = startColor[2] + (i * changeBlue / steps);
    byte newColor[] = {
      newRed, newGreen, newBlue                };
    setColor(newColor);
    delay(SPEED/steps);    
    tick(); 
    if(mode != rlMODE) break;
  }
  setColor(endColor);
}

void setColor(byte* color){
  for(int i = 0; i < 3; i++) {
    analogWrite(LED[0][i], 255 - color[i]);
    analogWrite(LED[1][i], 255 - color[i]);
  }
}

void setColor(const byte* color){
  byte tempByte[] = {
    color[0], color[1], color[2]        };
  setColor(tempByte);
}

void setColor(int* led, byte* color){
  for(int i = 0; i < 3; i++) {
    analogWrite(led[i], 255 - color[i]);
  }
}

void setColor(int* led, const byte* color){
  byte tempByte[] = {
    color[0], color[1], color[2]        };
  setColor(led, tempByte);
}

You have a “mode =” someplace in your code where you really meant “mode ==”.

I’m not much for writing up critiques. I instead prefer to rewrite things to present alternative ways of doing things.

The following has successfully compiled but is untested. I made no (real) changes to any of your calls of pinMode, analogRead or analogWrite so they should be just as safe, or dangerous, as your original code.

The rgb stuff has been completely represented as a type ‘rgb_t’ complete with the minimum arithmetic operators implimented as needed for the functionality I saw you using.

Hope I don’t lead you to astray!

#include <math.h>

#include <LiquidCrystal.h>

enum
{
        eMODE_ALL                  = 0            // All colors, cycling.
      , eMODE_WARM                        // Warm colors, cycling.
      , eMODE_COLD                        // Cold colors, cycling.
      , eMODE_POLICE                        // Police lights, (red/blue alternating).
      , eMODE_RANDOM                        // Random lights (100% random RGB channels).
      , eMODE_CONTRAST                  // Contrast controlled brightness.
      , eMODE_OUT                              // Lights out! (LCD is still lit)

      , eMODE_EASTER                        // Hidden easter egg!

      , eMODE_NUM_ENTRIES
};

struct rgb_t
{
      union {
            struct            { uint8_t _r, _g, _b; };
            uint8_t            rgb[3];
      };

      rgb_t() : _r(0), _g(0), _b(0)
      {}
      rgb_t(uint8_t r, uint8_t g, uint8_t b) : _r(r), _g(g), _b(b)
      {}

      // --- Accessors
      uint8_t r() const      { return  _r; }
      uint8_t g() const      { return  _g; }
      uint8_t b() const      { return  _b; }

      void r(uint8_t r)      { _r = r; }
      void g(uint8_t g)      { _g = g; }
      void b(uint8_t b)      { _b = b; }

      // --- operators
      rgb_t operator+ (const rgb_t& rgbRHS) const
      {
            return rgb_t(_r + rgbRHS._r, _g + rgbRHS._g, _b + rgbRHS._b);
      }

      rgb_t operator- (const rgb_t& rgbRHS) const
      {
            return rgb_t(_r - rgbRHS._r, _g - rgbRHS._g, _b - rgbRHS._b);
      }

      rgb_t operator* (int s) const
      {
            return rgb_t(_r * s, _g * s, _b * s);
      }

      rgb_t operator/ (int s) const
      {
            return rgb_t(_r / s, _g / s, _b / s);
      }

      operator const uint8_t* () const { return rgb; }
};


const rgb_t            k_rgbRED(0xFF, 0x00, 0x00);
const rgb_t            k_rgbORANGE(0x53, 0x04, 0x00);
const rgb_t            k_rgbYELLOW(0xFF, 0xFF, 0x00);
const rgb_t            k_rgbGREEN(0x00, 0xFF, 0x00);
const rgb_t            k_rgbBLUE(0x00, 0x00, 0xFF);
const rgb_t            k_rgbINDIGO(0x04, 0x00, 0x13);
const rgb_t            k_rgbVIOLET(0x17, 0x00, 0x16);
const rgb_t            k_rgbCYAN(0x00, 0xFF, 0xFF);
const rgb_t            k_rgbMAGENTA(0xFF, 0x00, 0xFF);
const rgb_t            k_rgbWHITE(0xFF, 0xFF, 0xFF);
const rgb_t            k_rgbBLACK(0x00, 0x00, 0x00);
const rgb_t            k_rgbPINK(0x9E, 0x04, 0x4F);



LiquidCrystal LCD(12, 13, 2, 4, 7, 8);

int LED[][3] = { {      3,      6,      5 }, { 10, 11,      9 } };

int startTime                  = int(millis());
int temp                        = 0;
int mode                        = eMODE_ALL;
int button                        = 0;
int curcol                        = 0;
int curtime                        = 0;
int nextact                        = int(millis()) - 1;
int nextact1                  = 0;
int startpress                  = 0;

byte heart[8] =
{
        B00000
      , B01010
      , B11111
      , B01110
      , B00100
      , B00000
      , B00000
};


void setColor(const rgb_t& rgb)
{
      for ( int i = 0; i < sizeof(rgb.rgb); i++ )
      {
            analogWrite(LED[0][i], 0xFF - rgb[i]);
            analogWrite(LED[1][i], 0xFF - rgb[i]);
      }
}


void setColor(int* led, const rgb_t& rgb)
{
      for ( int i = 0; i < sizeof(rgb.rgb); i++ )
      {
            analogWrite(led[i], 0xFF - rgb.rgb[i]);
      }
}

void tick()
{
      curtime            = int(millis());
      temp            = analogRead(0) / 5;

      int butval      = analogRead(1);

      if ( butval < 1000 && button == 1 )
      {
            if ( curtime > startpress && startpress != 0 && (mode == eMODE_OUT) )
            {
                  mode = eMODE_EASTER;
                  startpress = 0;
            }
      }

      else if ( butval < 1000 && button == 0 )
      {
            mode = ((++mode) % eMODE_NUM_ENTRIES);

            button = 1;
            curcol = 0;

            if ( mode == eMODE_POLICE )
            {
                  setColor(LED[0], k_rgbRED);
                  setColor(LED[1], k_rgbBLUE);
                  nextact = int(millis()) + 100;
                  nextact1 = 1;
            }

            Serial.println(">>> Button Pressed");
            startpress = int(millis()) + 5000;
      }
      else if(butval > 1000 && button == 1)
      {
            button            = 0;
            startpress      = 0;
            Serial.println(">>> Button UNpressed");
      }
      else
      {
            startpress = 0;
      }

      Serial.print(">>> Temp: ");                  Serial.print(temp);
      Serial.print("C. Current Mode: ");      Serial.print(mode); Serial.print(".\n");

      if ( mode == eMODE_EASTER )
      {
            LCD.clear();
            LCD.setCursor( 0, 0);                  LCD.print("       R4000 ");
            LCD.setCursor( 8, 0);                  LCD.write(0);
            LCD.setCursor(10, 0);                  LCD.print("EMMA");
            LCD.setCursor( 0, 1);                  LCD.print("         FOREVER!         ");
      }
      else
      {
            LCD.clear();
            LCD.setCursor( 0, 0);                  LCD.print("       -:[R4000]:-  ");
            LCD.setCursor(10, 1);                  LCD.print("Mode:");
            LCD.setCursor(15, 1);                  LCD.print(mode);
            LCD.setCursor( 0, 1);                  LCD.print("Temp:");
            LCD.setCursor( 5, 1);                  LCD.print(temp);
            LCD.setCursor( 7, 1);                  LCD.print("C");
      }

      delay(50);
}


void fadeColor(const rgb_t& rgbSrc, const rgb_t& rgbDst, const char* message, int SPEED, int rlMODE)
{
      tick();

      rgb_t      rgb(rgbDst - rgbSrc);
      int            steps      = max(abs(rgb.r()), max(abs(rgb.g()), abs(rgb.b())));
      for ( int i = 0 ; i < steps; i++ )
      {
            setColor(rgb_t(rgbSrc + ((rgb * i) / steps)));

            delay(SPEED / steps);
            tick();

            if (mode != eMODE_ALL ) break;
      }

      setColor(rgbDst);
}


void loop()
{
      tick();

      switch ( mode )
      {
            case eMODE_ALL:
                  switch ( curcol )
                  {
                        case  0: fadeColor(k_rgbRED, k_rgbINDIGO, "RED > INDIGO", 250, 0);                  break;
                        case  1: fadeColor(k_rgbINDIGO, k_rgbYELLOW, "INDIGO > YELLOW", 250, 0);      break;
                        case  2: fadeColor(k_rgbYELLOW, k_rgbVIOLET, "YELLOW > VIOLET", 250, 0);      break;
                        case  3: fadeColor(k_rgbVIOLET, k_rgbWHITE, "VIOLET > WHITE", 250, 0);            break;
                        case  4: fadeColor(k_rgbWHITE, k_rgbPINK, "WHITE > PINK", 250, 0);                  break;
                        case  5: fadeColor(k_rgbPINK, k_rgbORANGE, "PINK > ORANGE", 250, 0);            break;
                        case  6: fadeColor(k_rgbORANGE, k_rgbBLUE, "ORANGE > BLUE", 250, 0);            break;
                        case  7: fadeColor(k_rgbBLUE, k_rgbGREEN, "BLUE > GREEN", 250, 0);                  break;
                        case  8: fadeColor(k_rgbGREEN, k_rgbCYAN, "GREEN > CYAN", 250, 0);                  break;
                        case  9: fadeColor(k_rgbCYAN, k_rgbVIOLET, "CYAN > VIOLET", 250, 0);            break;
                        case 10: fadeColor(k_rgbVIOLET, k_rgbGREEN, "VIOLET > GREEN", 250, 0);            break;
                        case 11: fadeColor(k_rgbGREEN, k_rgbMAGENTA, "GREEN > MAGENTA", 250, 0);      break;
                        case 12: fadeColor(k_rgbMAGENTA, k_rgbRED, "MAGENTA > RED", 250, 0);            break;
                  }
      
                  curcol = ((curcol++) % 13);
                  break;

            case eMODE_WARM:
                  switch ( curcol )
                  {
                        case 0: fadeColor(k_rgbRED, k_rgbORANGE, "RED > ORANGE", 250, 1);                  break;
                        case 1: fadeColor(k_rgbORANGE, k_rgbYELLOW, "ORANGE > YELLOW", 250, 1);            break;
                        case 2: fadeColor(k_rgbYELLOW, k_rgbGREEN, "YELLOW > GREEN", 250, 1);            break;
                        case 3: fadeColor(k_rgbGREEN, k_rgbRED, "GREEN > RED", 250, 1);                        break;
                  }
      
                  curcol = ((curcol++) % 4);
                  break;

            case eMODE_COLD:
                  switch ( curcol )
                  {
                        case 0: fadeColor(k_rgbBLUE, k_rgbINDIGO,       "BLUE > INDIGO", 250, 2);            break;
                        case 1: fadeColor(k_rgbINDIGO, k_rgbVIOLET, "INDIGO > VIOLET", 250, 2);            break;
                        case 2: fadeColor(k_rgbVIOLET, k_rgbCYAN, "VIOLET > CYAN", 250, 2);                  break;
                        case 3: fadeColor(k_rgbCYAN, k_rgbMAGENTA,      "CYAN > MAGENTA", 250, 2);            break;
                        case 4: fadeColor(k_rgbMAGENTA, k_rgbWHITE,         "MAGENTA > WHITE", 250, 2);      break;
                        case 5: fadeColor(k_rgbWHITE, k_rgbBLUE,   "WHITE > BLUE", 250, 2);                  break;
                  }
      
                  curcol = ((curcol++) % 6);
                  break;

            case eMODE_POLICE:
                  if ( curtime > nextact && nextact1 == 0 )
                  {
                        setColor(LED[0], k_rgbRED);
                        setColor(LED[1], k_rgbBLUE);
                        nextact            = curtime + 100;
                        nextact1      = 1;
                  }
                  else if ( curtime > nextact && nextact1 == 1 )
                  {
                        setColor(LED[1], k_rgbRED);
                        setColor(LED[0], k_rgbBLUE);
                        nextact            = curtime + 100;
                        nextact1      = 0;
                  }
                  break;

            case eMODE_RANDOM:
                  setColor(LED[0], rgb_t(random(0xFF), random(0xFF), random(0xFF)));
                  setColor(LED[1], rgb_t(random(0xFF), random(0xFF), random(0xFF)));
                  break;

            case eMODE_CONTRAST:
            {
                  int            v = ((analogRead(2) / 4) * 2);
                  setColor(LED[0], rgb_t(v, v, v));
                  setColor(LED[1], rgb_t(v, v, v));
                  break;
            }

            case eMODE_OUT:
                  setColor(LED[0], k_rgbBLACK);
                  setColor(LED[1], k_rgbBLACK);
                  break;

            case eMODE_EASTER:
                  setColor(LED[0], k_rgbRED);
                  setColor(LED[1], k_rgbRED);
                  break;
      }

      tick();
}

void doStartup()
{
      LCD.clear();
      LCD.setCursor(0, 0);                        LCD.print("       -:[R4000]:-  ");
      delay(1000);

      LCD.setCursor(0, 1);                        LCD.print("Boot it all up!");

      // --- 

      Serial.println(">>> Testing RED color channel.");
      setColor(k_rgbRED);
      delay(250);

      Serial.println(">>> Testing GREEN color channel.");
      setColor(k_rgbGREEN);
      delay(250);

      Serial.println(">>> Testing BLUE color channel.");
      setColor(k_rgbBLUE);
      delay(250);

      Serial.println(">>> Testing WHITE color channel.");
      setColor(k_rgbWHITE);
      delay(250);
}


void setup()
{
      Serial.begin(9600);

      randomSeed(analogRead(5));

      LCD.begin(16, 2);
      LCD.createChar(0, heart);
      LCD.noCursor();

      for ( int i = 0; i < 3; i++ )
      {
            pinMode(LED[1][i], OUTPUT);            analogWrite(LED[0][i], 0xFF);
            pinMode(LED[2][i], OUTPUT);            analogWrite(LED[1][i], 0xFF);
      }

      Serial.println(">>> R4000's Arduino LED and LCD Controller.");
      Serial.println(">>> Successfully starting, initalizing bootup.");

      doStartup();
}