#include <Adafruit_NeoPixel.h> //Neopixel library.
int Power = 11; //LED Neopixel Voltage
int PIN = 12; //LED Neopixel Signal
#define NUMPIXELS 1 //Number of Neopixel LED's
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); //Neopixel configuration
void setup() {
pixels.begin(); //We need to called the begin() method to set up the Neopixel
pinMode(Power,OUTPUT); //Since the neopixel is an LED, its established as an output
pinMode(D1, INPUT); //D1, D8, D9 and D10 are butttons, therefore they're established as inputs
pinMode(D8, INPUT);
pinMode(D9, INPUT);
pinMode(D10, INPUT);
}
void loop() {
if (digitalRead(D8)==HIGH){ //IF is a statment that checks a condition, if this condition is "True" it run's the sequence
digitalWrite(Power, HIGH);//Indicating that my neopixel LED must be turn on if the condition of the if is met
pixels.clear(); //As the name indicates, this command clears the neopixel
pixels.setPixelColor(0, pixels.Color(0, 255, 0)); //Once its clear this command establishes the color
delay(400);
pixels.show(); //Everytime something is changed in the neopixel it must be sent to the neopixel. This queue the changes in the neopixel and the it push them all at once
}
if (digitalRead(D9)==HIGH){
digitalWrite(Power, HIGH);
pixels.clear();
pixels.setPixelColor(0, pixels.Color(255, 255, 255));
delay(400);
pixels.show();
}
if(digitalRead(D10)==HIGH){
digitalWrite(Power, HIGH);
pixels.clear();
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
delay(400);
pixels.show();
}
if(digitalRead(D1)==HIGH){
digitalWrite(Power, LOW); //This turns off the Neopixel
}
}