Home > other >  Solve problems of infrared receiving, LCD display eight 0
Solve problems of infrared receiving, LCD display eight 0

Time:11-22

Bosses have a look at the trouble I program, LCD display eight zero, eight remote controls how press is still zero
# include
# define LCDIO P0
# define uchar unsigned char
# define uint unsigned int
Sbit IR=P3 ^ 2;
Sbit RS=P2 ^ 6;
Sbit RW=P2 ^ 5;
Sbit E=P2 ^ 7;
Uchar irtime0 extern0_num, bit_YD irtime_OK;
Uchar data_irtime [33].
Uchar data_code [4].
Void delay (uint I)
{
While (I -);
}

Void LCD1602WriteCOM (unsigned int com)
{
RW=0;
RS=0;
E=0;
LCDIO=com;
Delay (30);
E=1;
Delay (30);
E=0;
Delay (100);//?? 0.1 ms
}

Void LCD1602Write_DAT (unsigned int dat)
{
RW=0;
RS=1;
E=0;
LCDIO=dat;
Delay (30);
E=1;
Delay (30);
E=0;
Delay (100);//?? 0.1 ms
}

Void LCD1602Init ()
{
LCD1602WriteCOM (0 x01);
LCD1602WriteCOM x06 (0);
X0c LCD1602WriteCOM (0);
X38 LCD1602WriteCOM (0);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

Void time0_Init ()
{
TMOD=0 x02;
TH0=0;
TL0=0;
EA=1;
ET0=1;
TR0=1;
}

Void extern0_Init ()
{
IT0=1;
EA=1;
EX0=1;
}

Void time0 () interrupt 0
{
Irtime0 + +;
}

Void extern0 () interrupt 1
{
Extern0_num + +;
If (extern0_num==1)
{
Irtime0=0;
}
The else
{
If (irtime0 & gt; 32)
{
Bit_YD=0;
}
Data_irtime [bit_YD]=irtime0;
Irtime0=0;
Bit_YD + +;
If (bit_YD==33)
{
Irtime_OK=1;
Extern0_num=0;
}
}
}

Void irdeal ()
{
Uchar I=1, the value, k, a;
For (a=0; a<4. +)
{
for(k=0; k<8; K++)
{
value>=1;
If (data_irtime [I] & gt; 6)
{
value=https://bbs.csdn.net/topics/value | 0 x80.
}
i++;
}
}
Data_code [a]=value;
}

Void LCD1602Display ()
{
Uchar I;
LCD1602WriteCOM (0 x80 + 0 x40);
for(i=0; I<4. I++)
{
If (data_code [I]/16 & lt; 10)
{
LCD1602Write_DAT (data_code [I]/16 + 0 x30);
}
The else
{
LCD1602Write_DAT (data_code [I]/16 + 0 x37);
}
If (data_code [I] % 16 & lt; 10)
{
LCD1602Write_DAT (data_code [I] % 16 + 0 x30);
}
The else
{
LCD1602Write_DAT (data_code [I] % 16 + 0 x37);
}
}
}

Void main ()
{
LCD1602Init ();
Time0_Init ();
Extern0_Init ();
While (1)
{
If (irtime_OK==1)
{
Irdeal ();
Irtime_OK=0;
}
LCD1602Display ();
}
}

CodePudding user response:

This program may see skull pain,

Provide methods:
1. A separate test LCD display program (don't show 0, try using a few different Numbers), driver and decoding problem whether LCD, speaking, reading and writing;
2. If the LCD driver: sure, separate test infrared receiving procedures, look to whether receive success; (reference: can try to add an indicator light, such as receiving infrared keys, the light is 0.5 S, the premise is the process of the lamp no problem)
3. If there is something wrong with the infrared, check the hardware problem (remote control without electricity? Or other hardware problem), and then view the decoding program problem (see successful routines)
4. If the infrared receiving no problem, can try the two programs alignment, verified the program logic,

The hope can help the building Lord,
  • Related