#include <FastLED.h>
#define LED_TYPE WS2811
#define COLOR_ORDER RGB
#define BRIGHTNESS 200

#define SOURCE_PIN 4
#define SENSOR_PIN A7
#define RELAY_PIN 5
#define LED_PIN 6

int sensorValue = 0;
CRGB leds[1];


// Slush-Ice Refiller
// Consists of 1 WS2811 status LED, 1 sensor pin and 1 relay for the peristaltic pump
 
void setup() {
  pinMode(SOURCE_PIN, OUTPUT);
  pinMode(RELAY_PIN, OUTPUT);
  Serial.begin(115200);

  FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, 1);
  FastLED.setBrightness(BRIGHTNESS);
  FastLED.clear();
}
 
void loop() {
  digitalWrite(SOURCE_PIN, HIGH);
  digitalWrite(RELAY_PIN, HIGH);


  delay(100);

  sensorValue = analogRead(SENSOR_PIN);
  if (sensorValue < 50) {
      Serial.println(sensorValue);
      digitalWrite(RELAY_PIN, LOW);
      fill_solid( leds, 1, CRGB::Green);
      FastLED.show();
      delay(12000);
  }
  digitalWrite(SOURCE_PIN, LOW);
  digitalWrite(RELAY_PIN, HIGH);
  fill_solid( leds, 1, CRGB::Blue);
  FastLED.show();

  delay(1900);



}
