Hello, I have a pretty simple question. I need to view the output of several pots on a LCD, but not in a continuous stream, just when it changes. I have some example code, but I'm embarrassed to say that it's just not enough. Can somebody use it in an example for me?
boolean PreviousValue;
void loop( void )
{
boolean ThisValue;
ThisValue = digitalRead( 7 );
if ( ThisValue != PreviousValue )
{
// Your print goes here.
PreviousValue = ThisValue;
}
}
a refactored version of the code, I added a timestamp in the print to show when state change happened.
#define INPUTPIN 7
int previousValue = LOW;
void setup()
{
Serial.begin(9600);
}
void loop( void )
{
int value = digitalRead( INPUTPIN );
if ( value != previousValue )
{
Serial.print(millis());
Serial.print(" : ");
Serial.println(value);
PreviousValue = value;
}
// do other things here
}
give it a try ..
Thanks Rob,
Ill try that, it seems much more clear. 
you're welcome, let us hear if it works and how you used it in your project