int helligkeit;
String farbe;
int dauer;
void setup() {
// put your setup code here, to run once:
pinMode(3,OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("Welche Farbe soll die LED haben? (r/g/b)");
while(!Serial.available()) {}
farbe = Serial.readString();
farbe.trim();
Serial.println("Wie hell soll die LED sein? (0-255)");
while(!Serial.available()) {}
helligkeit = Serial.readString().toInt();
Serial.println("Wie lang soll die LED an sein? (in sek)");
while(!Serial.available()) {}
dauer = Serial.readString().toInt();
if(farbe == "r")
{
analogWrite(3, 255);
delay(dauer*1000);
delay(500);
}
else if(farbe == "g")
{
analogWrite(5, 255);
delay(dauer*1000);
delay(500);
}
else if(farbe == "b")
{
analogWrite(6, 255);
delay(dauer*1000);
delay(500);
}
else
{
Serial.println("error");
Serial.println();
delay(500);
}
}