Need help to To open another vitrual screen using clock/time from arduino

Hello everyone
i need help I'm working on a drink bartender with arduino.
I've managed both code and app but can't solve my problem with clock/timer and call data by bluetooth from arduino
I would like it so that when the arduion is done with a mixed one, it should close the virtual screen and open a new one, but it seems that no matter what I try, it does it either at a completely random time or not at all. Hope you can help. Tried all the things I could find online

Hello Jens

We need to see your Arduino Sketch - please upload the file.

//drinkmixer v,1,0

#include <FastLED.h> //led strip
#include <SoftwareSerial.h> /to bluetooth
//SoftwareSerial EEBlue(0, 1); // RX | TX

//relæ udgange
int Vodka = 22; //vodka relæ 1
int Gin = 24; //Gin relæ 2
int JagerMesiter = 26; //jågermesiter relæ 3
int Morgon = 28; //captain morgan relæ 4
int Malibu = 30; //malibu relæ 5
int MangoSirup = 32; //mango sirup relæ 6
int LemonSirup = 34; //lemon sirup relæ 7
int Ambon = 36; //kungfu sirup relæ 8
int OrangeJuice = 31; //appelsinjuice relæ 9
int RedSoda = 33; //rødsodavand relæ 10
int LemonSoda = 35; //lemon sodavand relæ 11
int Cola = 37; //coca cola relæ 12
int Tonic = 38; //tonic relæ 13
int state = 0;
int TimeBetweenPours = 500; //tid mellem pumper

//led lys styring
#define NUM_LEDS 31 //numbers of leds
#define DATA_PIN 6 // led data pin
#define COLOR_ORDER GRB //Green (G), Red (R), Blue (B)
#define CHIPSET WS2812B //5 volt leds
#define BRIGHTNESS 60 //hold under 60 on test
#define VOLTS 5 //max 5 volts!
#define MAX_AMPS 3000 //value in milliamps
int s_delay = 02; //tid på led skift
int e_delay = 500; //tid efter mix
CRGB leds[NUM_LEDS];

void setup(){
Serial.begin(9600); //start på bluetooth kode 1234
//led lys
FastLED.addLeds<CHIPSET,DATA_PIN,COLOR_ORDER>(leds,NUM_LEDS);
FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS,MAX_AMPS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();
for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(500);
}

// relæer
pinMode(22, OUTPUT); //vodka
pinMode(24, OUTPUT); //gin
pinMode(26, OUTPUT); //jagermiester
pinMode(28, OUTPUT); //morgon
pinMode(30, OUTPUT); //malibu
pinMode(32, OUTPUT); //mangosirup
pinMode(34, OUTPUT); //lemon sirup
pinMode(36, OUTPUT); //Ambon
pinMode(31, OUTPUT); //appelsinjuice
pinMode(33, OUTPUT); //rød sodavand
pinMode(35, OUTPUT); //lemon sodavand
pinMode(37, OUTPUT); //coca cola
pinMode(38, OUTPUT); //tonic

//for slukke alle pumper
digitalWrite(22,HIGH);
digitalWrite(24,HIGH);
digitalWrite(26,HIGH);
digitalWrite(28,HIGH);
digitalWrite(30,HIGH);
digitalWrite(32,HIGH);
digitalWrite(34,HIGH);
digitalWrite(36,HIGH);
digitalWrite(31,HIGH);
digitalWrite(33,HIGH);
digitalWrite(35,HIGH);
digitalWrite(37,HIGH);
digitalWrite(38,HIGH);
}

void loop(){

//normal tilstand
for (int i=0; i<10; i++) {
leds[i] = CRGB(0,0,255);
delay(s_delay);
FastLED.show(); }
for (int i=10; i<20; i++) {
leds[i] = CRGB(0,255,0);
delay(s_delay);
FastLED.show(); }
for (int i=20; i<31; i++) {
leds[i] = CRGB(0,0,255);
delay(s_delay);
FastLED.show(); }

if(Serial.available() > 0){ // Checks whether data is comming from the serial port
state = Serial.read(); // Reads the data from the serial port
Serial.println(state);
}

// Cocktails:

//Gin og tonic
if (state == 'A') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(0,20000,0,0,0,0,15000,0,0,0,0,0,3500);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// Gin hass
if (state == 'B') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(0,18000,0,0,0,15000,0,0,0,0,6000,0,0);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// filur
if (state == 'C') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(18000,0,0,0,0,0,0,0,4000,3000,0,0,0);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// brandbil med udrykning
if (state == 'D') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(18000,0,15000,0,0,0,0,0,0,4000,0,0,0);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// brandbil uden rykning
if (state == 'E') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(0,0,15000,0,0,0,0,0,0,4500,0,0,0);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// cola og malibu
if (state == 'F') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(0,0,0,0,18000,0,0,0,0,0,0,5000,0);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// cola og morgon
if (state == 'G') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(0,0,0,18000,0,0,0,0,0,0,0,5000,0);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// kungfu
if (state == 'H') {

for (int i=0; i<31; i++) {
leds[i] = CRGB(255,0,0);
delay(s_delay);
FastLED.show(); }

Mix(0,0,15000,0,0,0,0,15000,0,0,0,4500,0);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

for (int i=0; i<31; i++) {
leds[i] = CRGB(0,255,0);
delay(e_delay);
FastLED.show(); }

// service menu

// Set-up alle
if (state == 'I') {

Mix(4500,4500,3000,4500,4000,4500,4000,4000,500,500,500,500,500);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}

// Set-up Vodka
if (state == 'J') {

digitalWrite(Vodka, LOW);
delay(4500);
digitalWrite(Vodka, HIGH);
}

// Set-up Gin
if (state == 'K') {

digitalWrite(Gin, LOW);
delay(4500);
digitalWrite(Gin, HIGH);
}

// Set-up JagerMesiter
if (state == 'L') {

digitalWrite(JagerMesiter, LOW);
delay(3000);
digitalWrite(JagerMesiter,HIGH);
}

// Set-up Morgon
if (state == 'M') {

digitalWrite(Morgon, LOW);
delay(4500);
digitalWrite(Morgon, HIGH);
}

// Set-up Malibu
if (state == 'N') {

digitalWrite(Malibu, LOW);
delay(4000);
digitalWrite(Malibu, HIGH);
}

// Set-up MangoSirup
if (state == 'O') {

digitalWrite(MangoSirup, LOW);
delay(4500);
digitalWrite(MangoSirup, HIGH);
}

// Set-up LemonSirup
if (state == 'P') {

digitalWrite(LemonSirup, LOW);
delay(4000);
digitalWrite(LemonSirup, HIGH);
}

// Set-up Ambon
if (state == 'Q') {

digitalWrite(Ambon, LOW);
delay(4000);
digitalWrite(Ambon, HIGH);
}

// Set-up OrangeJuice
if (state == 'R') {

digitalWrite(OrangeJuice, LOW);
delay(500);
digitalWrite(OrangeJuice, HIGH);
}

// Set-up RedSoda
if (state == 'S') {

digitalWrite(RedSoda, LOW);
delay(500);
digitalWrite(RedSoda, HIGH);
}

// Set-up LemonSoda
if (state == 'T') {

digitalWrite(LemonSoda, LOW);
delay(500);
digitalWrite(LemonSoda, HIGH);
}

// Set-up Cola
if (state == 'U') {

digitalWrite(Cola, LOW);
delay(500);
digitalWrite(Cola, HIGH);
}

// Set-up Tonic
if (state == 'V') {

digitalWrite(Cola, LOW);
delay(500);
digitalWrite(Cola, HIGH);
}

// rengørnings progam
if (state == 'W') {

Mix(5000,5000,5000,5000,5000,5000,5000,5000,1000,1000,1000,1000,1000);
// Vodka,Gin,JagerMesiter,Morgon,Malibu,MangoSirup,LemonSirup,Ambon,OrangeJuice,RedSoda,LemonSoda,Cola,Tonic
}
}

void Mix (int DelayTimeVodka, int DelayTimeGin, int DelayTimeJagerMesiter, int DelayTimeMorgon, int DelayTimeMalibu, int DelayTimeMangoSirup, int DelayTimeLemonSirup, int DelayTimeAmbon, int DelayTimeOrangeJuice, int DelayTimeRedSoda, int DelayTimeLemonSoda, int DelayTimeCola, int DelayTimeTonic){

state = 0;
delay(800);
digitalWrite(Vodka, LOW);
delay(DelayTimeVodka);
digitalWrite(Vodka, HIGH);
delay(TimeBetweenPours);

digitalWrite(Gin, LOW);
delay(DelayTimeGin);
digitalWrite(Gin, HIGH);
delay(TimeBetweenPours);

digitalWrite(JagerMesiter, LOW);
delay(DelayTimeJagerMesiter);
digitalWrite(JagerMesiter, HIGH);
delay(TimeBetweenPours);

digitalWrite(Morgon, LOW);
delay(DelayTimeMorgon);
digitalWrite(Morgon, HIGH);
delay(TimeBetweenPours);

digitalWrite(Malibu, LOW);
delay(DelayTimeMalibu);
digitalWrite(Malibu, HIGH);
delay(TimeBetweenPours);

digitalWrite(MangoSirup, LOW);
delay(DelayTimeMangoSirup);
digitalWrite(MangoSirup, HIGH);
delay(TimeBetweenPours);

digitalWrite(LemonSirup, LOW);
delay(DelayTimeLemonSirup);
digitalWrite(LemonSirup, HIGH);
delay(TimeBetweenPours);

digitalWrite(Ambon, LOW);
delay(DelayTimeAmbon);
digitalWrite(Ambon, HIGH);
delay(TimeBetweenPours);

digitalWrite(OrangeJuice, LOW);
delay(DelayTimeOrangeJuice);
digitalWrite(OrangeJuice, HIGH);
delay(TimeBetweenPours);

digitalWrite(RedSoda, LOW);
delay(DelayTimeRedSoda);
digitalWrite(RedSoda, HIGH);
delay(TimeBetweenPours);

digitalWrite(LemonSoda, LOW);
delay(DelayTimeLemonSoda);
digitalWrite(LemonSoda, HIGH);
delay(TimeBetweenPours);

digitalWrite(Cola, LOW);
delay(DelayTimeCola);
digitalWrite(Cola, HIGH);
delay(TimeBetweenPours);

digitalWrite(Tonic, LOW);
delay(DelayTimeTonic);
digitalWrite(Tonic, HIGH);

Serial.println("done");
state = 0;
}

Fix that variable reference in the clock timer

what part of it does i need to fix ?

f7e9293c000d8dc4e87f19049273d60fccc2b30c_2_689x339

Did you not see the red X ?

Also, the '0' processing test needs to be inside the section that just received new text, to prevent it being repeated unnecessarily.