Arduino Tutorial
In this tutorial I'll show you How to control Arduino with Bluetooth
using, My app developed with app inventor.
Parts Required
- 1x Arduino
- 1x Bluetooth Module ( HC-06)
- 1x Smartphone (any Android will work)
- 1x Led
- 3x resistors
- 1x Breadboard
- Jumper Cables
Schematics
Arduino Sketch
int ledblue=2;
int tx=1;
int rx=0;
char inSerial[15];
void setup(){
Serial.begin(9600);
pinMode(ledblue, OUTPUT);
pinMode(tx, OUTPUT);
pinMode(rx, INPUT);
allpinslow();
}
void loop(){
int i=0;
int m=0;
delay(500);
if (Serial.available() > 0) {
while (Serial.available() >
0) {
inSerial[i]=Serial.read();
i++;
}
inSerial[i]='\0';
Check_Protocol(inSerial);
}}
void allpinslow()
{
digitalWrite(ledblue, HIGH);
digitalWrite(ledblue, LOW);
}
void Check_Protocol(char inStr[]){
int i=0;
int m=0;
Serial.println(inStr);
if(!strcmp(inStr,"2off")){
//Led Off
allpinslow();
digitalWrite(ledblue, LOW);
Serial.println("Blue Off");
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}
if(!strcmp(inStr,"2on")){
//Led on
allpinslow();
digitalWrite(ledblue, HIGH);
Serial.println("Blue on");
for(m=0;m<11;m++){
inStr[m]=0;}
i=0;}
else{
for(m=0;m<11;m++){
inStr[m]=0;
}
i=0;
}}
Notes and Tips:
- You need to remove the RX and TX cables when you’re uploading the sketch to your Arduino.
- If the HC-05 Bluetooth Module asks for a password, It’s’1234′.
- Sometimes people connect the TX from the bluetooth module to the TX of the Arduino… that’s wrong and it won’t work. Make sure you connect it properly, the TX into RX and the RX into the TX.