Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3798

Serial comms to Arduino

$
0
0

Continuing the discussion from Serial communication with Arduino:

I am back still trying to communicate with an ADRUINO via serial port. Just to be sure, I don’t need any special drivers, etc. to get my MacBook pro M1 to properly talk via the USB port to the Arduino, correct?

I still can’t seem to get XOJO code to talk to the Arduino. SerialConnection1 Data Received event never fires…

Try
  Var data As String = SerialConnection1.ReadAll
  If data <> "" Then
    TextArea1.AddText("Received: " + data)
  End If
Catch error As IOException
  MessageBox("Error reading from serial port: " + error.Message)
End Try

The Arduino (Adafruit METRO RP 2040) code behaves as expected when using the Arduino IDE serial monitor. Here is that code:

void setup() {
  // Initialize serial communication at 9600 bits per second
  Serial.begin(9600);
}

void loop() {
  // Check if data is available from the Raspberry Pi
  if (Serial.available() > 0) {
    // Read the incoming data as a string
    String incomingData = Serial.readStringUntil('\n');

    // Print the received data to the Serial Monitor (optional)
    Serial.print("Received: ");
    Serial.println(incomingData);

    // Send an acknowledgment back to the Raspberry Pi
    Serial.println("Acknowledged");
  }

  // Optional: Other code can be placed here
}

Is there some dead simple test I can use to insure XOJO is hearing the Arduino?

18 posts - 5 participants

Read full topic


Viewing all articles
Browse latest Browse all 3798

Trending Articles