 
 Adafruit_NeoPixel strip = Adafruit_NeoPixel(numPixels, pixelPin, NEO_GRB + NEO_KHZ800);
 
-void readSensors()
-{
+int readSensors() {
+
+	int mode = 0;
+
 	sw1Read = digitalRead(sw1Pin);
 	sw2Read = digitalRead(sw2Pin);
 
-	if( !sw1Read && !sw2Read )	{ currentMode = 1; }
-	if( sw1Read && !sw2Read )	{ currentMode = 2; }
-	if( !sw1Read && sw2Read )	{ currentMode = 3; }
-	if( sw1Read && sw2Read )	{ currentMode = 4; }
-}
-
-int setColor(int color)
-{
-	if(color == rnd) { 
+	if(!sw1Read && !sw2Read) mode = 1;
+	if(sw1Read && !sw2Read) mode = 2;
+	if(!sw1Read && sw2Read) mode = 3;
+	if(sw1Read && sw2Read) mode = 4;
+
+	return mode;
+}
+
+void setColor(int color) {
+
+	if(color == rnd) {
 		color1 = random(1,255);
 		color2 = random(1,255);
 		color3 = random(1,255);
 
-		if((color1 + color2 + color3) < minColorIntensity) { setColor(rnd); }
-	}
-
-	if(color == off) { color1 = 0; color2 = 0; color3 = 0; }
-	if(color == white) { color1 = 255; color2 = 255; color3 = 255; }
-	if(color == warmwhite) { color1 = 255; color2 = 147; color3 = 41; }
-	if(color == red) { color1 = 255; color2 = 0; color3 = 0; }
-	if(color == green) { color1 = 0; color2 = 255; color3 = 0; }
-	if(color == blue) { color1 = 0; color2 = 0; color3 = 255; }
-	if(color == yellow) { color1 = 255; color2 = 255; color3 = 0; }
-	if(color == orange) { color1 = 255; color2 = 128; color3 = 0; }
-}
-
-int setAll(int color, int brightness)
-{
+		if((color1 + color2 + color3) < minColorIntensity) setColor(rnd);
+	}
+
+	else if(color == white) { color1 = 255; color2 = 255; color3 = 255; }
+	else if(color == warmwhite) { color1 = 255; color2 = 147; color3 = 41; }
+	else if(color == red) { color1 = 255; color2 = 0; color3 = 0; }
+	else if(color == green) { color1 = 0; color2 = 255; color3 = 0; }
+	else if(color == blue) { color1 = 0; color2 = 0; color3 = 255; }
+	else if(color == yellow) { color1 = 255; color2 = 255; color3 = 0; }
+	else if(color == orange) { color1 = 255; color2 = 128; color3 = 0; }
+	else { color1 = 0; color2 = 0; color3 = 0; }
+}
+
+void setAll(int color, int brightness) {
+
 	if(currentMode != previousMode) {
 		setColor(color);
-		for(int a = 0; a <= numPixels; a++) {
-			strip.setPixelColor(a, color1, color2, color3);	
+		for(int a = 0; a < numPixels; a++) {
+			strip.setPixelColor(a, color1, color2, color3);
 		}
 		strip.setBrightness(brightness);
 		strip.show();

	http://etsy.com/shop/Tinkerlight
	http://bnaucler.se

	Absolutely no rights reserved.
	Feel free to copy and modify the code to your liking.
	I'm curious to see what you come up with!

	TODO:
	* More modes!
		Disco?
	* Enum for brightness levels?
	* Improve flame mode by individual pixel movement?
		Or merge with glow?
	* Reduce code footprint for 'twinkle' and 'increase'

*/

#include <Adafruit_NeoPixel.h>

// Pin definitions
const int		pixelPin = 7;
const int		sw1Pin = 2;
const int		sw2Pin = 8;

// Global constants
const int		modes = 4;					// Number of modes - static
const int		numPixels = 13;				// Number of pixels - static
const int		maxBrightness = 255;
const int		minBrightness = 0;
const int		minColorIntensity = 150;	// When randomly selecting color 

const boolean	moreRandom = true;			// Set to true for more color change

// 'Worm' mode constants
const int		wormInterval = 300;			// Worm speed

const int		twinklePauseInterval = 100;	// Time to pause at max and min

// Switch states
bool			sw1Read, sw2Read;

// Variable declarations
int				currentMode = 1, previousMode = 2;
