cho em đoạn code của đọc mã remote tivi sử dụng C nha? nhớ là phải C đấy? as thì em có cả mớ rùi! thanks các bác nhiều!
Làm ơn hướng dẫn em cách đọc mã của remote tivi sử dụng C?
Collapse
X
-
#include<AT89S53.h>
sbit IR = 0x90; // IR = P1_0
sbit RS = 0x91; // RS = P1_1
sbit E = 0x92; // E = P1_2
unsigned char a=0xFF;
unsigned char b=0xFF;
unsigned char c=0;
void delay_ms( unsigned int ms )
{ unsigned int i,j;
for (i=0;i<ms;i++)
for (j=0;j<120;j++){};
}
void delay_900us(void)
{ TMOD= 0x01;
TL0 = 0xB7; //830
TH0 = 0xFC;
TR0 = 1;
while(!TF0) continue;
TR0 = TF0 = 0 ;
}
void delay_20us(void)
{ TMOD= 0x01;
TH0 = 0xFF;
TL0 = 0xEB;
TR0 = 1;
while(!TF0) continue;
TR0 = TF0 = 0 ;
}
void LCD_PulseEnable ( void )
{E=1;delay_ms(1);
E=0;delay_ms(3);
}
void LCD_PutCmd(unsigned char k)
{ RS =0;
transdata(k);LCD_PulseEnable();
for(c=0;c<=3;c=c+1){RX=1;delay_20us();RX=0;};
LCD_PulseEnable();
}
void LCD_PutChar(unsigned char k)
{ RS =1;
transdata(k);LCD_PulseEnable();
for(c=0;c<=3;c=c+1){RX=1;delay_20us();RX=0;};
LCD_PulseEnable();
}
void LCD_Init ( void )
{ delay_ms(50);
LCD_PutCmd(0x03);delay_ms(5);
LCD_PutCmd(0x03);delay_ms(1);
LCD_PutCmd(0x03);delay_ms(1);
LCD_PutCmd(0x06); // dich con tro sang phai
LCD_PutCmd(0x0C); // bat hien thi ,tat con tro
LCD_PutCmd(0x28); // 4 bit , 5x8
LCD_PutCmd(0x01); // xoa man hinh
LCD_PutCmd(0x02); // ve dau dong
}
void scanIR()
{ delay_900us(); //0
if(IR) {a= a&0xFE;};
delay_900us(); //1
if(IR) {a= a&0xFD;};
delay_900us(); //2
if(IR) {a= a&0xFB;};
delay_900us(); //3
if(IR) {a= a&0xF7;};
delay_900us(); //4
if(IR) {a= a&0xEF;};
delay_900us(); //5
if(IR) {a= a&0xDF;};
delay_900us(); //6
if(IR) {a= a&0xBF;};
delay_900us(); //7 bit 0 ma dia chi
if(IR) {a= a&0x7F;};
delay_900us(); // bit 1 ma dia chi
if(IR) {b= b&0xFE;};
delay_900us(); // bit 2 ma dia chi
if(IR) {b= b&0xFD;};
delay_900us(); // bit 3 ma dia chi
if(IR) {b= b&0xFB;};
delay_900us(); // bit 4 ma dia chi
if(IR) {b= b&0xF7;};
delay_900us(); //4
if(IR) {b= b&0xEF;};
delay_900us(); //5
if(IR) {b= b&0xDF;};
delay_900us(); //6
if(IR) {b= b&0xBF;};
delay_900us(); //7 bit 0 ma dia chi
if(IR) {b= b&0x7F;};
}
void giaima(unsigned char i,unsigned char j )
{ if((i==0x56&&j==0xBD)||(i==0x56&&j==0xB9)){ LCD_PutChar('O');LCD_PutChar('N');};
if(j==0xB6) { LCD_PutChar('1');};
if(j==0x49) { LCD_PutChar('2');};
if(i==0x4E&&j==0x4A) { LCD_PutChar('3');};
if(i==0xBD&&j==0xB5) { LCD_PutChar('4');};
if(i==0x4E&&j==0x4E) { LCD_PutChar('5');};
if((i==0xBD&&j==0xB9)||(i==0xB9&&j==0xB9)){ LCD_PutChar('6');};
if((i==0xB9&&j==0xBA)||(i==0xBD&&j==0xBA)){ LCD_PutChar('7');};
if(i==0x56&&j==0x55) { LCD_PutChar('8');};
if(i==0x4E&&j==0x56) { LCD_PutChar('9');};
if(i==0xBD&&j==0xA9) { LCD_PutChar('0');};
if((i==0xBD&&j==0x56)||(i==0xB9&&j==0x56)){ LCD_PutChar('S');LCD_PutChar('M');};
if((i==0xBD&&j==0xCE)||(i==0xBD&&j==0xCA)){ LCD_PutChar('V');LCD_PutChar('+');};
if(i==0x4E&&j==0x76) { LCD_PutChar('P');LCD_PutChar('+');};
if(i==0x56&&j==0xB5) { LCD_PutChar('V');LCD_PutChar('-');};
if((i==0xB9&&j==0xC9)||(i==0xBD&&j==0xC9)){ LCD_PutChar('P');LCD_PutChar('-');};
}
main()
{
LCD_Init();
while(1)
{
HERE : while(IR) continue ;
delay_ms(1);
if(IR) goto HERE;
while(!IR) continue;
while(IR) continue ;
scanIR();
P2=a;
P3=b;
LCD_PutCmd(0x01);
LCD_PutCmd(0x84);
giaima(b,a);
delay_ms(1000);
a=b=0xFF;
P2=P3=0x00;
};
}
Lấy từ nguồn http://dientuvietnam.net/forums/show...275#post179275Last edited by vdh246; 17-04-2009, 03:12. Lý do: Bài này lấy của bác ZZ..zz để châm cứu đã! có lẽ đây là cái em cần!
-
#include <at89x51.h>
sbit signal=P3^2;
sbit chanel1=P3^3;
sbit chanel2=P3^4;
sbit chanel3=P3^5;
unsigned char datasignal[6];
void delay(unsigned char time)
{
if(time==8) //tre 900us
{
TH0=0xFC;
TL0=0xC2;
}
if(time==2) //tre 200us
{
TH0=0xFF;
TL0=0x47;
}
TR0=1;
while(!TF0);
TR0=0;
TF0=0;
}
bit check()// ham con kiem tra bit cua remote (do dai cua remot 14 bit)
{
unsigned char i;
i=1;
while(!signal)
{
delay(2);
i++;
}
if((i<10)|(i>14))i=0;
return i;
}
void control(unsigned char k)//kich hoat so
{
switch(k)
{
case (0):
chanel1=chanel1?0:1;
break;
case (1):
chanel2=chanel2?0:1;
break;
case (2):
chanel3=chanel3?0:1;
break;
}
}
void process()//xu ly ma phim da bam
{
char so;
so=-1;
if(datasignal[0]==0x01)so=0;
if(datasignal[0]==0x81)so=1;
if(datasignal[0]==0x41)so=2;
control(so);
}
void isr (void) interrupt 0 //ngat int0 P3.2.. Nhan tin hieu tu IR dieu khien
{
bit databit;
unsigned char dem,tre,k,mang;
EX0=0;
dem=12;
mang=7;
k=0;
if (check())
{
while(dem--)
{
while(signal);
delay(8);
databit=~signal;
if(databit)
{
datasignal[k]|=0x01;
while(!signal);
}
else
datasignal[k]&=0xFE;
if((mang--)==0)
{
mang=7;
k++;
}
else
datasignal[k]<<=1;
}
process();
tre=250;
while(tre--)
{
delay(2);
if(!signal) tre=250;
}
}
EX0=1;
}
void main()
{
TMOD = 0x11; //su dung timer,che do 16 bit
EA = 1; //Cho phep ngat chung.
EX0 = 1;//cho phep ngat ngoai 0
P3|=0x38;
while(1);
}
Comment
-
-
chủ yếu là thuâti toán thôi: chứ 89xx với PIC có khác gì nhau
tôi viết chương trình này rồi.ngắn lắm: khoang 20 dòng thôi
vừa làm cái mạch này chạy ầm ầm. remote tv sony
mail: dongsongbang_dld@yahoo.comNhận làm mạch vi điều khiển, ghép nối máy tính, mạch xung số
mail:
dd: 0973423905
Thương trường là chiến trường. tiến lên để kiếm tiền
Comment
-
anh gui cho em diiiiii nhen em dang tim hieu can lam: thank anh truoc nhak phananhvu_92@yahoo.com.vn
Comment
-
Bài viết mới nhất
Collapse
-
-
-
bởi bqvietĐám UPS cửa cuốn đời cổ vẫn chạy 1 biến áp sắt từ vừa để hạ áp điện lưới nạp bình điện, vừa để kích áp bình điện thành sóng vuông đầu ra đấy thôi. Kiểu tiết kiệm này đã có từ mấy chục năm nay. Sơ đồ đại loại như link
https://www.homemade-circuits.com/si...rchargerchang/...-
Channel: Nguồn!
06-09-2026, 16:49 -

Comment