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:

  1. Install the MegunoLink library into your Arduino library folder
  2. #include "MegunoLink.h" — to make the library available to the sketch
  3. Create an instance of the visualizer class. This just means creating a variable such as TimePlot MyPlot;
  4. 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.

Destination

Data sent using the visualizer classes is sent to the Arduino’s Serial port by default.

The destination can be changed when you create the visualizer class variable by using the two argument constructor: ClassName(ChannelName, Destination). Here, ClassName is one of the visualizer classes; ChannelName is the name of the channel that data will be sent to (see below) and Destination is the variable where the data will be sent. For example: TimePlot MyPlot("", Serial2); will create a variable to send data to the default plot channel using Serial2 on an Arduino Mega.

Any object based on the Print class can be used as a destination for MegunoLink data. This includes:

Channels

MegunoLink’s channels let you send data to different visualizers in your project. For example, if you had two graphs: one for temperature and one for battery voltage. You can use channels to send the temperature data to one graph and battery voltage to a different graph.

Visualizer classes send data to the default channel by default. To select a different channel, include it when you create the visualizer class variable. This example sends the data to a channel named SetPoints. Refer to Message Channels documentation for information on selecting and managing channels in MegunoLink.

Visualizer Class Reference Pages

VisualizerClass NameLibrary Reference
Time PlotTimePlotTime Plot Library
X-Y PlotXYPlotX-Y Plot Library
Interface PanelInterfacePanelInterface panel Library
Message MonitorMessageMessage Monitor Library
TableTableTable Library
MapMapMap Library

Example

Here is a simple example that generates a cosine function and sends it to a time plot.

Start typing and press Enter to search