BTSerial.begin(38400) // HC-05 default speed in AT command mode PIN 9 of the Arduino is connected to the KEY pin of the HC-05 module. Writing HIGH to the PIN 9 puts the HC-05 into command mode. I will highlight the key sections of the code.
Arduino bluetooth serial#
Read from serial monitor and send to HC05 SoftwareSerial BTSerial(10, 11) // RX | TXīTSerial.begin(38400) // HC-05 default speed in AT command mode * Changing HC05 module's default device name using AT Command The first line activates the hardware serial port on the UNO. You will toggle the LED using a Bluetooth serial app on the phone. The LED is connected to PIN 8 of the Arduino. The flag is a variable used to store the input from Bluetooth. Serial.println("Ready to connect\nDefualt password is 1234 or 000") ģ) Code walkthrough SoftwareSerial MyBlue(2, 3) // RX | TXĪn object named MyBlue is created using the SoftwareSerial library. You can use AT commands to put the HC-05 module in the master mode. HC-05 Module can act like a Master as well as a slave. I will share with you more details about the AT modes and the KEY pin functionality in the sections below. It will be low when it si not connected to any device. The STATE pin will be high when it is connected to a Bluetooth device. The STATE pin tells the Arduino UNO whether the HC-05 is connected to a Bluetooth device or not. The KEY pin enables you to put the HC-05 Bluetooth module in AT command mode. Connect TXD Pin of the MCU (Arduino UNO PIN 1) You will send the commands to the module via this RXD pin. Connect the TXD pin of HC-05 to the RXD pin of the MCU (Arduino UNO PIN 0) TXD is the transmit pin of the Bluetooth module. This can be connected to the GND pin on the Arduino UNO GND pin of the HC-05 should be connected to the ground connection of your project. You can connect 5 V from the Arduino UNO to this pin.
This is the Power supply pin of the module. I will show you the HC-05 pins and the descriptions in the table below: Sl.