Filtering duplicates for sensor

Hello, How would I filter out duplicates within a sensors data? I have hooked up a pressure sensor and when just sitting it outputs 0 every 100ms. How can I it to Serial.print(0) a single time when its sitting then when the values change, Serial.print (1) a single time? Thanks so much in advance!

If the difference between the current reading and the previous reading is sufficiently large, print your print your '1'. Make sure you store the previous value in a global or static variable.

Thanks for the response!

Not following all that you explained, sorry!
Im setting it up like this, I think this should work but I keep getting this error:
ISO C++ forbids comparison between pointer and integer


const int threshold = 100;
int isEffect1on = 0;

void setup()
{
// Start serial at 9600 baud
Serial.begin(9600);
}

void loop()
{
// Read the input on analog pin 0:
int sensorValue1 = analogRead(A0);
int sensorValue2 = analogRead(A1);
int sensorValue3 = analogRead(A2);
int sensorValue4 = analogRead(A3);
int sensorValue5 = analogRead(A4);
int sensorValue6 = analogRead(A5);

//Instrument 1 Control; 11 = on, 10 = off
if (sensorValue1 > threshold) && isEffect1on != 1)
{
Serial.print(11);
}
else {
if (sensorValue1 < threshold)
{
Serial.print(10);
isEffect1on = 0;
}

// Wait 100 milliseconds
delay(100);
}

You can't declare a constant int and then change the value. That makes no sense.

I don't know what the pointer error is all about, I don't see any in your code.

if (sensorValue1 > threshold) && isEffect1on != 1)

missing a (

when you do CTRL-T in the IDE the code gets auto formatted IF the () and {} and match in number.

because of the missing ( the statement is interpreted as : // rewritten to emphasize
if (sensorValue1 > threshold)
{
&& isEffect1on != 1) << the address of the address of isEffection != 1
}


possible fix for your next bug:)
add DEC when printing might help - Serial.print(11, DEC);

X-mas gift ;)

int previousValue1 = -1;

void setup() 
{
  Serial.begin(9600); 
  Serial.println("start...");
}

void loop() 
{
  int sensorValue1 = analogRead(A0);
  
  if (sensorValue1 != previousValue1)
  {
    Serial.print(millis());
    Serial.print("\t");
    Serial.println(sensorValue1);
    previousValue1 = sensorValue1;
  }
}