// RGB LED Farbwechsel über Poti einstellen
// erweitert durch weiss am 06.08.2021 durch corvintaurus.de
#include <LiquidCrystal.h>
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int redPin = 11;
int bluePin = 10;
int greenPin = 9;
int whitePin = 8;
int redIn = 3;
int greenIn = 2;
int blueIn = 1;
int whiteIn = 0;
int redVal;
int greenVal;
int blueVal;
int whiteVal;
void setup()
{
Serial.begin(9600);
pinMode(redIn, OUTPUT);
pinMode(greenIn, OUTPUT);
pinMode(blueIn, OUTPUT);
pinMode(whiteIn, OUTPUT);
lcd.begin(16, 2);
Serial.begin(9600);
}
void loop()
{
redVal = analogRead(redIn);
lcd.print(redVal);
lcd.print("-rt ");
lcd.setCursor(0,0);
greenVal = analogRead(greenIn);
lcd.print(greenVal);
lcd.print("-gn ");
lcd.setCursor(8,0);
blueVal = analogRead(blueIn);
lcd.print(blueVal);
lcd.print("-bl ");
lcd.setCursor(8,1);
whiteVal = analogRead(whiteIn);
lcd.print(whiteVal);
lcd.print("-wh ");
lcd.setCursor(0,1);
redVal = map(redVal, 0, 1023, 0, 255);
greenVal = map(greenVal, 0, 1023, 0, 255);
blueVal = map(blueVal, 0, 1023, 0, 255);
whiteVal = map(whiteVal, 0, 1023, 0, 255);
analogWrite(redPin, redVal);
analogWrite(greenPin, greenVal);
analogWrite(bluePin, blueVal);
analogWrite(whitePin, whiteVal);
delay(1);
Serial.println();
}