Antarmuka yang dipergunakan untuk mengakses module ini yaitu serial TXD, RXD, VCCserta GND.
Skema rangkaian arduino Bluetooth HC-06 :
Bahan yang diperlukan :
1. Arduino Uno
2. Module Bluetooth HC-06
3. Breadboard
4. Kabel Jumper
5. Komputer + Software IDE Arduino
Source Code :
char data = 0;
void setup()
{
Serial.begin(9600);
pinMode(13, OUTPUT);
}
void loop(){
if(Serial.available() > 0 )
{
data = Serial.read();
Serial.print(data);
Serial.print("\n");
if(data=='1'){
digitalWrite(13,HIGH);
}
else if(data == '0'){
digitalWrite(13,LOW);
}
}
}
Hasil dari percobaan project ke tiga Turn on Turn off LED menggunakan Bluetooth HC-06
Untuk Sorce code 3 Buah LED, silahkan buat rangkaiannya ya.
char data = 0;
void setup()
{
Serial.begin(9600); //SERIAL PORT SCREEN
pinMode(11, OUTPUT); //LED 1
pinMode(12, OUTPUT); //LED 2
pinMode(13, OUTPUT); //LED 3
}
void loop(){
if(Serial.available() > 0 )
{
data = Serial.read();
Serial.print(data);
Serial.print("\n");
if(data == '1'){
digitalWrite(11,HIGH);
}
else if(data == '0'){
digitalWrite(11,LOW);
}
else if(data == '3'){
digitalWrite(12,HIGH);
}
else if(data == '2'){
digitalWrite(12,LOW);
}
else if(data == '5'){
digitalWrite(13,HIGH);
}
else if(data == '4'){
digitalWrite(13,LOW);
}
else if(data == 'a'){
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
}
else if(data == 'b'){
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
}
}
}