 #include <FastLED.h>
 #include <EEPROM.h>
 #include <SPI.h>
+#include <SD.h>
 
 #define LED_PIN     5
 #define COLOR_ORDER GRB
 #define CHIPSET     WS2811
 
 #define PIN_BRIGHTNESS A0
-#define PIN_MODE 4
+#define PIN_MODE 3
 #define PIN_LED A1
 
-int currentMode = 4;
-#define MAXMODE 5
+#define DEFAULTMODE 5;
+#define MAXMODE 6
+int currentMode = DEFAULTMODE;
 int eeprom_addr = 0;
-
-long lastMillis = millis();
-long currentMillis = millis();
-long pauseMillis = 10 * 1000;
 
 const uint8_t kMatrixWidth = 20;
 const uint8_t kMatrixHeight = 10;

void set_led_rgb(int x, int y, int r, int g, int b)
{
  leds[ XY(x, y) ] = CRGB( r, g, b );
}

void RainbowA()

  set_led_rgb(2, 1, 0, 0, 255);    
}

int lastNumLedsToLight = 0;

void ShowPotValue()
{
  int val = analogRead(PIN_BRIGHTNESS);
  int numLedsToLight = map(val, 0, 1023, 0, 200);

  if(numLedsToLight != lastNumLedsToLight)
  {
    lastNumLedsToLight = numLedsToLight;
    Serial.print("Pot: ");    
    Serial.println(lastNumLedsToLight);
  }  

  FastLED.clear();
    for(int led = 0; led < numLedsToLight; led++) { 
      leds[led] = CRGB::Blue; 
    }
  FastLED.show();
}

bool shown = false;

int ShowFiles()
{
  unsigned long currentMillis = millis();
  long delta = currentMillis - previousMillis;
  if(delta < interval)
    return;  
  previousMillis = currentMillis;
  currentFileIndex++;    

  FastLED.clear();

  sprintf(curFileName, "%02d.txt", currentFileIndex);
  myFile = SD.open(curFileName, FILE_READ);
  if(!myFile)
  {
    currentFileIndex = 1;
    sprintf(curFileName, "%02d.txt", currentFileIndex);
    myFile = SD.open(curFileName, FILE_READ);
  }

  if(!myFile)
  {
    ShowError(1);
    return;
  }
  
  Serial.println(curFileName);
  
  String line = "";
  while(myFile.available())
  { 
    char c = (char) myFile.read();

    line += c;

    if(c == '\n')
    {
      int val[5];
      char *pch;
      pch = strtok (line.c_str(), ",");
      for(byte i = 0; i < 5; ++i)
      {
        if(pch == NULL)
          break;
        String s(pch); 
        val[i] = s.toInt();
        pch = strtok (NULL, ",");
      }

      set_led_rgb(val[0], val[1], val[2], val[3], val[4]);
      
      line = "";
    }
  }

  myFile.close();

  return 0;
}

void ShowGoomba()
