how to save a changing value

Hey guys,

we are currently working on a air pressure project, and we want to display the result on a 16x2 LCD display. Displaying the value works perfectly, but we also want to fill the second line with '>' adjusted to the measured pressure. So we have to save every new pressure value and compare it with the older value, but we don't know how to write that in the code.
If someone have an idea, we would welcome it. :slight_smile:
Thanks :stuck_out_tongue:

previous pressure = pressure
read pressure
if pressure not equal to previous pressure
  do something
end if

UKHeliBob:

previous pressure = pressure

read pressure
if pressure not equal to previous pressure
  do something
end if

I think actual C code would be more helpful:

int prevPressure = 0;

void setup(){
    //your setup
}

void loop(){
    int pressure = readPressure();
    if(pressure!=prevPressure){//you can also use other operands than '!=', e.g.:'<','>','==','>=' or '<='
        //do whatever you need to do
        prevPressure=pressure;
    }
    //anything else you need to do
}

TGMStudent:
but we also want to fill the second line with '>' adjusted to the measured pressure.

What do you mean by that?
The difference between the last pressure and this pressure?

I think actual C code would be more helpful:

That depends on whether you want to give a man a fish to feed him for a day (ie write the code) or teach him to fish to feed him for life (ie provide ideas on how to write the code).

I prefer the latter, as in my experience learning by doing something is preferable, but that is, of course, a matter of opinion.