MegunoLink and the Arduino IDE work together to create your project:
- Create your Arduino sketch using your own code and any of the widely available libraries for sensors, motors and controllers.
- Create a custom interface using MegunoLink visualizers.
- Send data and commands from your Arduino sketch to MegunoLink using our Arduino library.
- Handle commands sent from MegunoLink to call functions in your Arduino sketch using the command handler in our Arduino library.
The MegunoLink library for Arduino includes classes to send data and commands to visualizers, and classes to receive commands and call a function in your Arduino sketch.
The visualizer classes (
InterfacePanel, for example) create and send special messages that MegunoLink decodes. The plotting data guide provides a detailed walk-through. These messages are sent to the serial port, by default (
Serial), though the destination can be changed.
The command handler classes decode messages sent to your Arduino
Serial port, by default. These could be commands sent by buttons on a MegunoLink interface panel. The guide process serial commands with an Arduino walks through the steps for using the command handler while the Arduino interface building guide talks about building an interface panel to send commands.
Here’s a simple sketch that sends measurements from analog port 0 to a time plot visualizer. A command,
SendData, starts and stops transmission of the data.
bool SendData = false;
void Cmd_SendData(CommandParameter &p)
SendData = p.NextParameterAsInteger(1) != 0;
if (SendData && SendTimer.TimePassed_Seconds(5))
ArduinoTimer is a utility class, included in our library, for executing a function periodically.
MegunoLink’s upload monitor solves the port contention problem. That’s the
avrdude: ser_open(): can't open device "\\.\COM4": Access is denied error in the Arduino IDE when another application is using the Arduino serial port needed to program your device. Two applications can’t use one serial port at the same time.
Our upload monitor is triggered when the Arduino IDE uploads a program to your Arduino. MegunoLink releases the serial port so the upload can continue. When the upload completes, MegunoLink will reconnect to the serial port to monitor your data.
This all happens automatically once you’ve installed the upload monitor.
Open Arduino Code
Select Open Arduino code from the MegunoLink open menu to open your sketch in the Arduino IDE.
MegunoLink looks in the folder where your MegunoLink project is saved to find the Arduino code for your project. It opens the
.ino file with the same name as the parent folder if present, or the first
.ino file in the MegunoLink project file folder otherwise.