Variable vale problem

Hy,

I made a little program. I am begginner in this subject. I have a bit mistake, and i don’t know where is it.
From 254 to 259 lines of code are ran, but the condition should filter ot that because off oblites_on variable value is must be false.

When i wrote that value, is true. There is only one place, where i put that value true, is row 225, but i tested it, it didn’t run in that else.

So my question: How can it work?

Thanks a lot. I am waiting for your reply.

Yours faithfully,
Struke

cip_flow_meter1.ino (9.41 KB)

Sorry, it's just too difficult to understand what the problem is you're having. Your description is very vague and it seems like maybe the line numbers you are referencing don't match the program you posted.

Please provide a much more detailed description of your problem so we can help you.

Thx for fast replay, also the problem this if, because this detail the “else” is running.

if (!sziv_on && oblites_on)
{

////oblites elokeszites 30 masodperc mulva indul
if (oblites_on_time)
{
lcd.lcdClear();
lcd.lcdGoToXY(1, 1);
lcd.lcdWrite(“Oblites”);
lcd.lcdGoToXY(1, 2);
lcd.lcdWrite(“megkezdese…”);
oblites_delay(oblites_time);

oblites_on_time = false;
lcd.lcdClear();
lcd.lcdGoToXY(1, 1);
lcd.lcdWrite(“Oblites”);
}
//////oblites elkezdese
else if (totalMilliLitres < oblites * 1000)
{
lcd.lcdGoToXY(1, 2);
lcd.lcdWrite(totalMilliLitres);
lcd.lcdGoToXY(5, 2);
lcd.lcdWrite(“mL”);
totalMilliLitres = totalMilliLitres + 100;
digitalWrite(ON, HIGH);

}

else
{
totalMilliLitres = 0;
menu_tilt = false;
oblites_on = false;
digitalWrite(ON, LOW);
lcd.lcdClear();
menu_set();
}
}

}

but in the program only is set it up (bool oblites_on bit) in true.

if (!oblites_on && sziv_on)
{

if (totalMilliLitres < vegyszerek[menu] * 1000)
{
lcd.lcdGoToXY(1, 2);
lcd.lcdWrite(totalMilliLitres);
lcd.lcdGoToXY(5, 2);
lcd.lcdWrite(“mL”);
totalMilliLitres = totalMilliLitres + 100;
digitalWrite(ON, HIGH);

}

else
{
totalMilliLitres = 0;
sziv_on = false;
digitalWrite(ON, LOW);

oblites_on = true;
oblites_on_time = true;
}
}

My advice is to add some Serial.println() in strategic locations in your sketch and then run it with the Serial Monitor open so you can see what is happening in the code.

You are writing 11 values into an array that can only hold 10.

unsigned int vegyszerek[10] = {};

void setup()
{
[...]
  for (int i = 0; i < 11; i++)
  {
    vegyszerek[i] = EEPROM.read(i);
    delay(5);
  }
[...]
}

You should have seen this warning:

sketch_aug26a.ino: In function 'setup':
sketch_aug26a.ino:114:35: warning: iteration 10 invokes undefined behavior [-Waggressive-loop-optimizations]
     vegyszerek[i] = EEPROM.read(i);
                                   ^
sketch_aug26a.ino:112:21: note: containing loop
   for (int i = 0; i < 11; i++)
                     ^

@johnwasser makes an excellent point about how compiler warnings can be incredibly useful in pointing out potential problems in your code. I recommend always paying attention to the compiler warnings shown in red in the black console window at the bottom of the Arduino IDE window (you need to scroll up to see them all).

By default, the Arduino IDE has compiler warnings turned off. You need to set File > Preferences > Compiler Warnings to "All".

Note that warnings are only the compiler pointing out things that might be problems. It's very common for beginners to confuse warnings with errors. They are not the same thing. I recommend always fixing the code that causes these warnings in your own work. However, some compiler warnings can be safely ignored. Sometimes you'll see warnings that are from some library code you didn't write. Take a look at these, but don't panic and assume "it's red text so there must be something wrong".

Hy

thank you very much for your help. The problem was that johnwasser. Now works fine. I couldn't do that pert, thx for detailed instructions. :slight_smile: