nb:diharapkan sudah megerti dasar arduino
Alat Dan Komponen :
1. Microcontroller arduino
2. Kabel kabel jumper , PCB berlubang sebaga teempat lampu led, solder, tima
modul bluetooth HC-06 atau 05
3. Smartphone android
4. Led (bisa di perkuat menggunakan relay jika ingin beban dengan kuat arus besar).
5. Apk Arduino BlueTooth Controller bisa downlod di plystore atau di https://www.4shared.com/office/I9sojobLca/Saklar_android__12_led_apk_Ard.html
6. Sotfware arduino-1.0.6-windows untuk memprogram bisa di download di https://www.4shared.com/rar/LavqFUHQei/arduino-106-windows.html
berikut codingnya: https://www.4shared.com/office/I9sojobLca/Saklar_android__12_led_apk_Ard.html
atau bisa copy langsung :
char val;
void setup() {
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop() {
if( Serial.available() >0 ) {
val = Serial.read();
Serial.println(val);
}
else if( val == 'A' ) {digitalWrite(2,HIGH);}
else if( val == 'B' ) {digitalWrite(3,HIGH);}
else if( val == 'C' ) {digitalWrite(4,HIGH);}
else if( val == 'D' ) {digitalWrite(5,HIGH);}
else if( val == 'E' ) {digitalWrite(6,HIGH);}
else if( val == 'F' ) {digitalWrite(7,HIGH);}
else if( val == 'G' ) {digitalWrite(8,HIGH);}
else if( val == 'H' ) {digitalWrite(9,HIGH);}
else if( val == 'I' ) {digitalWrite(10,HIGH);}
else if( val == 'J') {digitalWrite(11,HIGH);}
else if( val == 'K') {digitalWrite(12,HIGH);}
else if( val == 'L') {digitalWrite(13,HIGH);}
else if( val == 'a') {digitalWrite(2,LOW);}
else if( val == 'b') {digitalWrite(3,LOW);}
else if( val == 'c') {digitalWrite(4,LOW);}
else if( val == 'd') {digitalWrite(5,LOW);}
else if( val == 'e') {digitalWrite(6,LOW);}
else if( val == 'f') {digitalWrite(7,LOW);}
else if( val == 'g') {digitalWrite(8,LOW);}
else if( val == 'h') {digitalWrite(9,LOW);}
else if( val == 'i') {digitalWrite(10,LOW);}
else if( val == 'j') {digitalWrite(11,LOW);}
else if( val == 'k') {digitalWrite(12,LOW);}
else if( val == 'l') {digitalWrite(13,LOW);}
}
contoh saklar android bisa dilihat di :https://www.youtube.com/watch?v=busR-rhMfUU
apk saklar suara bisa di downlod di plystore atau di https://www.4shared.com/office/I9sojobLca/Saklar_android__12_led_apk_Ard.html
berikut codingnya saklar suara : https://www.4shared.com/office/KWbQCb4zca/Saklar_Suara__1_.html
atau bisa copy langsung :
String voice;
int
led1 = 2, //Connect LED 1 To Pin #2
led2 = 3, //Connect LED 2 To Pin #3
led3 = 4, //Connect LED 3 To Pin #4
led4 = 5 //Connect LED 4 To Pin #5
;
//--------------------------Fungsi untuk menyalakan dan mematikan semua LED
void allon(){
digitalWrite(led1, HIGH);
digitalWrite(led2, HIGH);
digitalWrite(led3, HIGH);
digitalWrite(led4, HIGH);
}
void alloff(){
digitalWrite(led1, LOW);
digitalWrite(led2, LOW);
digitalWrite(led3, LOW);
digitalWrite(led4, LOW);
}
//-----------------------------------------------------------------------//
void setup() {
Serial.begin(9600);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
}
//-----------------------------------------------------------------------//
void loop() {
while (Serial.available()){ //Cek apakah ada data yang masuk
delay(10); //Jeda waktu 10mS
char c = Serial.read(); //Menampung data serial yang masuk pada variable "c"
if (c == '#') {break;} //Keluar dari looping while saat ada karakter #
voice += c; //Menampung karakter yang masuk ke variable voice
}
if (voice.length() > 0) {
//Serial.println(voice);
//-----------------------------------------------------------------------//
if(voice == "semua hidup") {allon();} //memanggil fungsi all on
else if(voice == "semua mati"){alloff();} //memanggil fungsi all off
//----------matikan setiap led dengan perintah----------//0000000000000000000
else if(voice == "satu") {digitalWrite(led1, HIGH);}
else if(voice == "dua") {digitalWrite(led2, HIGH);}
else if(voice == "tiga") {digitalWrite(led3, HIGH);}
else if(voice == "empat") {digitalWrite(led4, HIGH);}
//----------Matikan led dengan perintah----------//
else if(voice == "satu mati") {digitalWrite(led1, LOW);}
else if(voice == "dua mati") {digitalWrite(led2, LOW);}
else if(voice == "tiga mati") {digitalWrite(led3, LOW);}
else if(voice == "empat mati") {digitalWrite(led4, LOW);}
//-----------------------------------------------------------------------//
voice="";}} //menghapus data di variable voice
contoh bisa lihat di: https://www.youtube.com/watch?v=UtbXwcVFkGc&t=24s
semoga bermanfaat.
Khoirul Aminin, ST |