Programming A Driverless Car Chapter 15: HC05 Interfacing

Bluetooth Technology

Bluetooth is a wireless technology standard for exchanging data over short distances using short wavelength UHF radio waves 2.4 to 2.485 Ghz from mobile device and building personal area networks. It can connect several devices, overcoming problems of synchronization.

Fig: Bluetooth MD-BT-HC-05-BO

HC05 module is an easy to use Bluetooth SPP( Serial Port Protocol) module, designed for transparent wireless serial connection setup.

It comes with 2 modes- Slave mode and Master mode.

HC-05 can communicate with Arduino board at a baud rate of 9600 bits per second. There are HC-05 boards present in the market which can communicate with 3800 bits per second even. HC-06 only works on Slave mode.

  • HC-05 blinks constant ready light when on and searching for devices to connect to
  • HC-05 indicates connected when blinking light is stalled and not constant

AT Command:

Connections:

Fig: Connections with BLUETOOTH device

 

LAB: Android Controlled Robot

 

int m11=6;

int m12=9;

int m21=10;

int m22=11;

void setup()

{

pinMode(m11,OUTPUT);

pinMode(m12,OUTPUT);

pinMode(m21,OUTPUT);

pinMode(m22,OUTPUT);

Serial.begin(9600);

}

void loop()

{

while(Serial.available())

{

char data=Serial.read();

if(data== ‘f’)

{

digitalWrite(m11,LOW);

digitalWrite(m12,HIGH);

digitalWrite(m21,LOW);

digitalWrite(m22,HIGH);

}

else if(data== ‘b’)

{

digitalWrite(m11,HIGH);

digitalWrite(m12,LOW);

digitalWrite(m21,HIGH);

digitalWrite(m22,LOW)

}

else if(data== ‘s’)

{

digitalWrite(m11,LOW);

digitalWrite(m12,LOW);

digitalWrite(m21,LOW);

digitalWrite(m22,LOW);

}

else if(data == ‘r’)

{

digitalWrite(m11,LOW);

digitalWrite(m12,LOW);

digitalWrite(m21,LOW);

digitalWrite(m22,HIGH);

}

else if(data == ‘l’)

{

digitalWrite(m11,LOW);

digitalWrite(m12,HIGH);

digitalWrite(m21,LOW);

digitalWrite(m22,LOW);

 

}

}

}

 

OUTPUT:

Manage all the settings according to your need and it is done.

Written By
More from Level Ten

Programming A Driverless Car Chapter 15: HC05 Interfacing

Bluetooth Technology Bluetooth is a wireless technology standard for exchanging data over...
Read More