Reed-Schalter

int taste[]={1,1,1};
int bp[] = {  0, 0, 0};
long int zeitvorg[]={0,0,0};
int nw=0,aw=0,mnw=0,maw=0,ausgja=0,anzs=3,hran;
long int mmin=0, amin=0,smin=0;
String geta=".";
void setup() {  Serial.begin(9600);
    for (int ni = 0; ni< anzs; ni++) {
    pinMode((ni)+2, INPUT_PULLUP);}
    Serial.print(millis());
    Serial.println("Beim ersten Schliessen startet die Messung!");
    Serial.println("Eine neue Messung wird über Pin 4 ausgelöst.");
}
void loop() {
  mmin=millis()-1;
  for (int ni = 0; ni< anzs; ni++) {
    if ((zeitvorg[ni])<mmin){taste[ni] = digitalRead((ni)+2) ;}else{taste[ni]=1;}
 
    if (taste[ni]==0 ){zeitvorg[ni]=mmin+100;bp[ni]+=1;geta =geta+">"+String(ni)+":"+String(bp[ni]);
        if (bp[ni]==1){smin=millis();geta =geta+"Start";}
        if (bp[ni]>1){geta =geta+"_"+String(millis()-smin)+" msec ";}
                      }
    }
    if (taste[2]==0){bp[0]=0;geta ="";Serial.println("neue Messung");}
    if (mmin>amin){
        if (geta.length()>1){Serial.println(geta); amin=mmin+1000; geta="";} 
    }
}

Spannung messen


// These constants won't change.  They're used to give names
// to the pins used:
const int analogInPin = A0;  // Analog input pin that the potentiometer is attached to
const int analogOutPin = 9; // Analog output pin that the LED is attached to
String geta;
int sensorValue = 0;        // value read from the pot
int outputValue = 0;        // value output to the PWM (analog out)

void setup() {
  // initialize serial communications at 9600 bps:
  Serial.begin(9600);
}

void loop() {
  // read the analog in value:
  sensorValue = analogRead(analogInPin);
  // map it to the range of the analog out:
  //outputValue = map(sensorValue, 0, 1023, 0, 50);

geta=geta +String(sensorValue/200)+" ";
  // print the results to the serial monitor:
 if (geta.length()>80){
  Serial.println(geta);geta="";}
 
  delay(1);
}

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);  }
}