   leds[ XY(x, y) ] = CRGB( r, g, b );
 }
 
+void RainbowA()
+{
+    uint32_t ms = millis();
+    int32_t yHueDelta32 = ((int32_t)cos16( ms * (27/1) ) * (350 / kMatrixWidth));
+    int32_t xHueDelta32 = ((int32_t)cos16( ms * (39/1) ) * (310 / kMatrixHeight));
+    DrawOneFrame( ms / 65536, yHueDelta32 / 32768, xHueDelta32 / 32768);
+    FastLED.show(); 
+}
+
+void DrawOneFrame( byte startHue8, int8_t yHueDelta8, int8_t xHueDelta8)
+{
+  byte lineStartHue = startHue8;
+  for( byte y = 0; y < kMatrixHeight; y++) {
+    lineStartHue += yHueDelta8;
+    byte pixelHue = lineStartHue;      
+    for( byte x = 0; x < kMatrixWidth; x++) {
+      pixelHue += xHueDelta8;
+      leds[ XY(x, y)]  = CHSV( pixelHue, 255, 255);
+    }
+  }
+}
+
+void Test()
+{
+  FastLED.clear();
+  set_led_rgb(1, 1, 255, 0, 0);
+  set_led_rgb(2, 1, 0, 255, 0);
+  set_led_rgb(2, 1, 0, 0, 255);  
+}
+
+void ShowPotValue()
+{
+  int val = analogRead(PIN_BRIGHTNESS);
+  int numLedsToLight = map(val, 0, 1023, 0, 200);
+
+  FastLED.clear();
+    for(int led = 0; led < numLedsToLight; led++) { 
+      leds[led] = CRGB::Blue; 
+    }
+  FastLED.show();
+}
+
 void ShowGoomba()
 {
+  FastLED.clear();
   // Shows a Goomba, see https://raw.githubusercontent.com/cbries/rgbwall/master/Photos,%20Images,%20Videos/Goomba01.jpg
   set_led_rgb(0, 0, 13, 9, 7);  set_led_rgb(1, 0, 13, 5, 0);  set_led_rgb(2, 0, 8, 3, 0); set_led_rgb(3, 0, 5, 2, 1); set_led_rgb(4, 0, 5, 4, 4); set_led_rgb(5, 0, 7, 3, 0); set_led_rgb(6, 0, 10, 4, 0);  set_led_rgb(7, 0, 13, 5, 0);  set_led_rgb(8, 0, 13, 5, 0);  set_led_rgb(9, 0, 13, 5, 0);  set_led_rgb(10, 0, 13, 5, 0); set_led_rgb(11, 0, 13, 5, 0); set_led_rgb(12, 0, 11, 4, 0); set_led_rgb(13, 0, 8, 3, 0);  set_led_rgb(14, 0, 5, 4, 4);  set_led_rgb(15, 0, 5, 3, 1);  set_led_rgb(16, 0, 7, 2, 0);  set_led_rgb(17, 0, 13, 5, 0); set_led_rgb(18, 0, 13, 8, 5); set_led_rgb(19, 0, 14, 11, 10);
   set_led_rgb(0, 1, 13, 5, 0);  set_led_rgb(1, 1, 13, 5, 0);  set_led_rgb(2, 1, 13, 5, 0);  set_led_rgb(3, 1, 13, 6, 2);  set_led_rgb(4, 1, 13, 12, 10);  set_led_rgb(5, 1, 2, 2, 2); set_led_rgb(6, 1, 5, 2, 0); set_led_rgb(7, 1, 13, 5, 0);  set_led_rgb(8, 1, 13, 5, 0);  set_led_rgb(9, 1, 13, 5, 0);  set_led_rgb(10, 1, 13, 5, 0); set_led_rgb(11, 1, 13, 5, 0); set_led_rgb(12, 1, 7, 3, 0);  set_led_rgb(13, 1, 0, 0, 0);  set_led_rgb(14, 1, 13, 12, 9);  set_led_rgb(15, 1, 13, 8, 4); set_led_rgb(16, 1, 13, 5, 0); set_led_rgb(17, 1, 13, 5, 0); set_led_rgb(18, 1, 13, 5, 0); set_led_rgb(19, 1, 13, 6, 1);

      i = (y * kMatrixWidth) + x;
    }
  }
  
  return i;
}



uint16_t XYsafe( uint8_t x, uint8_t y)
{
  if ( x >= kMatrixWidth) return -1;
  if ( y >= kMatrixHeight) return -1;
  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);

  switch(currentMode)
  {
    case 0: ShowGoomba(); break;
    case 1: Test(); break;
    case 2: ShowPotValue(); break;
    case 3: RainbowA(); break;
  }

  FastLED.show();
  FastLED.setBrightness(newBrightness);
}

void set_led_rgb(int x, int y, int r, int g, int b)
