#include <ESP32Servo.h>
#include <Adafruit_NeoPixel.h>
const int numFlowers = 18;
//LED Set up
const int bitLED = 7;
const int numLEDs = bitLED*numFlowers;
// #define LEDType WS2812B
const int brightness = 20;
const int ledPin = 15;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(numLEDs, ledPin, NEO_GRB + NEO_KHZ800);
// CRGB leds[numLEDs];
// int clockPin = 6;
//Servo Set up
int servoPins[numFlowers] = {32, 33, 25, 26, 27, 14, 12, 13, 2, 0, 4, 16, 17, 5, 18, 19, 21, 22};
Servo servos[numFlowers];
int servoOnTable[numFlowers];
void setup() {
// put your setup code here, to run once:
// Serial.begin(115200);
// Serial.println("Hello, ESP32!");
strip.begin();
strip.show();
// strip.setBrightness(brightness);
// for(int i = 0; i<numFlowers;i++){
// servoOnTable[i] = 0;
// }
// //Attach all the servos + LEDs
// for(int i = 0; i<numFlowers; i++){
// servos[i].attach(servoPins[i]);
// servos[i].write(0);
// // for(int j = 0; j<bitLED; j++){
// // leds[i*bitLED+j] = CRGB::Red;
// // }
// }
// FastLED.show();
}
void loop() {
colorWipe(strip.Color(255, 0, 0), 30);
delay(200);
colorWipe(strip.Color(0, 255, 0), 30);
/*
//Get input data
while(!Serial.available());
String input = Serial.readStringUntil('\n');
//Split up input data to flower number and function
String strNum = input.substring(0, 2);
int num = strNum.toInt();
String func = input.substring(2);
//Check if num is in range
if((num > (numFlowers-1)) || (num < 0)){
Serial.write("Invalid Number");
}
else{
//Change color and servo position based on input
if(input.equals("happy")){
leds[num][0] = CRGB(178, 223, 198);
FastLED.show();
servos[num].write(180);
}
else if(input.equals("content")){
leds[num][0] = CRGB(254, 221, 196);
FastLED.show();
servos[num].write(180);
}
else if(input.equals("anxious")){
leds[num][0] = CRGB(255, 171, 215);
FastLED.show();
servos[num].write(180);
}
else if(input.equals("sad")){
leds[num][0] = CRGB(193, 239, 251);
FastLED.show();
servos[num].write(180);
}
else if(input.equals("irritable")){
leds[num][0] = CRGB(255, 172, 174);
FastLED.show();
servos[num].write(180);
}
else if(input.equals("stressed")){
leds[num][0] = CRGB::Red;
FastLED.show();
servos[num].write(180);
}
else if(input.equals("miserable")){
leds[num][0] = CRGB(228, 199, 247);
FastLED.show();
servos[num].write(180);
}
//INCLUDE WAY TO CHECK IF FLOWER IS OPEN/CLOSE
else if(input.equals("off")){
leds[num][0] = CRGB::Black;
FastLED.show();
servos[num].write(0);
}
}
*/
}
void colorWipe(uint32_t c, uint8_t t){
for(uint16_t i = 0; i<strip.numPixels(); i++){
strip.setPixelColor(i, c);
strip.show();
delay(t);
}
strip.show();
}