Example Code for Arduino-RS232 Communication

Last revision 2025/12/26

This article offers a practical example of Arduino-RS232 communication, demonstrating how LattePanda Alpha & Delta can communicate with Arduino using an expansion board, complete with code examples and implementation guidance.

Hardware Preparation

Software Preparation

Note: the driver needs to be installed when using on Windows for the first time. There is no need to install driver in Linux system.

Connection

  1. Connect the Arduino RS232 expansion board to the Arduino main control board
  2. Connect the LattePanda Alpha&Delta RS232 interface expansion board to the LattePanda Alpha&Delta
  3. Use the RS232 data cable to connect them together, as shown in the picture below:

Sample Code

Burn the following code in Arduino:

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

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()>0){
    char a;
    a = Serial.read()+1;
    Serial.print(a); //return all the data that received from LP
  }
}

Result

Open the serial monitor on LattePanda, select the COM1 serial port, and set the baud rate to 115200. Send data to Arduino will returned with added 1.

Result

Was this article helpful?

TOP