Returning Max Data

Hello,
I am working on a Science Fair Project about how the strength of 3D-printed plastic is correlated to its extrusion temperature, and I am attempting to use a force sensitive resistor to measure the force applied until the plastic breaks. I have been testing out some code before I began the actual experimentation but am still struggling on how to narrow down the amount of data I am receiving. I am hoping to have the board (Uno) return values only if they are larger than previous ones. Attached is the code I currently have.

Thank you!

int force;
int forceprev;
int Pressurepin = A0;

void setup() {
    Serial.begin(9600);
}

void loop() {
    force = analogRead(Pressurepin);
    forceprev != analogRead(Pressurepin);
    if (force > forceprev)
     {
       Serial.println(force);
      }
       else{}
    delay(100);
}

FSRFinal.zip (2.38 KB)

The second line of this does not make sense

    force = analogRead(Pressurepin);
    forceprev != analogRead(Pressurepin);

I'm not even sure what you think it might do

Try something simple and obvious like this

    forceprev = force;
    force = analogRead(Pressurepin);
    if (force > forceprev)
    // etc

...R

Thanks for your help!

The second line came from when I was looking at a debouncing reference from the Chrono library. I think it helped to eliminate all the unnecessary zeros I got from the serial monitor. I did not know exactly what it would do.

When I switched out my bad lines lines for the ones you provided me with the program worked, and it eliminated most of the lesser values. I will test it again in the experiment soon.

Thank you again!

I think it helped to eliminate all the unnecessary zeros I got from the serial monitor. I did not know exactly what it would do.

force = analogRead(Pressurepin);
    forceprev != analogRead(Pressurepin);

Does nothing useful, but it does waste around 100 microseconds.

Thanks! I was beginning to wonder if it actually did anything.