The Arduino library bundled with MegunoLink provides classes to send data to our visualizers. There is one visualizer class for each visualizer, as shown in the table below. The classes provide methods for sending the data in the right format.
Using the Library
To use a visualizer class in your Arduino sketch:
- Install the MegunoLink library into your Arduino library folder
#include "MegunoLink.h"— to make the library available to the sketch
- Create an instance of the visualizer class. This just means creating a variable such as
- Call methods on the instance variable when you want to send data. For example:
MyPlot.SendData("ADC Value", analogRead(0));
The visualizer class variable can be in the global scope (at the top of your sketch), or in the function right before you use it. Generally it is easier to place it in the global scope, especially if you are using channels.
Channels and Serial Ports
The methods of each visualizer class send data to the default channel on the standard Arduino
Serial port. Include the channel name and Serial port in the constructor when you create the visualizer class variable to send data to a different channel or port.
For example, to send data to a channel named
Serial1 declare your
TimePlot variable as:
TimePlot MyPlot("SetPoints", Serial1);
Visualizer Class Reference Pages
|Time Plot||Time Plot Library|
|X-Y Plot||X-Y Plot Library|
|Interface Panel||Interface panel Library|
|Message Monitor||Message Monitor Library|
Here is a simple example that generates a cosine function and sends it to a time plot.
double t = millis();
double y = cos(2 * 3.141 * t/1000.0);