Data transmission with Arduino

Asked

Viewed 38 times

1

I’m monitoring 3 analog inputs of one Arduino UNO and I don’t know if the way I’m sending data to serial is correct, because when I try to receive the information in another language(C#) does not always come in the expected format.

int CANAL1, CANAL2, CANAL3, C1 = 0, C2 = 2, C3 = 5;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly
  analogReference(DEFAULT);
  CANAL1 = analogRead(C1);
  Serial.print(CANAL1);
  Serial.print(" ");
  CANAL2 = analogRead(C2);
  Serial.print(CANAL2);
  Serial.print(" ");
  CANAL3 = analogRead(C3);
  Serial.print(CANAL3);
  Serial.println();
  delay(10);
}

I wonder if it’s better to print in the serial that way or concatenate a String and print on serial. Or some other way where I don’t lose data while transmitting them. Someone to give a boost?

On the other platform(C#) when receiving the data and storing in a String I realize that data is missing in the String sent by Arduino, and most of the time it is at the beginning of the execution of the program that comes null data.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.