Pengetahuan Dasar Input Data Arduino dengan Remote TV

Software

-Arduino

Library IRRemote

Hardware

-Remote TV ( NEC, SONY, PANASONIC, SANYO atau yg lainya) pada contoh ini menggunakan remote dgn data kode  NEC  spt pd gb ke-2

-Sensor TV /IR senor

-Arduino board

PINIRREMOTE.jpg

 

Rangkai spt gambar berikut.  pin data untuk contoh ini no 8

irremote.jpg

Code Program

#include <IRremote.h>

int RECV_PIN = 8;
int y=0,data;
IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
Serial.begin(9600);
irrecv.enableIRIn(); // Start the receiver
}

void loop()
{
displayUtama();
pilihMenuUtama();

}
void displayUtama(){
Serial.println(“Display Utama”);
}

//==========================================
void pilihMenuUtama(void)
{ int y=0;
int Loop0=1; // loop1 baca menu,loop2 input data.

Serial.println(“pilihMenuUtama”);
while(Loop0) //loop baca #
{
y = key();
if( y == 1) // pilih menu #
{
menuUtama(); //tampilkan menu utama lalu menuju loop 2 baca keypad ke-2
Loop0=0;
}
if( y == 2) // pilih menu #
{
menuUtama1(); //tampilkan menu utama lalu menuju loop 2 baca keypad ke-2
Loop0=0;
}
} // end while(Loop0)

}
//=============================
int bacaRemotedanEnter(){
//input data integer dan tekan #
int y=0;
int Loop0=1; // loop1 baca menu,loop2 input data.
int data=0;
Serial.println(“baca remote dan enter”);
while(Loop0) //loop baca #
{
y = key();
if( y <10 ) // pilih menu 1-9
{
if(y==0 && results.value !=0xFF6897) continue;
data =data*10+y;
Serial.println(data);

}
if( y == ‘#’) // pilih menu #
{
Loop0=0;
return data;
}

delay(300); // Do not get immediate repeat
} // end while(Loop0)
}
//=============================
void menuUtama(){
Serial.println(“input plan:”);
int datahasil = bacaRemotedanEnter();
Serial.print(“hasil baca remote dan enter : “);
Serial.println(datahasil);
return;
}
void menuUtama1(){
Serial.println(“input cycle:”);
int datahasil = bacaRemotedanEnter();
Serial.print(“hasil baca remote dan enter : “);
Serial.println(datahasil);
return;
}
//=========================================
int key(void)
{

char KEY = 1 ;
while(KEY){
if (irrecv.decode(&results))
{
// Serial.println(results.value, HEX);
if(results.value != 0xFFFFFFFF)
{

y= translateIR();

KEY=0;
irrecv.resume(); // Receive the next value
return y;
}
delay(100); // Do not get immediate repeat
irrecv.resume(); // Receive the next value
}
}
}

//========================================================

int translateIR() // data tergantung kode masing2 merk remote
{
if(results.value== 0xFF30CF) return 1;
if(results.value== 0xFF18E7) return 2;
if(results.value== 0xFF7A85) return 3;
if(results.value== 0xFF10EF) return 4;
if(results.value== 0xFF38C7) return 5;
if(results.value== 0xFF5AA5) return 6;
if(results.value== 0xFF42BD) return 7;
if(results.value== 0xFF4AB5) return 8;
if(results.value== 0xFF52AD) return 9;
if(results.value== 0xFF6897) return 0;
if(results.value== 16769055) return ‘#’;

}
//======================================

hasilbacairremoteTV

Advertisements

About pccontrol

Berisi Tutorial Menggunakan PC untuk mengontrol Peralatan dengan cara mudah & praktis untuk pemula.

Posted on 02/06/2017, in Arduino, Daftar isi. Bookmark the permalink. Leave a comment.

Komentar ,Saran atau Pertanyaan

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: