I am testing the code first that is why i have named them simply as "x", "y" and "z" variables.
Declaring these variables as volatile is just a precaution, but if it is unneeded then i'll simply remove it.
"CoinChange = 1" ; i forgot to delete that statement. i declared a "CoinChange" variable for a condition purpose but it is useless unless i can correct the problem of my code.
There is no problem with the connections of the devices. All is working properly.
What i want to display in the LCD is the 4 variables that counts the number of the coins and the total monetary of the coins inserted.
Type 1 coin (P1.00) = 1 pulse
Type 2 coin (P5.00) = 5 pulses
Type 3 coin (P10.00) = 10 pulses
Adding the total monetary is not a problem. The main concern is that i want to count the number of each type of coin that is inserted in the system.
With the code i shown, when i tested it, logically i was thinking with the delay at that start of the loop function the interrupt function would have had the time to count up the "coins" value before entering the main codes in the loop function.
The result is that it either counts right or:
~ Even when the total monetary counts up correctly to the corresponding type of coin, the Variable that corresponds to that coin doesn't count up.
~ It counts up the wrong variable, most of the time it is the "x" variable, even when type 2 or type 3 is inserted in the coin slot.
~ It doens't count at all; the total monetary and any of the variables.
Ideally what i want is:
~ When i insert a Type 1 Coin, "x" variable counts up (x = x + 1), and total monetary counts up as well (a = a + 1)
~ When i insert a Type 2 Coin, "y" variable counts up (y = y + 1), and total monetary counts up as well (a = a + 5)
~ When i insert a Type 3 Coin, "z" variable counts up (z = z + 1), and total monetary counts up as well (a = a + 10)