Arduino Analog Value Plotter

A while ago, I figured it would be pretty handy to have a graph for my analog outputs. It would help debug my outputs, give me a general idea of the sensor's limits and whatnot, and would even be just a pretty cool interface to have for any sensor. So, with an Arduino, an oled, and a sensor of your choice, let's get this up and running.

Step 1: Things You Will Need:

  • An Arduino
  • A display (my project uses a 0.96" OLED, and the sketch is suited for the same, but feel free to use any display you'd like. You will have to tweak the code a it, though (explained in the code section))
  • A breadboard (I use a custom breadboard shield, but it doesn't matter what you use)
  • Jumper wires
  • Not a lot of time

Step 2: The Hardware

Connecting The OLED: (Refer to images above for colors)

  • Red Wire (VCC):5v of the Arduino
  • Green Wire (GND):Ground of the Arduino
  • Purple Wire (SCL):SCL of the Arduino (Check bottom of board for labeling, if no specific SCL pin, it's usually A5)
  • Orange Wire (SDA):SDA of the Arduino (Check bottom of board for labeling, if no specific SDA pin, it's usually A4)


Connecting The Sensor: (Refer to images above for colors)

  • Power the sensor according to its specific pinout
  • The output of the sensor should go to A0

Step 3: The Code

It's a simple thing the program does- it takes the analog input, maps it to the y coordinates of the graph, and draws a line to the y coordinate, from the previous y coordinate, while the x coordinate is continuously increased.

The code is not very complicated at all, and is well commented, so if you feel you understand it well enough to tweak it, by all means do so. It was, however, designed to be maximally customizable with minimal tweaking. To change the graph size, graph position, or reading bar size (the bar size is already optimally, and responsively set), you only need to change the

  • GRAPH_HEIGHT
  • GRAPH_WIDTH
  • GRAPH_BOX_X
  • GRAPH_BOX_Y
  • BAR_WIDTH

constants, as per your requirement, in the constants definition section.

Additionally, your sensor output may be inverted (high input -> low output and vice versa). In this case, change the INVERTED constant to 'true'.

Arduino code:

Step 4: Conclusion

So that's it for this simple project. Hopefully it's of use to other people. If you happen to find a bug in the code, any potential improvements, or even a new use for the project, please let me know in the comments. Also, if you liked the project, consider voting for it in the "Build A Tool" contest.

Build a Tool Contest

This is an entry in the
Build a Tool Contest

Share

    Recommendations

    • Remix Contest

      Remix Contest
    • Tape Contest

      Tape Contest
    • Trash to Treasure

      Trash to Treasure

    Discussions