LCD - Display

#include <Wire.h> // Wire Bibliothek einbinden
#include <LiquidCrystal_I2C.h> // Vorher hinzugefügte LiquidCrystal_I2C Bibliothek einbinden
LiquidCrystal_I2C lcd(0x3F, 16, 2); //Hier wird festgelegt um was für einen Display es sich handelt. In diesem Fall eines mit 16 Zeichen in 2 Zeilen und der HEX-Adresse 0x27. Für ein vierzeiliges I2C-LCD verwendet man den Code "LiquidCrystal_I2C lcd(0x27, 20, 4)"
const int sensorMin = 0;      // sensor minimum, discovered through experiment
const int sensorMax = 1024;    // sensor maximum, discovered through experiment

void setup() {
  // initialize serial communication:
lcd.init(); //Im Setup wird der LCD gestartet
lcd.backlight();
}

void loop() {
  // read the sensor:
  int sensorReading = analogRead(A0);
  // map the sensor range to a range of four options:
  int range = map(sensorReading, sensorMin, sensorMax, 0, 3);

  // do something different depending on the
  lcd.setCursor(8, 1);lcd.print( sensorReading);lcd.print(" _");
  switch (range) {
    case 0:    // your hand is on the sensor
      lcd.setCursor(0, 0);lcd.print("000");
      lcd.setCursor(0, 1);lcd.print("____"); 
      break;
    case 1:    // your hand is close to the sensor
      lcd.setCursor(0, 0);lcd.print("111");
      lcd.setCursor(0, 1);lcd.print("____");
      break;
    case 2:    // your hand is a few inches from the sensor
      lcd.setCursor(0, 0);lcd.print("222");
      lcd.setCursor(0, 1);lcd.print("___");
      break;
    case 3:    // your hand is nowhere near the sensor
      lcd.setCursor(0, 0);lcd.print("333");
      lcd.setCursor(0, 1);lcd.print("___");
      break;
  }
  delay(1);        // delay in between reads for stability
}

Bluetooth Modul mit myAPP

#include <SoftwareSerial.h>
SoftwareSerial mySerial(2, 3); // RX, TX
boolean lamp1,lamp2,lamp3,lamp4;
String taste;
int blinkdauer = 4000,blinkdaue2 = 4000,la13;
long int zeitvor1, zeitvor2, zeitvor3, zeitvor4 ;
int melody[] = {262,196,196,220,196,0,247,262};
int noteDurations[] = { 4, 8, 8, 4,4,4,4,4 };
void setup() 
{
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {;  }

pinMode(8, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(12, OUTPUT);
 zeitvor1 = millis();zeitvor2 = millis();zeitvor3 = millis();zeitvor4 = millis();
 lamp1= HIGH;lamp2= HIGH;lamp3= HIGH;lamp4= HIGH;
  Serial.println("Meldungen:");
  // set the data rate for the SoftwareSerial port
  mySerial.begin(9600);
 
}

void loop()
{
  while (mySerial.available()){
    int thisChar  =  mySerial.read();delay(5);
    if((thisChar)==35) {Serial.println(taste+" gewaehlt ");}
    if((thisChar)=='*') {Serial.print(" Taste ");}
    if(isDigit(thisChar)) {taste.concat((char)thisChar);}
    //Serial.print(thisChar);//Serial.print(tastb+".");
  }
 
   if (millis()-zeitvor1>blinkdauer) {lamp1= HIGH;}
   if (millis()-zeitvor2>blinkdauer) {lamp2= HIGH;}
   if (millis()-zeitvor3>blinkdaue2) {lamp3= HIGH;}
   if (millis()-zeitvor4>blinkdaue2) {lamp4= HIGH;}
   //if (analogRead(A0)<500){digitalWrite(4, 1);delay(200);digitalWrite(5, 1);delay(200);digitalWrite(6, 1);delay(200);digitalWrite(7, 1);delay(200);}
  la13=lamp1 +lamp2+lamp3+lamp4;if (la13<4){digitalWrite(13, HIGH);}else {digitalWrite(13, LOW);}
  digitalWrite(5, lamp1);delay(100);digitalWrite(6, lamp2);delay(100);digitalWrite(7, lamp3);delay(100);digitalWrite(8, lamp4);
  if (taste.length()>0) {
   if (taste.length()>1) {taste=taste.substring(1,1);}
    if (taste=="4") {lamp1= LOW;zeitvor1 = millis();tone(12, 440, 200);}
    if (taste=="7") {lamp4= LOW;zeitvor4 = millis();tone(12,  880, 200);}
    if (taste=="3") {blinkdauer=blinkdauer+2000;}
    if (taste=="2" and blinkdauer >1000) {blinkdauer=blinkdauer-1000;}
    if (taste=="5") {lamp2= LOW;zeitvor2 = millis();tone(12, 585, 200);}
    if (taste=="6") {lamp3= LOW;zeitvor3 = millis();tone(12,659, 200);}
    if (taste=="9") {blinkdaue2=blinkdaue2+2000;}
    if (taste=="8"and blinkdaue2 >1000) {blinkdaue2=blinkdaue2-1000;}
    Serial.print(lamp1);
    Serial.print(lamp2);Serial.print(lamp3);Serial.print(lamp4);Serial.print("__");
    Serial.print(blinkdauer);Serial.print(blinkdaue2);Serial.print("_");Serial.println(millis());//Serial.print(la13);
    taste="";
  }
}
void musik()
{ for (int thisNote = 0; thisNote < 8; thisNote++) {
    int noteDuration = 1000/noteDurations[thisNote];
    tone(8, melody[thisNote],noteDuration);
    delay(noteDuration * 1.30); noTone(8);  }
}