Serial Communication

Learn to send and receive data through the serial port for debugging and communication.

Wire Connections & Pin Configuration

Wire Color Connections:

USB cable (built-in): No external jumper wires required

Pin Configuration:

Arduino USB (TX/RX) → Computer (serial communication)
Arduino Code
Edit
// Serial Communication Example

void setup() {
  // Initialize serial communication at 9600 baud
  Serial.begin(9600);
  Serial.println(\"Arduino Serial Communication Started!\");
}

void loop() {
  // Check if data is available to read
  if (Serial.available() > 0) {
    // Read the incoming byte
    char incomingByte = Serial.read();
    
    // Echo back what was received
    Serial.print(\"I received: \");
    Serial.println(incomingByte);
  }
  
  // Send a message every 2 seconds
  Serial.println(\"Hello from Arduino!\");
  delay(2000);
}

Instruction Details

Wiring: Connect Arduino to computer via USB cable. No external components needed.
Library: Not required (built-in).
Upload Code: Tools → Board → Arduino Uno. Tools → Port → select your COM port. Click Upload button.
View Output: Open Serial Monitor (Tools → Serial Monitor) at 9600 baud. Type in input box and press Enter to send. Received data will echo back.

How to Use

  1. Connect the required components as per the Pin Configuration above
  2. Open Arduino IDE and create a new sketch
  3. Copy and paste the code above
  4. Select your Arduino board and COM port from Tools menu
  5. Click the Upload button to upload the code to your Arduino
  6. Open Serial Monitor (if applicable) to see the output

Components Required

  • Arduino Uno
  • USB Cable

Category: Communication