#include <wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const int potiPin = A0;
const int ledPin = 13;
const int rgbRed = 6;
const int rgbGreen = 5;
const int rgbBlue = 3;
const int buttonPin = 7;
const int switchPin = 8;
const int TrigPin = 9;
const int echoPin = 10;
const int servoPin = 11;
Servo myservo;
//Variablen
bool buttonState = false; //status für den Taster
long duration;
int distance;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Arduino Mega");
//pin als Input und Output
pinMode(potiPin; INPUT);
pinMode(ledPIn; OUTPUT);
pinMode(rgbRed, OUTPUT);
pinMode(rgbGreen, OUTPUT);
pinMode(rgbBlue, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
pinMode (switchPin, INPUT_PULLUP);
pinMode (trigPin, OUTPUT);
pinMode(echoPin, INPUT);
myServo.attach(servoPin);
}
void loop() {
int potiValue =
analogRead(potiPin);
int servoAngle = map(potiValue, 0, 1023, 0, 180);
myServo.write(servoAngle);
//abstand messen
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite((trigPin, HIGH));
}