#include <Adafruit_NeoPixel.h>
#include <neoPixel.h>
neoPixel thePixel(1, 2); // We got one pixel on pin 2.
colorMultiMap ourColors; // Create our empty color map.
mapper percentMap(0,1023,0,100); // Create our analog to percent mapper.
void setup() {
thePixel.begin(); // Fire up the adafruit stuff.
ourColors.addColor(0,&green); // Adding colors(%,color);
ourColors.addColor(40,&green);
ourColors.addColor(60,&yellow);
ourColors.addColor(80,&yellow);
ourColors.addColor(90,&red);
}
void loop(){
int rawValue;
float percent;
colorObj aColor;
rawValue = analogRead(A0); // Read the analog value.
percent = percentMap.map(rawValue); // Convert this value into a percent.
aColor = ourColors.map(percent); // Map this percent to a color.
thePixel.setPixelColor(0,&aColor); // Set the pixel to that color.
thePixel.show(); // Show our results.
}