Help with code

Hello,
I neen your help with my code.Where is the mistake? I made a video: - YouTube and here is my code:

#include<LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#include <EEPROM.h>
#include <OneWire.h>
#include <Wire.h>
#include <DallasTemperature.h>
int Backlight =10;
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

/////////////////////////////////////////////
  int btnSelect = 15;
  int btnDown = 16;
  int btnUp = 17;
//////////////////////////////////////////// 
  boolean btnSound = true;
  byte set1 = 30;
  byte set2 = 30;
  byte set3 = 30;
  byte set4 = 70;
  byte Menu = 0;
  int pump1 = 11;
  int heater = 12;
  int pump2 = 12;
  int Buzzer = 2;
////////////////////////////////////////////
  byte buttonState1 = 0;         
  byte lastButtonState1 = 0;
  byte buttonState2 = 0;         
  byte lastButtonState2 = 0;
  byte buttonState3 = 0;         
  byte lastButtonState3 = 0;
  
void setup() 
{
  lcd.begin(16, 2);
  // Show Intro
  Intro();
///////////////////////////////////////////  
  pinMode(btnSelect, INPUT);
  pinMode(btnDown, INPUT);
  pinMode(btnUp, INPUT);
  pinMode(pump1, OUTPUT);
  pinMode(heater, OUTPUT);
  pinMode(pump2, OUTPUT);
  pinMode(Buzzer, OUTPUT);
}  
//////////////////////////////////////////
void loop ()
{    
 BSelect();
 BUp();
 BDown();
 
 UpdateLCD();
 
 ReadTemperature();
 }
//////////////////////////////////////////
void ReadTemperature()
{
 sensors.setResolution(TEMPERATURE_PRECISION);
 sensors.requestTemperatures(); 
 float temperature1 = sensors.getTempCByIndex(0);
 lcd.setCursor(0,0);
 lcd.print("Katilas  ");
 lcd.print(sensors.getTempCByIndex(0));
 lcd.print((char)223);
 lcd.print("C");
 
 float temperature2 = sensors.getTempCByIndex(1);
 lcd.setCursor(0, 2);
 lcd.print("Boileris ");
 lcd.print(sensors.getTempCByIndex(1));
 lcd.print((char)223);
 lcd.print("C");
} 

void UpdateLCD()
{
  if (Menu == 1)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Katilo siurblys");
    lcd.setCursor(0,1);
    lcd.print("<              >");
    lcd.setCursor(6,1);
    lcd.print(set1);
    lcd.print((char)223);
    lcd.print("C"); 
  } 
 else if (Menu == 2)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Boilerio temperatura");
    lcd.setCursor(0,1);
    lcd.print("<              >");
    lcd.setCursor(6,1);
    lcd.print(set2);
    lcd.print((char)223);
    lcd.print("C");  
  }    
  else if (Menu == 3)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Boilerio siurblys");
    lcd.setCursor(0,1);
    lcd.print("<              >");
    lcd.setCursor(6,1);
    lcd.print(set3);
    lcd.print((char)223);
    lcd.print("C");  
  }   
  else if (Menu == 4)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.print("Aliarmas");
    lcd.setCursor(0,1);
    lcd.print("<              >");
    lcd.setCursor(6,1);
    lcd.print(set4);
    lcd.print((char)223);
    lcd.print("C");
  }    
  else if (Menu == 5)
  {
    WLCD("    Saugoti    ", "   <Saugoti?>");
  }

} 
char WLCD(char line[], char line2[])
{
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.write(line);
    lcd.setCursor(0,1);
    lcd.write(line2);
}
/////////////////////////////////////////////
 void Intro()
{   
  lcd.clear();
  delay(50);
  lcd.setCursor(0,0);
  lcd.print("Termostatas v1.0");
  lcd.setCursor(1,1);
  lcd.print("by Kornelijus");  
  delay(2000);
  
// Load Settings
   set1 =  EEPROM.read(0); 
   set2 = EEPROM.read(1); 
   set3 = EEPROM.read(2); 
   set4 = EEPROM.read(3); 
}
/////////////////////////////////////////////
void clickSound()
{
   digitalWrite(Buzzer, HIGH);
   delay(30);
   digitalWrite(Buzzer, LOW);
}
/////////////////////////////////////////////
void SaveAll()
{
 byte savedN = 0;

 if (set1 != EEPROM.read(0))
{
   EEPROM.write(0, set1); 
   savedN++;
}
  if (set2 != EEPROM.read(1))
{
   EEPROM.write(1, set2); 
   savedN++;
}  
  if (set3 != EEPROM.read(2))
{
   EEPROM.write(2, set3); 
   savedN++;
}
  if (set4 != EEPROM.read(3))
{
   EEPROM.write(3, set4); 
   savedN++;
}
  if (savedN > 0)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.write("6.Save Done:");
    lcd.setCursor(0,1);
    lcd.print(savedN);
    lcd.write(" B Saved.");
    delay(2000);
  }
  if (savedN == 0)
  {
    lcd.clear();
    lcd.setCursor(0,0);
    lcd.write("Nothing Changed");
    lcd.setCursor(0,1);
    lcd.write("Not Saving.");
    delay(2000);
  }
}
/////////////////////////////////////////////
void BSelect()
{
  buttonState1 = digitalRead(btnSelect);
  // compare the buttonState to its previous state
  if (buttonState1 != lastButtonState1) {
    // if the state has changed, increment the counter
    if (buttonState1 == HIGH) 
    {
      
        // Btn Sound
      if (btnSound == true)
      {
        clickSound();
      }
      
      Menu++;
      if (Menu > 5)
      Menu = 0;
    } 
    lastButtonState1 = buttonState1;
    UpdateLCD();
  }
}
/////////////////////////////////////////////
void BDown()
{
  buttonState2 = digitalRead(btnDown);
  // compare the buttonState to its previous state
  if (buttonState2 != lastButtonState2) {
    // if the state has changed, increment the counter
    if (buttonState2 == HIGH) 
    {
      // Btn Sound
      if (btnSound == true)
      {
        clickSound();
      }

      if (Menu == 1)
      {
       if (set1 < 30)
         set1 = 30;
        if (set1 > 30)
         set1--;
      }
      if (Menu == 2)
      {
       if (set2 < 30)
         set2 = 30;
        if (set2 > 30)
         set2--;
       }
      
      // Save?
      if (Menu == 5)
      {
        SaveAll();
      }
      
      if (Menu == 3)
      {
        if (set3 < 30)
         set3 = 30;
        if (set3 > 30)
         set3--;
      }
     if (Menu == 4)
      {
      if (set4 < 70)
         set4 = 70;
        if (set4 > 70)
         set4--;
      }
    } 
    lastButtonState2 = buttonState2;
    UpdateLCD();
  }
}
//////////////////////////////////////////////////
void BUp()
{
  buttonState3 = digitalRead(btnUp);
  // compare the buttonState to its previous state
  if (buttonState3 != lastButtonState3) {
    // if the state has changed, increment the counter
    if (buttonState3 == HIGH) 
    {
     if (Menu == 1)
      { 
        if (set1 < 120)
        set1++;
        if (set1 >= 120)
        set1 = 30;
      }
      // Btn Sound
      if (btnSound == true)
      {
        clickSound();
      }
      // Save Settings?
      if (Menu == 5)
      {
        SaveAll();
      }
      if (Menu == 2)
      { 
        if (set2 < 120)
        set2++;
        if (set2 >= 120)
        set2 = 30;
      }
      if (Menu == 3)
      { 
        if (set3 < 120)
        set3++;
        if (set3 >= 120)
        set3 = 30;
      }
      if (Menu == 4)
      { 
        if (set4 < 120)
        set4++;
        if (set4 >= 120)
        set4 = 70;
      }
    } 
    lastButtonState3 = buttonState3;
    UpdateLCD();
  }
}

So what's your problem?

Mark

Where is the mistake?

Besides not describing what your problem is? It's amassing boatloads of code without assuring that all the pieces work individually before being assembled into a complete program.

My problem you can see in video. - YouTube When I trying log on menu he start flashing, and I can't find where is my problem

 BSelect();
 BUp();
 BDown();

Meaningful names are important. I can't even begin to guess what these functions do.

 ReadTemperature();

Functions should do only what the name suggests that they do. A read function that does not return a value is useless.

A read function that also updates the LCD is misnamed. I can't help you when you can't even use names that make sense.

The first three functions all call UpdateLCD(). Why is it necessary to call it AGAIN?

#include<LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
#include <EEPROM.h>
#include <OneWire.h>
#include <Wire.h>
#include <DallasTemperature.h>
int Backlight =10;
#define ONE_WIRE_BUS 2
#define TEMPERATURE_PRECISION 9
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

When I look at these opening lines I get the impression of a complex project.

I presume you did get each piece to work on its own before you combined them.

What change did you make that has changed your previously working program into the current non-working program?

...R

In this program does not change anything as. I have tried to delete UpdateLCD (); after each button, but nothing has changed

I don't understud where I need to make changes

I don't understud where I need to make changes

Well, we don't understand exactly what your problem is, so it's hard to say.

Describe your problem in terms of the exact steps that you perform. Something along the lines of "The Arduino starts up. It displays xxxx on the LCD. I press the kaboom switch, connected to pin 183, and smoke pours out of the cat...".

One of the things I notice is that you're calling updateLCD through every iteration of the loop. In fact it happens even more than that since it also gets called from various other functions.

Now bearing in mind that the loop itself, (if no button is being pressed) is likely to execute in less than 20 micro seconds, You're attempting to clear the screen and redraw it about 50,000 times every second.

I suggest as a VERY QUICK AND DIRTY measure, you introduce delay(500); at the end of your loop() function so that you get a chance to see what's going on and help you debug it.

The next thing you should do is introduce a method to keep track of when the display really NEEDS updating. (perhaps a simple global variable screenDirty that gets changed to true when something changes, you could then change it to false in updateLCD)

Then your updateLCD could return without doing anything if nothing has changed.

korne1:
In this program does not change anything as.

If this is a response to Reply #5 it does not make sense.

If no changes had been made from your last working version the program would be working and you would not be asking for help.

If you have put all that stuff into a program without testing each part as you went along I am not surprised that it doesn't work. But you have nobody to blame but yourself.

...R