remote Infra Red dengan output LED buzzer dan relay

Pasang jumper dihihadiy ke Infra red sensor, LED, buzzer

Remote Control yang dipakai adalah Sony, seri trinitron

Sensor IR pada digihadiy memakai sensor TSOP

Contoh program berikut adalah ketika tombol ditekan, led sensor akan berkedip. dan berikut tombol serta fungsinya

Tombol 1  membunyikan buzzer

Tombol 2 relay ON

Tombol 3 LED ON

Tombol 4 toggle buzzer

Tombol 5 toggle relay

Tombol 6 toggle LED

tombol 7 Buzzer OFF

tombol 8 relay OFF

tombol 9 LED OFF

untuk trouble shooting:

– pastikan LED di sensor berkedip

– cek semua jumper yang berhubungan ke LED, sensor relay dan buzzer, pastikan terpasang dengan benar

– Kode yang benar ditampilkan di 4 LED sebagai kombinasi biner

– Periksa settingan fusebit seperti ini

– pastikan koneksi PCB tidak kotor atau short, bersihkan dengan alkohol atau thinner, disapu dengan kuas. terutama di bagian kristal dan jalur dari sensor TSOP menuju ke interrupt INT1

-pastikan jarak remote tidak terlalu jauh, dan tidak ada sumber noise infrared lain, diindikasikan dengan LED indikator yang hanya berkedip ketika ada sinyal dari Remote kita saja

//========================================================
#define F_CPU 8000000UL
#include “util/delay.h”
#include “avr/io.h”
#include “avr/interrupt.h”

#define T_pulse 28    //14
#define T_header 60    //30

void port_init(void);
void timer0_init(void);
unsigned int read_IR (void);
void init_devices(void);

unsigned char CODE;

void port_init(void)
{
DDRB = 0x0f;
PORTB = 0x00;
DDRD |= (1<<5);
DDRD |= (1<<6);
DDRD |= (1<<7);
}

void timer0_init(void)
{
TCCR0 = 0x04; //CLK / 64
TCNT0 = 0; //reset the timer
}

ISR(INT1_vect)
{
unsigned char count;
unsigned int IR_input;

TCNT0 = 0;
while(!(PIND & 0x08));
count = TCNT0;
// deteksi pulsa START
if(count < T_header)
{
return;
}
// jika > 1,2 ms -> paket data=valid cek datanya
IR_input = read_IR ();
CODE=(unsigned char) ((IR_input & 0xff00) >> 8);
//    number=10;
if(CODE==0x00){PORTD|=(1<<7);_delay_ms(200);}    //tombol 1 nyalakan buzzer
if(CODE==0x01){PORTD|=(1<<6);_delay_ms(200);}    //tombol 2 nyalakan relay
if(CODE==0x02){PORTD|=(1<<5);_delay_ms(200);}    //tombol 3 nyalakan LED
if(CODE==0x03){PORTD^=(1<<7);_delay_ms(200);}    //tombol 1 toggle buzzer
if(CODE==0x04){PORTD^=(1<<6);_delay_ms(200);}    //tombol 2 toggle relay
if(CODE==0x05){PORTD^=(1<<5);_delay_ms(200);}    //tombol 3 toggle LED
if(CODE==0x06){PORTD&=~(1<<7);_delay_ms(200);}    //tombol 1 matikan buzzer
if(CODE==0x07){PORTD&=~(1<<6);_delay_ms(200);}    //tombol 2 matikan relay
if(CODE==0x08){PORTD&=~(1<<5);_delay_ms(200);}    //tombol 3 matikan LED
PORTB=CODE;
}

unsigned int read_IR (void)
{
unsigned char pulseCount=0, code = 0, address = 0, timerCount;
unsigned int IR_input;

while(pulseCount < 7)
{
while(PIND & 0x08);
TCNT0 = 0;
while(!(PIND & 0x08));
pulseCount++;

timerCount = TCNT0;

if(timerCount > T_pulse)
code = code | (1 << (pulseCount-1));
else
code = code & ~(1 << (pulseCount-1));
}
pulseCount = 0;
while(pulseCount < 5)
{
while(PIND & 0x08);
TCNT0 = 0;
while(!(PIND & 0x08));
pulseCount++;
timerCount = TCNT0;
if(timerCount > T_pulse)
address = address | (1 << (pulseCount-1));
else
address = address & ~(1 << (pulseCount-1));
}
IR_input = (((unsigned int)code) << 8) | address;
return(IR_input);
}
//************************************************************
//*** call this routine to initialize all peripherals
//************************************************************
void init_devices(void)
{
cli();                     //matikan interupsi
port_init();            //siapkan port yang dipakai
timer0_init();            //set up timer0 8 bit

MCUCR = 0b00001000;        //setup pin interupsi
GICR|=(1<<INT1);
sei();                     //re-enable interrupts
}

int main(void)
{
init_devices();
while(1)
{
//background process, program utama di sini
}
}

DOWNLOAD FILE DI SINI

selamat mencoba

Tombol 1  membunyikan buzzer

Tombol 2 relay ON

Tombol 3 LED ON

~ by den-wam on October 16, 2010.

2 Responses to “remote Infra Red dengan output LED buzzer dan relay”

  1. nilai yang penting untuk timing pulsa adalah pada baris program ini

    untuk crystal external 16MHz onboard:
    #define T_pulse 28*2 //14
    #define T_header 60*2 //30

    untuk oscillator internal 8MHz onchip:
    #define T_pulse 28 //14
    #define T_header 60 //30

  2. blognya bagus banget gan. . . linknya kok mati ??? bisa reupload gan? pengen blajar remot ini gan. . .sukses slalu gan

Leave a Reply

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: