02-24-2015 01:37 PM
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 ¡¡¡
02-24-2015
02:42 PM
- last edited on
01-03-2025
11:22 AM
by
Content Cleaner
A few thoughts about your question...
1) Please, please, please, format your code with the Insert Code button on the visual toolbar. It improves your chances for answered questions.
2) Be more specifc! What kind of errors are you getting?
3) Do your troubleshooting one piece at a time:
4) Once all these separate tests are done, then you can try to hook it all up together.