Bluetooth Interfacing with LPC2148

This article is a continuation of the series of tutorials on the LPC2148 Microcontroller (ARM7). The aim of this series is to provide easy and practical examples that anyone can understand. In the previous tutorial, we have interfaced the IR sensor with LPC2148 (ARM7). In this tutorial, we are going to see Bluetooth interfacing with LPC2148.


Before starting this tutorial we should know the below topics. If you know already, please go further.

Components Required

  • LPC2148 Development Board
  • Bluetooth Module
  • DC Motor
  • L293D (Motor Driver IC)
  • Smart Phone with Bluetooth Terminal App

Bluetooth Module (HC-05)


HC‐05 module is an easy-to-use Bluetooth SPP (Serial Port Protocol) module, designed for a transparent wireless serial connection setup. The HC-05 Bluetooth Module can be used in a Master or Slave configuration, making it a great solution for wireless communication. This serial port Bluetooth module is fully qualified Bluetooth V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with a complete 2.4GHz radio transceiver and baseband. It uses CSR Bluecore 04‐External single-chip Bluetooth system with CMOS technology and with AFH (Adaptive Frequency Hopping Feature).

The Bluetooth module HC-05 is a MASTER/SLAVE module. By default the factory setting is SLAVE. The Role of the module (Master or Slave) can be configured only by AT COMMANDS. The slave modules cannot initiate a connection to another Bluetooth device but can accept connections. The master module can initiate a connection to other devices. The user can use it simply for a serial port replacement to establish a connection between MCU and GPS, PC to your embedded project, etc.

Hardware Features

  • Typical ‐80dBm sensitivity.
  • Up to +4dBm RF transmit power.
  • 3.3 to 5 V I/O.
  • PIO(Programmable Input/Output) control.
  • UART interface with programmable baud rate.
  • With integrated antenna.
  • With edge connector.

Software Features

  • Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.
  • Auto‐connect to the last device on power as default.
  • Permit pairing device to connect as default.
  • Auto‐pairing PINCODE:”1234” as default.

Pin Description

The HC-05 Bluetooth Module has 6pins. They are as follows:


When enable is pulled LOW, the module is disabled which means the module will not turn on and it fails to communicate. When enable is left open or connected to 3.3V, the module is enabled i.e the module remains on and communication also takes place.


Supply Voltage 3.3V to 5V


Ground pin


These two pins act as an UART interface for communication


It acts as a status indicator. When the module is not connected to / paired with any other Bluetooth device, the signal goes Low. At this low state, the led flashes continuously which denotes that the module is not paired with another device. When this module is connected to/paired with any other Bluetooth device, the signal goes High. At this high state, the led blinks with a constant delay say for example 2s delay which indicates that the module is paired.


This is used to switch the module into AT command mode. To enable AT command mode, press the button switch for a second. With the help of AT commands, the user can change the parameters of this module but only when the module is not paired with any other BT device. If the module is connected to any other Bluetooth device, it starts to communicate with that device and fails to work in AT command mode.

Bluetooth Interfacing with LPC2148


Bluetooth Module

  • Rx – P0.0 (TxD0)
  • Tx – P0.1 (RxD0)

DC Motor (L293D Driver)

  • In 1 – P1.16
  • In 2 – P1.17
  • En 1 – Vcc
  • In 3 – P1.18
  • In 4 – P1.19
  • En 2 – Vcc

Bluetooth interfacing with LPC2148

Source Code – Bluetooth interfacing with LPC2148

The program given below is the HC-05 Bluetooth module program. This process is quite different from others since we are going to use android mobile to control and communicate with LPC2148. Here the Bluetooth module acts as an interface between our mobile and LPC2148 board. Before getting into the execution process, follow the given procedure:

  • First of all, the user should install an application called Bluetooth SPP PRO from the play store which is a free application.
  • After installation, pair the Bluetooth module to your mobile as like connecting one device to another using Bluetooth. The default pairing code is 1234.
  • Upload the given program to the LPC2148 board.
  • The Bluetooth SPP PRO has three types of communication modes. Here Byte stream mode is used to communicate. So select that mode and give the input as below.

F – Forward 

R – Reverse

L – Left

W – Right

  • So We can control the motor using Mobile by Bluetooth. We can use this setup for developing robots using Bluetooth.
/*   PCLK = 30MHz, BaudRate=9600  */

#define bit(x) (1<<x)
#define delay for(i=0;i<=60000;i++)

unsigned int i;

void pll()
    VPBDIV=0x02;                         //pclk=30mhz
void ser_int()
void tx(unsigned char c)
char rx()
    unsigned char a;
    return a;

int main()
    unsigned char b;
    IO1DIR=0xf0000;                     //Declaring as a output
    while(1) {
        if(b == 'F') {
            IO1SET=bit(16) | bit(18);           //IN1 = 1, IN3 = 1
            IO1CLR=bit(17) | bit(19);           //IN2 = 0, IN4 = 0
        } else if (b == 'R') {
            IO1SET=bit(17) | bit(19);           //IN2 = 1, IN4 = 1
            IO1CLR=bit(16) | bit(18);           //IN1 = 0, IN3 = 0
        } else if (b == 'W') {
            IO1SET=bit(16) ;                                            //IN1 = 1
            IO1CLR=bit(17) | bit(19) | bit(18);     //IN2 = 0, IN3 = 0, IN4 = 0
        } else if (b == 'L') {
            IO1SET=bit(18) ;                                            //IN3 = 1
            IO1CLR=bit(16) | bit(17) | bit(19);     //IN2 = 0, IN1 = 0, IN4 = 0
        } else if (b == 'S') {
            IO1CLR=bit(16) | bit(17) | bit(18) | bit(19); //IN1 = IN2 = IN3 = IN4 = 0

In our next tutorial, we will see how to interface the LDR sensor with LPC2148 (ARM7). If you want to use FreeRTOS on LPC2148, then please refer FreeRTOS series.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
STM32F7 Bootloader TutorialsRaspberry PI Pico Tutorials
STM32F103 Bootloader TutorialsRT-Thread RTOS Tutorials
Zephyr RTOS Tutorials - STM32Zephyr RTOS Tutorials - ESP32
AUTOSAR TutorialsUDS Protocol Tutorials
Product ReviewsSTM32 MikroC Bootloader Tutorial
VHDL Tutorials
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments
Table of Contents