Trouble with Arduino combined with a LCD and linking integers to a matrix.

Hi everyone,

Im trying to programm an arduino to keep track of the amount of drinks everyone took from the fridge in our student house. The main objective is to be able to select a name, and increse or decrease an integer, linked to that name. In the mean time, the name and integer are displayed on a LCD screen.

I'm using an arduino Leonardo r3 and a dr robot lcd keypad shield. Im using the buttons on the screen to controll the unit.

Right now, I am able to change names, and change the integers connected to it. But, instead of printing a single integer to the lcd on position (9,1), it prints the integer connected to the name on (9,1), and integer h on (10,1).
Also, when increasing the integers, it always increases of decreases both the linked integer and integer h.

I cant find out why the integer h responds like it does. I hope some of you can find the problem!

Im lost as of why the integer h responds to weird

I hope someone can translate that phrase.

else if (i==3);Oops

I fixed the weird sentence.

And if i change that if else statement to a normal else, is behaves exactly the same.

larsholm:
And if i change that if else statement to a normal else, is behaves exactly the same.

"That" statement? - there's more than one!

Im sorry for being vague.

Even if i change all of the if else statements to else, it still behaves the same.

OK, so post your code, and post your less vague observations.

Why is adc_key_in global? The ONLY place it is used is read_LCD_buttons().

Serial.println(i);
Serial.println(p);
Serial.println(k);
Serial.println(h);
Serial.println(l);

Anonymous printing sucks. Print some identifiers before these values, so it is obvious what the value corresponds to.

Single letter global variables are a bad idea. It is too easy to overwrite one of them, unintentionally.

Perhaps with reasonable names for the variables, the problem, whatever it is, will become obvious.

Thanks for your advice. Doing that dit greatly improve the reeadability of my code! Also, i found the problem. For some reason, it was the semicolon after the if else statement that made the code not work as intended. It does work fully now!

Thanks everyone!