Greetings,
I successfully ported a library for Arduino to LabVIEW following the instructions in the Help File. However, I was unable to resolve the following: in the example provided by the library, an instance is created that receive two constant. Something like the following:
////////////////////////////////////////////
#include "ALHarduinoLibrary.h" // library that must be included #define arduinoPIN 4 // Arduino Digital pin #define ALTYPE 11 // Used by the library for some settings // Create instance ALH alhobject(arduinoPIN, ALTYPE); void setup() { // Initialize alhobject.begin(); } void loop() { // Reading float h = alhobject.reading();
...
//////////////////////////////////////////////////////
and so on. If I use a different pin on the Arduino, or need to change the number for ALTYPE, I can just change it in this source code. However, for the Arduino Compatible Compiler for LabVIEW I had to hardcode those values in "Translator.vi", specifically in the "Defines" and "Includes" portions. Therefore, if I need to change them, I need to modify "Translator.vi", but that seems to defeat the purpose of the whole process.
Is there a better way? Please advise.
Regards,
Enrique
It works. Thanks!
This brings another question about how the ACCL work. Please bear in mind that I am not proficient in C or arduino sketches. Having the capability to code Arduino in LabVIEW is amazing and for that I am grateful.
In the Arduino sketch that I shared as an example the instance "alhobject" is global to both "setup()" and "loop()".
From your suggestion, the way I modified the code is to create a VI, which in Translator.vi looks as follow:
ALH alhobject(%s,%s);
alhobject.begin();
This VI receive arduinoPIN and ALTYPE as inputs. When I check this using the "Arduino Code" in the compiler Window, this code ends up inside setup(), like this:
void setup()
{
unsigned char Const302;
unsigned char Const228;
Const302 = 11;
Const228 = 41;
ALH alhobject(%s,%s);
alhobject.begin();
}
As I mentioned, I am not proficient in C or arduino sketches, but it seems to me that alhobject won't work inside loop()... but somehow this code is working.
I was wondering: is it that the ACCL work some extra magic while compiling the code for Arduino and sort things out correctly?, or perhaps is that everything happens inside setup(), which means that loop() is not used?
Regards,
Enrique
29
1 Guest(s)