// Arduino Uno R4 WiFi LESSON 17: Control Multiple LED from the Serial Monitor
// https://www.youtube.com/watch?v=Ai7uqYHt_Yc&list=PLGs0VKk2DiYyn0wN335MXpbi3PRJTMmex&index=18
// homework - red green yellow LED, ask user which user to turn on and brightness

//in progressd

#include <Arduino.h>

int redLED = 11;
int greenLED = 10;
int yellowLED = 9;
int baudRate = 9600;
String promptColor = ("which LED (red, green, yellow) do you want to switch?");
String promptBright = ("Set brightness (0-10)");

String myColor;    //selected LED
int userBright;    //brightness from user
int writeBright;    //calculated value of brightness


void setup() {
    Serial.begin(baudRate);
    pinMode(redLED,OUTPUT);
    pinMode(greenLED,OUTPUT);
    pinMode(yellowLED,OUTPUT);    

}

void loop() {
    //digitalWrite(redLED,HIGH);

    //user input
    Serial.println(promptColor);
    while (Serial.available()==0)
    {
        /* code */
    }
    myColor=Serial.readString();
    myColor.toLowerCase();
    Serial.print("your chosen color is: ");
    Serial.println(myColor);

    Serial.println(promptBright);
    while (Serial.available()==0)
    {
        /* code */
    }
    userBright=Serial.parseInt();
    Serial.print("you desired level of brightness is: ");
    Serial.println(userBright);

//red LED
    if (myColor=="red"){

    writeBright=pow(2,(8./10.)*userBright)-1;
    
    Serial.print("brightness value: ");
    Serial.println(writeBright);
    
    analogWrite(redLED,writeBright);
    }
    
//green LED
    if (myColor=="green"){

    writeBright=pow(2,(8./10.)*userBright)-1;
    
    Serial.print("brightness value: ");
    Serial.println(writeBright);
    
    analogWrite(greenLED,writeBright);
    }

//yellow LED
    if (myColor=="yellow"){

    writeBright=pow(2,(8./10.)*userBright)-1;
    
    Serial.print("brightness value: ");
    Serial.println(writeBright);
    
    analogWrite(yellowLED,writeBright);
    }   

    
}
$abcdeabcde151015202530354045505560fghijfghij