//Version No.1 of the ARC Reactor lamp V2, conisting only of the
//basics, testing the neopixels and the circuit

//Declaring all the libreries
#include <Adafruit_NeoPixel.h>
#define NUM_LEDS 11     //Quantity of neopixels used
#define PIN 7           //Pin assigned to the neopixels

//Declaring variables

int CURRENT = A0;
int VOLTAGE;
int MODE;
int NEOS = 10;
int i;
int COUNTER;
float COUNTER2;


//Declare the name of the neopixel stripe
Adafruit_NeoPixel pixels(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);

void setup(){
  Serial.begin(9600); //Serial monitor initialization
  pinMode(CURRENT, INPUT);
  pixels.begin();
}

void loop(){
  //Reading the voltage of the potentiometer
  VOLTAGE = analogRead(CURRENT);


  //Depending on the position of the potentiometer a different color
  //setup becomes active:
  //Off
  //Sky blue version
  //White light
  //Emergency red

  if(VOLTAGE < 256){
    for(i = NEOS; i >= 0; i--){
  pixels.setPixelColor(i, pixels.Color(0, 0, 0));
  pixels.show();
    }
  }
  
  
  else if(VOLTAGE > 256 && VOLTAGE < 512){
     for(i = NEOS; i >= 0; i--){
  pixels.setPixelColor(i, pixels.Color(21, 175, 229));
  pixels.show();
  }
  }

  else if(VOLTAGE > 512 && VOLTAGE < 768){
     for(i = NEOS; i >= 0; i--){
  pixels.setPixelColor(i, pixels.Color(250, 250, 250));
  pixels.show();
  }
  }
  
  else if(VOLTAGE > 768 && VOLTAGE < 1023){
  if(COUNTER == 0){
  for(i = NEOS; i >= 0; i--){
  pixels.setPixelColor(i, pixels.Color(210, 6, 6));
  pixels.show();
  }
  COUNTER = 1;
  delay(1000);
  
  if(COUNTER == 1){
  for(i = NEOS; i >= 0; i--){
  pixels.setPixelColor(i, pixels.Color(0, 0, 0));
  pixels.show();
     }
  COUNTER = 0;
  delay(1000);
  
  }
  }
  }

  Serial.println(VOLTAGE); //Feedback
}
