C++ Blynk (Legacy) - Code Examples for Basic Tasks

#3 Dirt simple Zero Centered Negative/Positive data display

Say you need an analog display for a value that could be negative or positive… well, until we get such option for the Gauge Display, here is an alternative that works perfectly.

This is shown along with a ‘normal’ bar graph (in Yellow) of the same data feed from a Potentiometer on an Analog pin.

image

image

image

// ----- Zero Center Split Bar Level Display -- Call this function with a timer -----
void AnalogSensor() {
  LVLval = map(analogRead(pin), 0, 1023, -150, 150); // Mapped data from Arduino analog pin
  Blynk.virtualWrite(V1, LVLval);  // Lefthand bar (MIN/MAX setting 0 to -150, Flip Axis ON)
  Blynk.virtualWrite(V2, LVLval);  // Righthand Bar (MIN/MAX setting 0 to 150, Flip Axis OFF)
}  // END Arduinor Function
8 Likes