Hallo Leute,

ich bin am verzweifeln. Ich baue gerade einen UV Belichter aus einem alten Scanner. Diser Code sollte es tun.
Ziel ist ein Display, Ein Buzzer, 2 Relais, 3 Buttons und eine LED wie folgt an zu steuern.
Einschalten am Display wir angezeigt
UV-Belcihter
v0.1 by meddie
Eine kurze Melodie wird am Buzzer abgespielt.
Display wird angezeigt
Belcihtungszeit?

3 Buttons (Up,Down, Start) ermöglichen folgende Bedienung

Up kurz gedrückt erhöht die Belichtungszeit um 5 Sekunden am Display soll angezeigt werden
0 Min 5 Sek
bei jedem weiteren Druck erhöht sich die Zeit um 5 Sekunden
Bei einem Druck länger als 2 Sekunden soll gleich ein Belichtungsvorgang (beide Relais ein und LED ein) mit einer Zeit von 2 Minuten gestartet werden.

Down kurz gedrückt reduziert die Zeit um 5 Sekunden zeigt am Display die restliche Zeit an.
Bei einem Druck länger als 2 Sekunden soll gleich ein Belichtungsvorgang (beide Relais ein und LED ein) mit einer Zeit von 3 Minuten gestartet werden.

Start kurz gedrückt startet den Belichtungsvorgang mit der Zeit die mit Up/Down eingestellt wurde.
Bei einem Druck länger als 2 Sekunden soll gleich ein Belichtungsvorgang (beide Relais ein und LED ein) mit einer Zeit von 30 Minuten gestartet werden.

Wenn Die Belichtung Fertig ist: kurze Melodie Abspielen, Relais ausschalten, LED ausschalten. Im Display "Fertig" anzeigen, 3 Sekunden warten "Belichtungszeit?" anzeigen.

Und so sieht mein Code aus der leider nicht funktioniert. Irgendwie "hängt" er er zeigt nur im Display Belichtungszeit? an und reagiert auf nix. Als ob die Loop-Schleife gar nicht ausgeführt wird

Code:
/*
Arduino UV Exposure Light. Built from 2 (4x9W) UV Nail Lamps placed in an old scanner.
 Controlled by an Arduino Nano. 16x2 Display. A 2 Way Relais Baord 3 Buttons and 
 Buzzer to signal when done.
 The Buttons are 'Up' 'Down' and 'Start'. When you press longer than 2 Seconds 
 that starts a saved time 
 - Up Button 45 Seconds (for Exposure a Soldering Stop Laminate)
 - Down Button 3 Minutes (for exposure a PCB)
 - Start Button 30 Minutes (for exposure a soldering stop laminate to get hard)
 
 The circuit:
 * LCD RS pin to digital pin D0 12
 * LCD Enable pin to digital pin D1 11
 * LCD D4 pin to digital pin D2 5
 * LCD D5 pin to digital pin D3 4
 * LCD D6 pin to digital pin D4 3
 * LCD D7 pin to digital pin D5 2
 * LCD R/W pin to ground
 * Buzzer pin D6
 * Button 1 pin D7
 * Button 2 pin D8
 * Button 3 pin D9
 * Relais 1 pin D10
 * Relais 2 pin D11
 * LED pin D12
 
 */


// include the library code:
// LCD Lib
#include <LiquidCrystal.h>
//ToneLib for Buzzer
#include "pitches.h"


//Variable Declarations
// notes in the melody:
int melody[] = {
  NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3,0, NOTE_B3, NOTE_C4};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
  4, 8, 8, 4,4,4,4,4 };


//Hardware Pins  
const int upPin = 7; //up button pin
const int startPin = 8; //start button pin
const int downPin = 9; //down button pin
int relais1Pin = 10; //relais 1 pin 
int relais2Pin = 11; //relais 2 pin
int buzzerPin = 6; //piezo buzzer pin


//Variables for states
int timerCount = 0; //variable for timer setting
int minutesCount = 0; //minutes value
int secondsCount = 0; //seconds value


int buttonState = 0; 
int lockbyte=0;
int command;
unsigned long time;
int pressed=0;


// initialize the LCD library with the numbers of the interface pins
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);


void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print Version to the LCD.
  lcd.setCursor(0,0);                            //set cursor to the first column and the first line
  lcd.print("UV Belichter");                     //print this text to LCD
  lcd.setCursor(0,1);                            // set cursor to the first column and the second line
  lcd.print("V 0.1 by meddie");                  //print this Text to LCD
  playTone();                                    //Call function playTone this will play a short meldoy
  delay(3000);                                   //wait 3 Seconds the Text will be shown 3 seconds
  lcd.setCursor(0,0);                            //set cursor to column 1 and line 1
  lcd.clear();
  lcd.print("Belichtungszeit?");                 //print this Text on LCD
  pinMode(relais1Pin, OUTPUT);
  pinMode(relais2Pin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
  pinMode(startPin, INPUT);
  digitalWrite(startPin, HIGH);                  //activate PullUp
  pinMode(upPin, INPUT);
  digitalWrite(upPin, HIGH);                     //activate PullUp
  pinMode(downPin, INPUT);
  digitalWrite(downPin, HIGH);                   //aktivate PullUp
  Serial.begin(9600);
}


void loop() {
  //read Up button
  pressed = getButtonState(upPin); //Call Buttonstate Function for upPin
  //if up button pressed increment timer count and print to lcd
  if (pressed == 1 ) // button is pressed less than 2 seconds
  {
    lcd.clear(); //clear screen
    secondsCount = secondsCount+5; //increment in sec intervals
    if (secondsCount == 60) //increment minute & reset sec for every 60 sec
    {
      minutesCount++;
      secondsCount=0;
    }
    lcdWrite(); //print values
    pressed=0;
  }
  if (pressed == 2) // button is pressed lomger than 2 seconds set the uv time to a defined seconds and start exposure
  {
    minutesCount=0;
    secondsCount=5;
    startuv();
    pressed=0;
  }
  //read down Button
  pressed = getButtonState(downPin); //Call ButtonState function for upPin


    //if down button pressed decrement timer count and print to lcd
  if (pressed == 1)
  {
    lcd.clear(); //clear lcd
    secondsCount = secondsCount-5; //decrement minute & reset sec for every 60 sec
    if(minutesCount>0) //if more than a minute left
    {
      if(secondsCount==-5) // reset sec value of -5 to 55 & decrement minute
      {
        secondsCount=55;
        minutesCount--;
      } 
      else
      {
        if(secondsCount<0) //if countdown finished, reset values to zero
        {
          secondsCount = 0;
          minutesCount = 0;
        } 
      }
    }
    lcdWrite();
    pressed=0;
    if(secondsCount<0)
    {
      secondsCount=0;
      lcd.clear();
      lcd.print("0 Min 0 Sek");
    }
  } 
  if (pressed == 2) // button is pressed longer than 2 seconds set the uv time to a defined seconds and start exposure
  {
    minutesCount=0;
    secondsCount=10;
    startuv();
    pressed=0;
  }
  //read start button
  pressed = getButtonState(startPin);
  if (pressed == 1) // button is pressed less than 2 seconds start the exposure with the entered time
  {
    startuv();
    pressed=0;
  }   
  if (pressed == 2) // button is pressed lomger than 2 seconds set the uv time to a defined seconds and start exposure
  {
    minutesCount=0;
    secondsCount=1;
    startuv();
    pressed=0;
  }
}




//if start button pressed activate relais 1 and 2 
//print timer count down to lcd
//activate buzzer to signal end of count
void startuv() {


  timerCount = (minutesCount*60) + secondsCount;
  int timerCount2 = timerCount;
  Serial.println(timerCount);
  for(int i=timerCount;i>0;i--)
  {
    lcd.clear();


    if(timerCount2>60)
    {
      minutesCount = timerCount2/60;
      secondsCount = timerCount2%60; 
    }
    else if(secondsCount==60)
    {
      secondsCount=59; 
    }
    else
    {
      minutesCount = 0;
      secondsCount = timerCount2; 
    }




    lcdWrite();


    //send transistor base pin high
    digitalWrite(relais1Pin, HIGH);
    digitalWrite(relais2Pin, HIGH);
    delay(1000);
    timerCount2--;
  }


  lcd.clear();
  lcd.print("Fertig");


  //turn transistor off
  digitalWrite(relais1Pin, LOW);
  digitalWrite(relais2Pin, LOW);


  //Play Tone on Buzzer
  playTone();
  delay(2000);


  lcd.clear();
  lcd.print("Belcihtungszeit?");


  //reset timer values
  timerCount = 0;
  minutesCount = 0;
  secondsCount = 0;
  command=0;
}


void playTone() {
  // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 8; thisNote++) {


    // to calculate the note duration, take one second 
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000/noteDurations[thisNote];
    tone(buzzerPin, melody[thisNote],noteDuration);


    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(buzzerPin);
  }
}


void lcdWrite()
{
  lcd.setCursor(0, 0); //set cursor to top left
  lcd.print(minutesCount); //print minutes value
  lcd.setCursor(3, 0); //set cursor on other side of minutes value
  lcd.print("Min"); //print min string
  lcd.setCursor(7, 0); //set cursor further right
  lcd.print(secondsCount); //print seconds value
  lcd.setCursor(10,0); //set cursor further right
  lcd.print("Sek"); //print sec string
}


int getButtonState(const int buttonPin){
  buttonState=digitalRead(buttonPin); 
  if((buttonState == LOW) && (lockbyte==0)){ //buttonPin is defined as High, that means that the internal Pull-Up is On. When button is pressed than the buttonPin will change from HIGH to LOW
    time=millis(); // take a time when button is pressed
    lockbyte=1; //lockbyte prevents that the time will stopped on each buttonpress
  }
  if((buttonState == HIGH) && (time+60<=millis()) && (time+2000>millis()) && (lockbyte==1)){ // When Button is pressed longes thab 60ms (debounce) and Button is pressed less than 2000 millis (2 Second), do command "a"
    command=1; //1 = button is pressed less than 2 seconds
    time=0; //reset time to 0
    lockbyte=0; //reset the lockbyte
  }
  if((buttonState == HIGH) && (time+2000<=millis()) && (lockbyte==1)){ //When Button is pressed longer as 2 Seconds do command "b" 
    command=2; //2 = button is pressed longer then 2 seconds
    time=0; // reset time to 0
    lockbyte=0; //reset the lockbyte
  }
  if((time+60>millis()) && (buttonState==HIGH)){ // When Buttons is pressed less than 60ms, then reset lockbyte and time to 0
    lockbyte=0; //reset lockbit to 0
    time=0; //reset time to 0
  }
  return command;
}
Vielleicht kann mir jemand helfen bin am verzweifeln
Danke sehr
Gruß Eddie