Kamis, 03 November 2016

Arduino + Android Voice Commands Control

Kendali Relay / Lampu dengan Perintah Suara menggunakan Arduino dan Android Voice Control


Kali ini saya akan memberikan tutorial tentang pengendalian Relay (yang dapat kita sambungkan dengan berbagai perangkat seperti Lampu,Pompa Air,TV,AC,Kulkas dan beban lainya) menggunakan 'perintah suara' yang kita ucapkan pada Hp Android kita.

Disini kita menggunakan koneksi bluetooth untuk menghubungkan Ponsel Pintar Android milik Anda dengan Perangkat Arduino.Berikut adalah bahan bahan untuk membuat project kita kali ini :

A.Bahan dan Module yang dibutuhkan

-1Unit Arduino Uno / Nano / Pro mini / jenis lain.
-1Unit Module Bluetooth HC-06 atau HC-05
-1Unit Relay Module 8Channel atau 4 Channel 5V
-1Unit Hp Android

Note : klik www.tokopedia.com/rajacell untuk mendapatkan semua kebutuhan module dalam project ini


B.Wiring  

1.Wiring Bluetooth HC-05/06 dengan Arduino
 Bluetooth Module <--> Arduino
* VCC      : Pin +5V
* GND     : Pin GND
* TX         : Pin D2
* RX         : Pin D3

2.Wiring Module Relay 8Ch dengan Arduino
Relay Module <--> Arduino
* GND   : Pin GND
* IN1      : Pin D4
* IN2      : Pin D5
* IN3      : Pin D6
* IN4      : Pin D7
* IN5      : Pin D8
* IN6      : Pin D9
* IN7      : Pin D10
* IN8      : Pin D11
* VCC    : Pin +5V

(apabila anda menggunakan Relay 4channel abaikan sambungan IN5 hingga IN8)

Pastikan wiring sesuai gambar dibawah ini :






C.Aplikasi SOPO Bluetooth Voice Control

Silahkan download aplikasi SOPO Bluetooth Voice Control pada Google Play store pada link berikut :

https://play.google.com/store/apps/details?id=appinventor.ai_dani_ardan.Sopo

atau via Google Drive pada link berikut :

https://drive.google.com/file/d/0B_sJguJA9LQHdk1hUUpoNk5tX2M/view


D.Library

Pada project kali ini kita tidak membutuhkan Library External sehingga kita tidak perlu menambahkan library apapun ke dalam sistem arduino kita.Library yang kita pakai adalah library internal yaitu 'SoftwareSerial' dan juga di coding versi 2 akan ada penambahan library 'EEPROM' yang juga sudah include kedalam software Arduino IDE.

E.Sourch Code

Copy paste coding dibawah ini ke dalam Arduino IDE anda dan Upload ke Board Arduino Anda :


Versi 1 (tanpa penggunaan memory Eeprom)

//Coding berikut dibuat oleh Dani untuk www.belajarduino.com
//Silahkan Download Aplikasi Android untuk control coding ini pada link dibawah ini
//https://play.google.com/store/apps/details?id=appinventor.ai_dani_ardan.Sopo
//Support by RAJACELL - BEKASI
//Semua module yang dibutuhkan dapat dibeli di www.tokopedia.com/rajacell
#include <SoftwareSerial.h>
SoftwareSerial Bluetooth(2, 3); // RX | TX
//Pin Tx Bluetooth ke Pin D2 Arduino
//Pin Rx Bluetooth ke Pin D3 Arduino

#define Ch1 4
#define Ch2 5
#define Ch3 6
#define Ch4 7
#define Ch5 8
#define Ch6 9
#define Ch7 10
#define Ch8 11
//Define untuk Relay Module Active LOW
#define ON 0
#define OFF 1

//Define untuk Lampu LED atau Relay Module Active HIGH
//#define ON 1
//#define OFF 0

//Nama-nama panggilan untuk setiap channel Relay
//Silahkan diganti sesuai kebutuhan anda
//Misal : String Name1 = "Lampu Depan";
//INGAT! Kapitalisasi huruf Harus sesuai dengan RESULT Text yang tertera pada Aplikasi di Hp
String Name1 = "merah";
String Name2 = "kuning";
String Name3 = "hijau";
String Name4 = "biru";
String Name5 = "putih";
String Name6 = "magenta";
String Name7 = "ungu";
String Name8 = "jingga";
String All = "semua";

//3 Jenis Kata untuk Mendefinisikan kondisi ON
//Bisa dirubah sesuai kebutuhan misal String Key_ON_3="aktif";
String Key_ON_1 = "on";
String Key_ON_2 = "menyala";
String Key_ON_3 = "hidup";

//3 Jenis Kata untuk Mendefinisikan kondisi OFF
//Bisa dirubah sesuai kebutuhan misal String Key_OFF_2="nonaktif";
String Key_OFF_1 = "of";
String Key_OFF_2 = "padam";
String Key_OFF_3 = "mati";

//Notif ke Serial monitor atau ke LCD
String Notif_ON = " Dinyalakan";
String Notif_OFF = " Dimatikan";

//Coding berikut dibuat oleh Dani untuk www.belajarduino.com
//Silahkan Download Aplikasi Android untuk control coding ini pada link dibawah ini
//https://play.google.com/store/apps/details?id=appinventor.ai_dani_ardan.Sopo
//Support by RAJACELL - BEKASI
//Semua module yang dibutuhkan dapat dibeli di www.tokopedia.com/rajacell
void setup() {
  // put your setup code here, to run once:
  //Mencegah Semua Relay on beberapa saat setelah sistem reset/booting
pinMode (Ch1,OUTPUT); digitalWrite (Ch1,OFF);
pinMode (Ch2,OUTPUT); digitalWrite (Ch2,OFF);
pinMode (Ch3,OUTPUT); digitalWrite (Ch3,OFF);
pinMode (Ch4,OUTPUT); digitalWrite (Ch4,OFF);
pinMode (Ch5,OUTPUT); digitalWrite (Ch5,OFF);
pinMode (Ch6,OUTPUT); digitalWrite (Ch6,OFF);
pinMode (Ch7,OUTPUT); digitalWrite (Ch7,OFF);
pinMode (Ch8,OUTPUT); digitalWrite (Ch8,OFF);
Serial.begin (9600); //Memulai koneksi Serial D0 D1
Bluetooth.begin (9600); //Memulai koneksi Serial dengan Bluetooth Module
}

//Buffer char yang dikirim dari aplikasi android
String Speech; 

void loop() {
  // put your main code here, to run repeatedly:
 if(Bluetooth.available()){
    char lastCharRead = Bluetooth.read();
    Speech += lastCharRead; 
    //Serial.print (lastCharRead);
    //Serial.print (Speech);
       
       if (Speech.length() > 0) {
           
//************Membaca data Voice dan Melakukan index kata

            //Kendali Channel 1
            if(Speech.indexOf(Name1)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 1
              Serial.print(Name1); Serial.println(Notif_ON);
              digitalWrite (Ch1,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name1)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 1
              Serial.print(Name1); Serial.println(Notif_OFF);
              digitalWrite (Ch1,OFF);
              Speech = "";}
           
            //Kendali Channel 2
            if(Speech.indexOf(Name2)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 2
              Serial.print(Name2); Serial.println(Notif_ON);
              digitalWrite (Ch2,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name2)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 2
              Serial.print(Name2); Serial.println(Notif_OFF);
              digitalWrite (Ch2,OFF);
              Speech = "";}

              //Kendali Channel 3
            if(Speech.indexOf(Name3)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 3
              Serial.print(Name3); Serial.println(Notif_ON);
              digitalWrite (Ch3,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name3)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 3
              Serial.print(Name3); Serial.println(Notif_OFF);
              digitalWrite (Ch3,OFF);
              Speech = "";}

              //Kendali Channel 4
            if(Speech.indexOf(Name4)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 4
              Serial.print(Name4); Serial.println(Notif_ON);
              digitalWrite (Ch4,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name4)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 4
              Serial.print(Name4); Serial.println(Notif_OFF);
              digitalWrite (Ch4,OFF);
              Speech = "";}

              //Kendali Channel 5
            if(Speech.indexOf(Name5)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 5
             Serial.print(Name5); Serial.println(Notif_ON);
              digitalWrite (Ch5,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name5)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 5
              Serial.print(Name5); Serial.println(Notif_OFF);
              digitalWrite (Ch5,OFF);
              Speech = "";}

              //Kendali Channel 6
            if(Speech.indexOf(Name6)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 6
              Serial.print(Name6); Serial.println(Notif_ON);
              digitalWrite (Ch6,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name6)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 6
              Serial.print(Name6); Serial.println(Notif_OFF);
              digitalWrite (Ch6,OFF);
              Speech = "";}

              //Kendali Channel 7
            if(Speech.indexOf(Name7)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 7
              Serial.print(Name7); Serial.println(Notif_ON);
              digitalWrite (Ch7,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name7)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 7
              Serial.print(Name7); Serial.println(Notif_OFF);
              digitalWrite (Ch7,OFF);
              Speech = "";}

              //Kendali Channel 8
            if(Speech.indexOf(Name8)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 8
              Serial.print(Name8); Serial.println(Notif_ON);
              digitalWrite (Ch8,ON);
              Speech = "";} 
              else if(Speech.indexOf(Name8)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 8
              Serial.print(Name8); Serial.println(Notif_OFF);
              digitalWrite (Ch8,OFF);
              Speech = "";}

              //Kendali Semua Channel
            if(Speech.indexOf(All)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON All Channel
              Serial.print(All); Serial.println(Notif_ON);
              digitalWrite (Ch1,ON); digitalWrite (Ch2,ON); digitalWrite (Ch3,ON); digitalWrite (Ch4,ON);
              digitalWrite (Ch5,ON); digitalWrite (Ch6,ON); digitalWrite (Ch7,ON); digitalWrite (Ch8,ON);
              Speech = "";} 
              else if(Speech.indexOf(All)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF All Channel
              Serial.print(All); Serial.println(Notif_OFF);
              digitalWrite (Ch1,OFF); digitalWrite (Ch2,OFF); digitalWrite (Ch3,OFF); digitalWrite (Ch4,OFF);
              digitalWrite (Ch5,OFF); digitalWrite (Ch6,OFF); digitalWrite (Ch7,OFF); digitalWrite (Ch8,OFF);
              Speech = "";}
             
               
      }   
   }    
}
//Coding berikut dibuat oleh Dani untuk www.belajarduino.com
//Silahkan Download Aplikasi Android untuk control coding ini pada link dibawah ini
//https://play.google.com/store/apps/details?id=appinventor.ai_dani_ardan.Sopo
//Support by RAJACELL - BEKASI
//Semua module yang dibutuhkan dapat dibeli di www.tokopedia.com/rajacell




Versi 2 (dengan tambahan memory Eeprom)

//Coding berikut dibuat oleh Dani untuk www.belajarduino.com
//Silahkan Download Aplikasi Android untuk control coding ini pada link dibawah ini
//https://play.google.com/store/apps/details?id=appinventor.ai_dani_ardan.Sopo
//Support by RAJACELL - BEKASI
//Semua module yang dibutuhkan dapat dibeli di www.tokopedia.com/rajacell
#include <SoftwareSerial.h>
#include <EEPROM.h>
SoftwareSerial Bluetooth(2, 3); // RX | TX
//Pin Tx Bluetooth ke Pin D2 Arduino
//Pin Rx Bluetooth ke Pin D3 Arduino

#define Ch1 4
#define Ch2 5
#define Ch3 6
#define Ch4 7
#define Ch5 8
#define Ch6 9
#define Ch7 10
#define Ch8 11
//Define untuk Relay Module Active LOW
#define ON 0
#define OFF 1

byte State1 = 1;
byte State2 = 1;
byte State3 = 1;
byte State4 = 1;
byte State5 = 1;
byte State6 = 1;
byte State7 = 1;
byte State8 = 1;

//Define untuk Lampu LED atau Relay Module Active HIGH
//#define ON 1
//#define OFF 0

//Nama-nama panggilan untuk setiap channel Relay
//Silahkan diganti sesuai kebutuhan anda
//Misal : String Name1 = "Lampu Depan";
//INGAT! Kapitalisasi huruf Harus sesuai dengan RESULT Text yang tertera pada Aplikasi di Hp
String Name1 = "1";
String Name2 = "2";
String Name3 = "3";
String Name4 = "4";
String Name5 = "5";
String Name6 = "6";
String Name7 = "7";
String Name8 = "8";
String All = "semua";

//3 Jenis Kata untuk Mendefinisikan kondisi ON
//Bisa dirubah sesuai kebutuhan misal String Key_ON_3="aktif";
String Key_ON_1 = "on";
String Key_ON_2 = "menyala";
String Key_ON_3 = "hidup";

//3 Jenis Kata untuk Mendefinisikan kondisi OFF
//Bisa dirubah sesuai kebutuhan misal String Key_OFF_2="nonaktif";
String Key_OFF_1 = "of";
String Key_OFF_2 = "padam";
String Key_OFF_3 = "dimatikan";

//Notif ke Serial monitor atau ke LCD
String Notif_ON = " Dinyalakan";
String Notif_OFF = " Dimatikan";

//Coding berikut dibuat oleh Dani untuk www.belajarduino.com
//Silahkan Download Aplikasi Android untuk control coding ini pada link dibawah ini
//https://play.google.com/store/apps/details?id=appinventor.ai_dani_ardan.Sopo
//Support by RAJACELL - BEKASI
//Semua module yang dibutuhkan dapat dibeli di www.tokopedia.com/rajacell
void setup() {
  // put your setup code here, to run once:
  //Mencegah Semua Relay on beberapa saat setelah sistem reset/booting
pinMode (Ch1,OUTPUT); digitalWrite (Ch1,OFF);
pinMode (Ch2,OUTPUT); digitalWrite (Ch2,OFF);
pinMode (Ch3,OUTPUT); digitalWrite (Ch3,OFF);
pinMode (Ch4,OUTPUT); digitalWrite (Ch4,OFF);
pinMode (Ch5,OUTPUT); digitalWrite (Ch5,OFF);
pinMode (Ch6,OUTPUT); digitalWrite (Ch6,OFF);
pinMode (Ch7,OUTPUT); digitalWrite (Ch7,OFF);
pinMode (Ch8,OUTPUT); digitalWrite (Ch8,OFF);

Serial.begin (9600); //Memulai koneksi Serial D0 D1
Bluetooth.begin (9600); //Memulai koneksi Serial dengan Bluetooth Module

ReadEEPROM ();
}

//Buffer char yang dikirim dari aplikasi android
String Speech; 

void loop() {
  // put your main code here, to run repeatedly:
 if(Bluetooth.available()){
    char lastCharRead = Bluetooth.read();
    Speech += lastCharRead; 
    //Serial.print (lastCharRead);
    //Serial.print (Speech);
       
       if (Speech.length() > 0) {
           
//************Membaca data Voice dan Melakukan index kata

            //Kendali Channel 1
            if(Speech.indexOf(Name1)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 1
              Serial.print(Name1); Serial.println(Notif_ON);
              relayON(Ch1);
              Speech = "";} 
              else if(Speech.indexOf(Name1)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 1
              Serial.print(Name1); Serial.println(Notif_OFF);
              relayOFF(Ch1);
              Speech = "";}
           
            //Kendali Channel 2
            if(Speech.indexOf(Name2)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 2
              Serial.print(Name2); Serial.println(Notif_ON);
              relayON(Ch2);
              Speech = "";} 
              else if(Speech.indexOf(Name2)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 2
              Serial.print(Name2); Serial.println(Notif_OFF);
              relayOFF(Ch2);
              Speech = "";}

              //Kendali Channel 3
            if(Speech.indexOf(Name3)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 3
              Serial.print(Name3); Serial.println(Notif_ON);
              relayON(Ch3);
              Speech = "";} 
              else if(Speech.indexOf(Name3)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 3
              Serial.print(Name3); Serial.println(Notif_OFF);
              relayOFF(Ch3);
              Speech = "";}

              //Kendali Channel 4
            if(Speech.indexOf(Name4)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 4
              Serial.print(Name4); Serial.println(Notif_ON);
              relayON(Ch4);
              Speech = "";} 
              else if(Speech.indexOf(Name4)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 4
              Serial.print(Name4); Serial.println(Notif_OFF);
              relayOFF(Ch4);
              Speech = "";}

              //Kendali Channel 5
            if(Speech.indexOf(Name5)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 5
              Serial.print(Name5); Serial.println(Notif_ON);
              relayON(Ch5);
              Speech = "";} 
              else if(Speech.indexOf(Name5)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 5
              Serial.print(Name5); Serial.println(Notif_OFF);
              relayOFF(Ch5);
              Speech = "";}

              //Kendali Channel 6
            if(Speech.indexOf(Name6)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 6
              Serial.print(Name6); Serial.println(Notif_ON);
              relayON(Ch6);
              Speech = "";} 
              else if(Speech.indexOf(Name6)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 6
              Serial.print(Name6); Serial.println(Notif_OFF);
              relayOFF(Ch6);
              Speech = "";}

              //Kendali Channel 7
            if(Speech.indexOf(Name7)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 7
              Serial.print(Name7); Serial.println(Notif_ON);
              relayON(Ch7);
              Speech = "";} 
              else if(Speech.indexOf(Name7)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 7
              Serial.print(Name7); Serial.println(Notif_OFF);
              relayOFF(Ch7);
              Speech = "";}

              //Kendali Channel 8
            if(Speech.indexOf(Name8)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON Channel 8
              Serial.print(Name8); Serial.println(Notif_ON);
              relayON(Ch8);
              Speech = "";} 
              else if(Speech.indexOf(Name8)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF Channel 8
              Serial.print(Name8); Serial.println(Notif_OFF);
              relayOFF(Ch8);
              Speech = "";}

              //Kendali Semua Channel
            if(Speech.indexOf(All)>=0 && (Speech.indexOf(Key_ON_1)>=0 || Speech.indexOf(Key_ON_2)>=0 || Speech.indexOf(Key_ON_3)>=0)){
              //Action ON All Channel
              Serial.print(All); Serial.println(Notif_ON);
              relayON(Ch1); relayON(Ch2); relayON(Ch3); relayON(Ch4); relayON(Ch5); relayON(Ch6); relayON(Ch7); relayON(Ch8);
              Speech = "";} 
              else if(Speech.indexOf(All)>=0 && (Speech.indexOf(Key_OFF_1)>=0 || Speech.indexOf(Key_OFF_2)>=0 || Speech.indexOf(Key_OFF_3)>=0)){
              //Action OFF All Channel
              Serial.print(All); Serial.println(Notif_OFF);
              relayOFF(Ch1); relayOFF(Ch2); relayOFF(Ch3); relayOFF(Ch4); relayOFF(Ch5); relayOFF(Ch6); relayOFF(Ch7); relayOFF(Ch8);
              Speech = "";}
             
               
      }   
   }    
}
//Coding berikut dibuat oleh Dani untuk www.belajarduino.com
//Silahkan Download Aplikasi Android untuk control coding ini pada link dibawah ini
//https://play.google.com/store/apps/details?id=appinventor.ai_dani_ardan.Sopo
//Support by RAJACELL - BEKASI
//Semua module yang dibutuhkan dapat dibeli di www.tokopedia.com/rajacell
void ReadEEPROM (){
  State1 = EEPROM.read(Ch1);
  State2 = EEPROM.read(Ch2);
  State3 = EEPROM.read(Ch3);
  State4 = EEPROM.read(Ch4);
  State5 = EEPROM.read(Ch5);
  State6 = EEPROM.read(Ch6);
  State7 = EEPROM.read(Ch7);
  State8 = EEPROM.read(Ch8);
  digitalWrite(Ch1,State1);
  Serial.print(F("Posisi Terakhir relay1 = "));
  if(State1==0){Serial.println("ON");} else {Serial.println("OFF");}

  digitalWrite(Ch2,State2);
  Serial.print(F("Posisi Terakhir relay2 = "));
  if(State2==0){Serial.println("ON");} else {Serial.println("OFF");}

  digitalWrite(Ch3,State3);
  Serial.print(F("Posisi Terakhir relay3 = "));
  if(State3==0){Serial.println("ON");} else {Serial.println("OFF");}

  digitalWrite(Ch4,State4);
  Serial.print(F("Posisi Terakhir relay4 = "));
  if(State4==0){Serial.println("ON");} else {Serial.println("OFF");}

  digitalWrite(Ch5,State5);
  Serial.print(F("Posisi Terakhir relay5 = "));
  if(State5==0){Serial.println("ON");} else {Serial.println("OFF");}
  
  digitalWrite(Ch6,State6);
  Serial.print(F("Posisi Terakhir relay6 = "));
  if(State6==0){Serial.println("ON");} else {Serial.println("OFF");}
  
  digitalWrite(Ch7,State7);
  Serial.print(F("Posisi Terakhir relay7 = "));
  if(State7==0){Serial.println("ON");} else {Serial.println("OFF");}
  
  digitalWrite(Ch8,State8);
  Serial.print(F("Posisi Terakhir relay8 = "));
  if(State8==0){Serial.println("ON");} else {Serial.println("OFF");}
}

void relayON (uint8_t r) {
  digitalWrite (r,ON); 
      EEPROM.write(r, 0);
        Serial.print("Relay ");
        Serial.print(r-3);
        Serial.println(" ON by Voice Command");
}

void relayOFF (uint8_t r) {
  digitalWrite (r,OFF); 
      EEPROM.write(r, 1);
        Serial.print("Relay ");
        Serial.print(r-3);
        Serial.println(" OFF by Voice Command");
} 
 


F.Test & Trial

-Rangkai Module dan Arduino sesuai wiring
-Upload sketch program diatas (pakai yang Versi 1 terlebih dulu sebelum mencoba yang Ver.2)
-Install aplikasi "SOPO" di Hp Android anda dan lakukan pengaturan

*Setting / Pengaturan
*Input & Language / Bahasa dan Masukan
*Text to Speech / Text hingga Bicara
*Pilih mesin TTS yang diutamakan "Google Text-to-Speech" (jika Hp anda Samsung)
*Atur "Status Bahasa default" / "Default Language" menjadi "Bahasa Indonesia (indonesia)"
*Aplikasi SOPO mendukung Offline Voice Recognition pada beberapa Hp Android

-Buka aplikasi "SOPO"
-Hubungkan aplikasi dengan module bluetooth yang terpasang di Arduino untuk koneksi awal.
  *Untuk koneksi berikutnya hanya perlu tekan tombol voice dan katakan "Sambungkan Perangkat"

  *Apabila module bluetooth anda belum terlihat pada daftar perangkat yang tampil pada aplikasi ini
 silahkan test pairing terlebih dahulu melalui menu Pengaturan/Setting->Bluetooth->Cari perangkat
 kemudian hubungkan atau pasangkan dan buka kembali aplikasi Arduino Bluetooth Controllernya.

-Tekan tombol voice dan katakan beberapa kata yang sudah terdaftar di coding Arduino misal :
  "satu menyala" atau "Nyalakan Semua"
-Selamat Mencoba..........

9 komentar:

  1. om untuk pemasangan lednya bagaimana ? terima kasih

    BalasHapus
  2. tutorial yang bermanfaat..
    bang, kalo berkenan mohon dimuat tutorial sms gateway dengan modem wavecom. terima kasih

    BalasHapus
  3. Komentar ini telah dihapus oleh pengarang.

    BalasHapus
  4. Maaf pak dani,kenapa ketika perintah "Nyalakan Semua" LED malah mati dan begitu juga sebaliknya , ketika diperitahkan "Matikan semua" LED malah menyala,dan perintah2 yg lain...jadi terbalik gitu?apa ada yg salah ya pak?jika ada dimana baris yg harus dirubah? terimakasih sebelumnya.

    BalasHapus
    Balasan
    1. Bagian
      #define ON 0
      #define OFF 1

      Seharusnya
      #define ON 1
      #define OFF 0

      Hapus
  5. salam kenal,,,sangat bemanfaat,,apakah sketchnya udh full,dan apakah bisa bekerja klu tanpa jaringan internet utk menjalankan mesin TTS google speech

    BalasHapus

  6. sketch_aug30a:139: error: 'Ch4' was not declared in this scope
    sketch_aug30a:143: error: expected primary-expression before '=' token
    sketch_aug30a:143: error: expected primary-expression before '=' token
    sketch_aug30a:143: error: expected primary-expression before '=' token
    sketch_aug30a:143: error: expected primary-expression before '=' token
    sketch_aug30a:148: error: expected primary-expression before '=' token
    sketch_aug30a:148: error: expected primary-expression before '=' token
    sketch_aug30a:148: error: expected primary-expression before '=' token
    sketch_aug30a:148: error: expected primary-expression before '=' token
    sketch_aug30a:155: error: expected primary-expression before '=' token
    sketch_aug30a:155: error: expected primary-expression before '=' token
    sketch_aug30a:155: error: expected primary-expression before '=' token
    sketch_aug30a:155: error: expected primary-expression before '=' token
    sketch_aug30a:160: error: expected primary-expression before '=' token
    sketch_aug30a:160: error: expected primary-expression before '=' token
    sketch_aug30a:160: error: expected primary-expression before '=' token
    sketch_aug30a:160: error: expected primary-expression before '=' token
    sketch_aug30a:167: error: 'Name7' was not declared in this scope
    sketch_aug30a:167: error: expected primary-expression before '=' token
    sketch_aug30a:167: error: expected primary-expression before '=' token
    sketch_aug30a:167: error: expected primary-expression before '=' token
    sketch_aug30a:167: error: expected primary-expression before '=' token
    sketch_aug30a:172: error: expected primary-expression before '=' token
    sketch_aug30a:172: error: expected primary-expression before '=' token
    sketch_aug30a:172: error: expected primary-expression before '=' token
    sketch_aug30a:172: error: expected primary-expression before '=' token
    sketch_aug30a:179: error: expected primary-expression before '=' token
    sketch_aug30a:179: error: expected primary-expression before '=' token
    sketch_aug30a:179: error: expected primary-expression before '=' token
    sketch_aug30a:179: error: expected primary-expression before '=' token
    sketch_aug30a:184: error: expected primary-expression before '=' token
    sketch_aug30a:184: error: expected primary-expression before '=' token
    sketch_aug30a:184: error: expected primary-expression before '=' token
    sketch_aug30a:184: error: expected primary-expression before '=' token
    sketch_aug30a:191: error: expected primary-expression before '=' token
    sketch_aug30a:191: error: expected primary-expression before '=' token
    sketch_aug30a:191: error: expected primary-expression before '=' token
    sketch_aug30a:191: error: expected primary-expression before '=' token
    sketch_aug30a:194: error: 'Ch2' was not declared in this scope
    sketch_aug30a:194: error: 'Ch3' was not declared in this scope
    sketch_aug30a:194: error: 'Ch4' was not declared in this scope
    sketch_aug30a:197: error: expected primary-expression before '=' token
    sketch_aug30a:197: error: expected primary-expression before '=' token
    sketch_aug30a:197: error: expected primary-expression before '=' token
    sketch_aug30a:197: error: expected primary-expression before '=' token
    sketch_aug30a:200: error: 'Ch2' was not declared in this scope
    sketch_aug30a:200: error: 'Ch3' was not declared in this scope
    sketch_aug30a:200: error: 'Ch4' was not declared in this scope
    sketch_aug30a.cpp: At global scope:
    sketch_aug30a:209: error: 'codes' does not name a type

    sir iam getting this error please help me

    BalasHapus
  7. Bagus ya tutorial ini.boleh aku tanya bang, ada nggak mp3 mengontrol module relay 8 cannel, jika ada lengkap dengan codenya bang, terima kasih sebelumnya.

    BalasHapus

Copyright © 2014 Belajar Arduino | Designed With By Blogger Templates | Distributed By Gooyaabi Templates
Scroll To Top