CODE TO CHECK THE TRANSITION FROM ONE STATE TO OTHER

hi... I'm just a beginner to programming. i want the code to check the transition from one value to the other in the analog pin.i want this code for my college project. In my project I'm using two batteries, of which one will charge and the other will discharge. Charging and discharging depends on the available power in the battery. Is there any other logic to to the above????

Keep track of what the value was on the last iteration, and if it is different enough...

Do you need help with the logic or are you getting confused by translating into C++? If it's the later, I find it often helps to write it down as if you were explaining it to your idiot friend, telling them when to "keep track" of a number and to read (and keep track of) the sensor value. Then, you just have to get the parentheses in the right places.

wonderfuly said!