Learning Arduino for beginners EP#20 Android Bluetooth control

In this episode we will take a look at how you can use an Android device with a Bluetooth module (HC-06 or HC-05) to control your Arduino project…

How to connect a HC-05 or HC-06

Click here to buy a HC-05 or HC-06

 

 

ARDUINO CODE:

#define led 13

void setup() {
Serial.begin(9600);
pinMode(led,OUTPUT);
}

void loop() {
if (Serial.available() >= 2 )
{
unsigned int a = Serial.read();
unsigned int b = Serial.read();
unsigned int val = (b * 256) + a;

if (val == 100)
{
digitalWrite(led,HIGH);
}

else if (val == 200)
{
digitalWrite(led,LOW);
}
}

delay(250);
}

Advertisements