#include <LiquidCrystal_I2C.h> //Library für LCD I2C
#include <Wire.h> //Library für I2C
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int ledrot = 3;
const int ledblau = 2;
const int RGBrot = 4;
const int RGBgrun = 5;
const int RGBblau = 6;
const int swein = 7;
const int swaus = 8;
int potiwert = 0;
int pwmwert = 0;
int prozent = 0;
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Motor Steuerung");
lcd.setCursor(6, 1);
lcd.print("LG55");
delay(1000);
lcd.clear();
pinMode (ledrot, OUTPUT);
pinMode (ledblau, OUTPUT);
pinMode (RGBrot, OUTPUT);
pinMode (RGBgrun, OUTPUT);
pinMode (RGBblau, OUTPUT);
pinMode (swein, INPUT_PULLUP);
pinMode(swaus, INPUT_PULLUP);
}
void loop() {
if (digitalRead(swein) == LOW)
{
potiwert = analogRead(A7);
pwmwert = map(potiwert, 0, 1023, 0, 255);
prozent = map(pwmwert, 0, 255, 0, 100);
digitalWrite(ledrot, HIGH);
digitalWrite(ledblau, LOW);
lcd.setCursor(0, 0);
lcd.print("Motor ein");
lcd.setCursor(0, 1);
lcd.print("prozent: %");
lcd.setCursor(9, 1);
lcd.print(prozent);
if ((prozentwert>0) && (pwmwert<=50))
}
else
{
digitalWrite(ledrot, LOW);
digitalWrite(ledblau, HIGH);
lcd.setCursor(0, 0);
lcd.print("Motor aus");
lcd.setCursor(0, 1);
lcd.print(" ");
}
}
void setRGB(int valrot, int valgrun, int valblau)
{
digitalWrite(RGBrot, valrot);
digitalWrite(RGBblau, valblau);
digitalWrite (RGBgrun, valgrun);
}