   }
 };
 
+class Nightlight
+{
+private:
+  byte brightness;
+  int8_t brightnessDelta;
+  
+public:
+  Nightlight()
+    : brightness(10)
+    , brightnessDelta(1)
+  {
+  }
+  
+  void held()
+  {
+    if (brightnessDelta > 0 && brightness == 255) {
+      brightnessDelta = -1;
+    } else if (brightnessDelta < 0 && brightness == 0) {
+      brightnessDelta = 1;
+    }
+    brightness += brightnessDelta;
+    
+    Serial.print("Brightness ");
+    Serial.println(brightness);
+  }
+  
+  void released()
+  {
+    brightnessDelta = -brightnessDelta;
+  }
+  
+  void reset()
+  {
+    brightness = 0;
+    brightnessDelta = 1;
+  }
+  
+  uint32_t colour()
+  {
+    return Adafruit_NeoPixel::Color(brightness, brightness/2, 0);
+  }
+};
+
 Adafruit_NeoPixel pixels(PIXEL_COUNT, PIXEL_PIN); 
 Button button(BUTTON_PIN);
-byte brightness = 10;
-int brightnessDelta = 1;
+Nightlight nightlight;
 byte on = false;
 byte lastHeld = false;
 

    if (on) {
      Serial.println("Turning on");
      for (int i = 0; i != pixels.numPixels(); ++i) {
        pixels.setPixelColor(i, brightness, brightness/2, 0);
      }
    } else {
      Serial.println("Turning off");

#include <Adafruit_NeoPixel.h>

#define PIXEL_PIN   13    // Digital IO pin connected to the NeoPixels.
#define PIXEL_COUNT 22
#define BUTTON_PIN  3

class Button
{
