»ùÓÚºìÍâÒ£¿Ø²½½øµç»úµÄÉè¼Æ ÏÂÔر¾ÎÄ

3. ºìÍâ½âÂëÅжÏ×Ó³ÌÐò

ºìÍâ½âÂëÅжÏ×Ó³ÌÐò°üÀ¨¶ÔÂëÖµµÄÅжϳÌÐòºÍÍⲿÖжÏ0³ÌÐò£¬ºìÍâ½ÓÊյ緽«½ÓÊÕµ½µÄÐźÅË͵½ÍⲿÖжÏ0£¬È»ºóºìÍâ½âÂë³ÌÐò¶ÔÊÕµ½µÄÐźŽøÐнâÂ룬Èô½âÂëʧ°ÜÔòÖØнøÐнâÂ룬Èô½âÂë³É¹¦ÔòÅжÏÆ÷ÂëÖµ£¬È»ºóµ÷Óò½½øµç»ú¿ØÖƺÍLCDÏÔʾ³ÌÐòʵÏÖ²½½øµç»úµÄÔËתºÍÏÔʾ¡£´Ó¶øʵÏÖºìÍâÒ£¿Ø¶Ô²½½øµç»úµÄ¿ØÖƼ°ÏÔʾ¡£ÏµÍ³ºìÍâ½âÂëÅжÏ×Ó³ÌÐòÁ÷³ÌͼÈçͼ12Ëùʾ

ºìÍâ½âÂ뺯ÊýN½âÂë³É¹¦YÅжÏÂëÖµÆô¶¯Í£Ö¹¼ÓËÙ¼õËÙÕýת·´×ªµ÷ÓÃÏÔʾº¯Êýµ÷ÓÃÏÔʾº¯Êýµ÷ÓÃÏÔʾº¯Êýµ÷ÓÃÏÔʾº¯Êýµ÷ÓÃÏÔʾº¯Êýµ÷ÓÃÏÔʾº¯Êý ͼ12

Î壺×ܽá

¸ÃºìÍâÒ£¿Ø²½½øµç»úµÄÖÆ×÷ÈÃÎÒѧ»áÁËÔõÑùÈ¥Éè¼ÆÒ»¸öϵͳ£¬¶ÔÒ»¸öϵͳµÄ»ù±¾¼Ü¹¹ÓÐÁËÒ»¶¨µÄÈÏʶ£¬ÔÚͨ¹ý¶ÔºìÍâ±à½âÂëµç·µÄÉè¼ÆÒ²ÈÃÎÒ¶ÔºìÍâÒ£¿ØµÄ»ù±¾ÖªÊ¶ÓÐÁËеÄÈÏʶ£¬ÖªµÀÁ˺ìÍâ·¢ÂëµÄÔ­ÀíÕÆÎÕÁ˺ìÍâ½âÂë³ÌÐòµÄ±àд£¬¶ÔLCDÏÖʵģ¿éµÄʹÓÃÒ²ÈÃÎÒ¶ÔLCDÓÐÁËеÄÈÏʶ£¬½»½ÓÁËÒªµ÷½ÚLCDµÄÇý¶¯µçѹʹÆä´ïµ½0V×óÓÒ²ÅÄÜÈÃ×Ö·ûÏÔʾ³öÀ´£¬Í¨¹ý¶Ô²½½øµç»úÇý¶¯µç·µÄÉè¼ÆÒ²ÈÃÎÒÈÏʶµ½ÒªÔÚ²½½øµç»úµÄP¿Ú¼ÓÉÏÀ­µç×è²ÅÄÜÇý¶¯²½½øµç»ú¡£×ÜÖ®£¬Õâ´ÎʵѵÈÃÎÒÊÕ»ñÁ˺ܶàҲΪÎÒÒÔºóµÄ¹¤×÷µì¶¨ÁËÒ»¶¨µÄ»ù´¡¡£ Ô´´úÂ룺

#include

#include

#define DataPort P0 //¶¨ÒåÊý¾Ý¶Ë¿Ú ³ÌÐòÖÐÓöµ½DataPort ÔòÓÃP0 Ìæ»»

sbit IR=P3^2; //ºìÍâ½Ó¿Ú±êÖ¾

unsigned char TempData[8]; //´æ´¢ÏÔʾֵµÄÈ«¾Ö±äÁ¿ char code Tab[16]=%unsigned char irtime;//ºìÍâÓÃÈ«¾Ö±äÁ¿

bit irpro_ok,irok,f;

unsigned char IRcord[4]; unsigned char irdata[33];

sbit A1=P1^0; //¶¨Òå²½½øµç»úÁ¬½Ó¶Ë¿Ú sbit B1=P1^1; sbit C1=P1^2; sbit D1=P1^3;

#define Coil_AB1 {A1=1;B1=1;C1=0;D1=0;}//ABÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_BC1 {A1=0;B1=1;C1=1;D1=0;}//BCÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_CD1 {A1=0;B1=0;C1=1;D1=1;}//CDÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_DA1 {A1=1;B1=0;C1=0;D1=1;}//DÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_A1 {A1=1;B1=0;C1=0;D1=0;}//AÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_B1 {A1=0;B1=1;C1=0;D1=0;}//BÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_C1 {A1=0;B1=0;C1=1;D1=0;}//CÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_D1 {A1=0;B1=0;C1=0;D1=1;}//DÏàͨµç£¬ÆäËûÏà¶Ïµç #define Coil_OFF {A1=0;B1=0;C1=0;D1=0;}//È«²¿¶Ïµç #define RS_CLR RS=0 #define RS_SET RS=1

#define RW_CLR RW=0 #define RW_SET RW=1

#define EN_CLR EN=0 #define EN_SET EN=1 #define CHECK_BUSY #define DataPort P0 unsigned char Speed=1; bit StartFlag,zfFlag;

sbit RS = P2^4; //¶¨Òå¶Ë¿Ú

sbit RW = P2^5; sbit EN = P2^6;

void DelayUs2x(unsigned char t); void DelayMs(unsigned char t); void Ir_work(void); void Ircordpro(void); void TIM0init(void); void Init_Timer1(void); void EX0init(void);

/*------------------------------------------------ ÅÐ溯Êý

------------------------------------------------*/ bit LCD_Check_Busy(void) {

#ifdef CHECK_BUSY DataPort= 0xFF; RS_CLR; RW_SET; EN_CLR; _nop_(); EN_SET;

return (bit)(DataPort & 0x80); #else

return 0; #endif }

/*------------------------------------------------ дÈëÃüÁÊý

------------------------------------------------*/ void LCD_Write_Com(unsigned char com) {

// while(LCD_Check_Busy()); //æÔòµÈ´ý DelayMs(5); RS_CLR; RW_CLR; EN_SET;

DataPort= com; _nop_(); EN_CLR;

}

/*------------------------------------------------ дÈëÊý¾Ýº¯Êý

------------------------------------------------*/ void LCD_Write_Data(unsigned char Data) {

//while(LCD_Check_Busy()); //æÔòµÈ´ý DelayMs(5); RS_SET; RW_CLR; EN_SET;

DataPort= Data; _nop_(); EN_CLR; }

/*------------------------------------------------ ÇåÆÁº¯Êý

------------------------------------------------*/ void LCD_Clear(void) {

LCD_Write_Com(0x01); DelayMs(5); }

/*------------------------------------------------ дÈë×Ö·û´®º¯Êý

------------------------------------------------*/

void LCD_Write_String(unsigned char x,unsigned char y,unsigned char *s) {

if (y == 0) {

LCD_Write_Com(0x80 + x); //±íʾµÚÒ»ÐÐ } else

{

LCD_Write_Com(0xC0 + x); //±íʾµÚ¶þÐÐ } while (*s) {

LCD_Write_Data( *s); s ++; }