Hi everyone,
I am trying to communicate with Arduino and LabWindowCVI10. Just want to send integers for my Arduino to read. It is not clear how it works the ComWrt function.
You can give me a hand?
This is my code LabWindow
int CVICALLBACK Frecuencia (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
double x;
GetCtrlVal(panelHandle, PANEL_FRECUENCIA, &x);
char info[10];
Fmt(info, "%s<%f[p0]", x);
/*for(int i=0; i<strlen(info); i++){
int c = info[i];
ComWrtByte(COM, c);
Delay(0.1);
}*/
ComWrt(COM,info, strlen(info));
break;
}
return 0;
}
And this on my Arduino
char cadena[8];
byte posicion;
unsigned long valor;
void loop() {
if (Serial.available())
{
memset(cadena, 0, sizeof(cadena));
while (Serial.available() > 0)
{
delay(5);
cadena[posicion] = Serial.read();
posicion++;
}
valor = atol(cadena);
AsignarFrecuencia(valor);
posicion = 0;
}
}
Not if I'm working properly with LabWindow. I would appreciate any help.
Regards from Spain ¡¡¡