Communication with Arduino Leonardo on LattePanda single board computer


I’m trying to use Openframeworks libraries to communicate with an Arduino Leonardo that is included onboard the LattePanda single board computer (which is running Win10). I have programmed the onboard Arduino with Standardfirmata.

I got the firmata example working, included with the download:

I was able to see the PWM and servo working, as well as toggle the D13 pin with mouse clicks, and read ADC A2 (I had to switch from A0, which didn’t seem to work).

Now I’m trying to simplify to just read an ADC in some in-line code before I integrate these functions into a much larger program (and these functions will replace calls to Measurement Computing USB-1208FS-PLUS ADC and Dout calls, just fyi).

When I run my very simplified code (pasted below), the ADC returns a -1 and I get an error “ofArduino: Pin 2 does not exist on the current board”

This line, “ard.connect(“COM5”, 9600);” worked in the firmataExample, so I feel like it’s not the problem.

I’m guessing I stripped out too much of the setup here:

#include “ofMain.h”
#include “ofApp.h”
#include “ofEvents.h”
#include “ofArduino.h”

ofArduino ard;

int main( ){

int result = 0;

printf_s("\nAbout to connect...");
ard.connect("COM5", 9600);

printf_s("\nAbout to configure Analog pin 2...");
// set pin A2 to analog input
ard.sendAnalogPinReporting(2, ARD_ANALOG); //3-3-2021 Phil addition, and it seems to work!

for(int i = 0; i < 60; i++)
	printf_s("\nReading Analog pin 2...");
	result = ard.getAnalog(2);
	printf_s("Channel 2: %i", result);

return 0;


What other code do I need to set up the communication between the CPU and the Arduino?



I have more information to help with troubleshooting, but it’s still not fixed.

I added this code to help troubleshoot:
cnt = ard.connect(“COM5”, 9600);
init = ard.isInitialized();
rdy = ard.isArduinoReady();

ofLogNotice() << ard.getFirmwareName();
ofLogNotice() << "firmata v" << ard.getMajorFirmwareVersion() << "." << ard.getMinorFirmwareVersion();

printf_s("\nArduino status:");
printf_s("\n \t connect: %i", cnt);
printf_s("\n \t init: %i", init);
printf_s("\n \t ready: %i", rdy);


When I run the program, the three bool variables come up as follows:
cnt: 1
init: 0
rdy: 1

The two ofLogNotice() statements returned:

Firmware name: unknown
Firmata: v0.0

The isInitialized() is failing, indicating that a connection has not been established and that the Arduino has not reported a firmware.