Example Code for Arduino-Serial Communication
Last revision 2026/01/24
This article provides example code for Arduino serial communication, focusing on hardware and software setup for Bluno M0, and explains the use of USB and hardware serial ports.
Hardware Preparation
- Bluno M0 Mainboard(SKU: DFR0416) ×1
- Micro USB Cable ×1
Software Preparation
- Download Arduino IDE: Click to download Arduino IDE
- Install Bluno M0 board URL: https://raw.githubusercontent.com/DFRobot/DFRobotDuinoBoard/master/package_dfrobot_index.json
Other Preparation Work
Just like Arduino Leonardo, M0 has USB Serial Port and Hardware Serial Port. No like DFRduino M0, Bluno don't have Serial1. USB COM port, Bluetooth and Hardware Serial Port 1 share the same port: Serial.
| USB Serial Port | Serial |
|---|---|
| Hardware Serial Port 1 | Serial |
| Hardware Serial Port 2 | Serial2 |
D0&D1 refers to Serial, serial2 refers to Serial2. Users can use USB serial transformer tools to check printing.
Sample Code
Init Serial/Serial2 at 115200bps, loop to print specific content.
void setup() { // put your setup code here, to run once:
Serial.begin(115200);
Serial2.begin(115200);
}
void loop() { // put your main code here, to run repeatedly:
Serial.println("I am Serial");
Serial2.println("I am Serial 2");
delay(1000);
}
Result
Use USB serial transforming board to receive data from Serial2 and you can check printing in correspond in PC.
Was this article helpful?
