int counter; // count 200 samples
int minValue;
int maxValue;
void setup()
{
Serial.begin(115200);
Serial.println( "The sketch has started");
counter = 0; // start at the begin
minValue = maxValue = SensorValue(); // give them a value from the sensor to start with
}
void loop()
{
int newValue = SensorValue();
if( newValue > maxValue)
{
maxValue = newValue;
Serial.print( "▲"); // this is a UTF-8 character
}
else if( newValue < minValue)
{
minValue = newValue;
Serial.print( "▼"); // this is a UTF-8 character
}
else
{
Serial.print( "─"); // this is a UTF-8 character
}
counter++;
if( counter == 200)
{
Serial.println();
Serial.print( "Minimum value: ");
Serial.print( minValue);
Serial.print( ", ");
Serial.print( "Maximum value: ");
Serial.println( maxValue);
counter = 0; // start at the begin
minValue = maxValue = SensorValue(); // give them a value from the sensor to start with
}
delay( 50);
}
int SensorValue()
{
// This is no fun:
// return random( -20000, +20001);
// This is more fun:
return( random( -32, 32) * random( -32, 32) * random( -32, 32));
}