 void set_led_rgb(int x, int y, int r, int g, int b)
 {
   leds[ XY(x, y) ] = CRGB( r, g, b );
+}
+
+void ShowError(int errorNr)
+{
+  if(errorNr <= 0 || errorNr >= 200)
+    return;
+
+  Serial.print("Error: "); 
+  Serial.println(errorNr);
+
+  FastLED.clear();
+  for(int led = 0; led < errorNr; led++) { 
+    leds[led] = CRGB::Red; 
+  }
+  FastLED.show();
 }
 
 void RainbowA()

  return XY(x, y);
}

void loop()
{
  int brightness = analogRead(PIN_BRIGHTNESS);
  int newBrightness = map(brightness, 0, 1023, 0, 255);
  
  bool r = isButtonPressed();
  if(r)
    currentMode++;

  if(currentMode >= MAXMODE)
    currentMode = 0;

  EEPROM.write(eeprom_addr, currentMode);

  FastLED.clear();

  switch(currentMode)
  {
    case 0: Test(); break;
    case 1: ShowPotValue(); break;    
    case 2: RainbowA(); break;
    case 3: ShowGoomba(); break;
    case 4: ShowMario(); break;
  }
  
  FastLED.show();

  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()
