#include <Adafruit_NeoPixel.h> // plugin for the Neopixel library
int dataPin = 13; //what pin dose the LED data cable connect to on the board eg.D6
#define numberOfPixels 2 //how meny NeoPixels are on the Led strip
#define maximumBrightness 255 //the maximum brightness of the pixel is 255
//any higher you will damagethem, lower the brightness to increase batttry life
Adafruit_NeoPixel ledStrip = Adafruit_NeoPixel(numberOfPixels, dataPin); //over here we are telling the controller that we have a "ledStrip"
int Pot = A0; //What pin is the pot on.
int PotVal = 0; // Set pot to 0 //that has amount of pixels "numberOfPixels" eg 255
//connected to pin "dataPin" on the board eg 6
void setup()
{
ledStrip.begin(); // This tells the led strip to wakeup becouse its going to do things now.
Serial.begin(9600);
}
void loop()
{
//customLight();
PotVal = analogRead(Pot);
Serial.println(PotVal);
int mode = map(PotVal, 0, 1023, 0, 7); //this calls the "customLight" method
switch (mode) {
case 0:
setLightsToColour(0,0,255);
Serial.print("Tank Is Good");
Serial.print(",POT Value: ");
break;
case 1:
setLightsToColour(51,221,255);
Serial.print("Water Level too low");
Serial.print(",POT Value: ");
break;
case 2:
setLightsToColour(247,255,28);
Serial.print("Alk Too low");
Serial.print(",POT Value: ");
break;
case 3:
setLightsToColour(255,0,0);
Serial.print("Alk too high");
Serial.print(",POT Value: ");
break;
case 4:
setLightsToColour(255,0,0);
Serial.print("Tank Is Good");
Serial.print(",POT Value: ");
break;
case 5:
setLightsToColour(255,0,0);
Serial.print("Tank Is Good");
Serial.print(",POT Value: ");
break;
case 6:
setLightsToColour(255,140,25);
Serial.print("Tank Is Good");
Serial.print(",POT Value: ");
break;
default:
ledStrip.setPixelColor(0, ledStrip.Color(255, 0, 0));
ledStrip.show();
delay(500);
ledStrip.setPixelColor(0, ledStrip.Color(0, 0, 0));
ledStrip.show();
delay(500);
Serial.println("Emergncy");
}
//void customLight() // this is the "customLight" method, think of it as some type of box that groups tasks together
// {
// setLightsToColour(25,200,20); // this is calling the "SetLightsToColour" method,it needs to know how much Red ,Blue and Green Light
// to add to each pixel this is known as RGB colour so we are sending it.(255 red,200 green,0 blue)
// }
}
void setLightsToColour(int red, int green, int blue) //this is the "setLightsToColour" method, it needs 3 values for (red,green,blue) so it knows how much to add to each one
{
for (uint8_t i = 0; i < numberOfPixels; i++) // this makes sure that every pixel gets its colour changed from 0 to "numberOfPixels"
{
ledStrip.setPixelColor(i, ledStrip.Color(red, green, blue)); // this is telling the led pixel to change its red green blue to what you have given "setLightToColour()" method
}
ledStrip.show(); // this tells the ledStrip to show the changes
}