I want to design an indicator which will record peak pressure. It is used in some industries where the pressure goes on increasing until the subject break at a certain pressure and pressure reduces. Now at the point at which the pressure reaches a peak and starts reducing, it should hold that value on lcd. It should hold until reset is pressed.
For ex, I have 0 to 2 BAR sensor giving 4 to 20 mAmps output. I have an amplifier board which will convert 4 to 20 mAmps signal to 0 to 1 Volts/5 Volts signal. This will go to by system. User will apply the pressure until the peak, and when that peak is reached say 0.8 volts, it should hold on to that value until a reset input is received from the user.
I just need a pseudo code, as i am very confused where to start with or how should i hold the value on screen.
Start with reading the values from the sensor. Just print them to the Serial Monitor application.
If the values do indeed go up and then down, as expected, then it isn't hard to see if this value is greater than that value (this value being the current reading and that value being the previous reading). Of course, this means that you need to store the previous reading, and make it equal to the current reading at the end of loop. The State Change Detection code shows how to compare the current reading with the previous reading for digital sensors, but the principal is the same for analog sensors.
Once you have a value that is no longer going up (this reading is not greater than that reading), you know the peak. If this reading is greater than that reading, then the peak (so far) is this reading. If you always display the peak reading, then there is nothing to do when the readings start going down.