กลับไปหน้ารวมไฟล์
basic-bluetooth-communication-with-arduino-hc-05-3a431c-en.md

Wireless Introduction: HC-05 Bluetooth Basics

Bluetooth is the backbone of short-range telemetry. The Basic HC-05 Communication project is the absolute required first step before you can build a remote-control car or an automated curtain opener using your smartphone.

button_led_basic_interaction_1772681969235.png

The Software Serial Bridge

An Arduino Uno has one hardware serial port (Pins 0 & 1).

  • If you plug the Bluetooth module into 0 & 1, it will violently conflict with the USB cable when you try to upload your code!
  • You must use the <SoftwareSerial.h> library to create a "fake" serial port on pins 10 and 11.
  • You wire HC-05 TX -> Arduino Pin 10 (RX) and HC-05 RX -> Arduino Pin 11 (TX). (Note the crossover!).

Formatting Transmitted Characters

  1. The Phone App: You download a free "Bluetooth Serial Terminal" app on Android. You connect to the HC-05 and type the letter "A".
  2. The Code Listener:
if (bluetoothSerial.available()) {
  char command = bluetoothSerial.read();  
  if (command == 'A') { digitalWrite(13, HIGH); } // Light turns ON!
  if (command == 'B') { digitalWrite(13, LOW); }  // Light turns OFF!
}
  1. A single tap on your glowing phone screen travels invisibly through the air and triggers massive relay drivers on the other side of the room.

Requirements

  • Arduino Uno/Nano: The command logic.
  • HC-05 or HC-06 Bluetooth Receiver: Ensure it is a 5V tolerant breakout board.
  • A 5mm LED and Resistor.
  • Android Smartphone/Tablet. (Note: iOS devices generally completely block communication with cheap SPP Bluetooth modules like the HC-05. An Android device or PC is highly recommended).

ข้อมูล Frontmatter ดั้งเดิม

title: "Basic Bluetooth communication with Arduino & HC-05"
description: "Cut the cord! Enter the world of wireless computing by pairing an HC-05 module to your smartphone to turn an LED on and off from the couch."
category: "Wireless & IoT"
difficulty: "Easy"