找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1063|回复: 2
打印 上一主题 下一主题
收起左侧

基于单片机的RFID智能停车场系统程序电路原理图设计

[复制链接]
跳转到指定楼层
楼主
1、本产品采用单片机+独立按键+12864液晶显示+RFID射频模块+继电器模块+串口模块+上位机等组成。
2、下位机具有四个独立按键分别为注册功能、撤销功能、充值功能、入库和出库等功能。
3、每张IC卡号相当于每辆车的车牌号,在IC卡刷第一次卡是车辆入库,刷第二次卡是车辆出库,液晶显示车牌号、消费、余量、车辆状态等信息,并且电机转动来模拟开关。
4、只有注册过的IC卡才进行停车、充值、撤销、等操作,并且蜂鸣器会进行提示,无效卡刷卡时蜂鸣器响两声。
5、当IC卡余额小于0时, 液晶会显示余额不足,并且蜂鸣器响两声提示,并且车辆是无法出入库的。
6、上位机管理员可以对车辆信息进行增加、修改、查询、删除,并且可以设置IC卡,进和消费范围0~255之间。
7、上位机可以显示当前停车场剩下车位数量、用户的停车状态、停车总时间、每小时停车费用、消费、入库时间、出库时间、并且保存到数据库方便管理员查询记录。
8、通过红外传感器检测当前车位是否有车,并且液晶显示指导哪里有空车位,方便用户寻找车位。
9、语音模块进行播报每次的消费、出入库、注册和撤销、等信息。

制作出来的实物图如下:


电路原理图如下:


单片机源程序如下:
  1. #include "reg52.h"
  2. #include "main.h"
  3. #include "mfrc522.h"      
  4. #include "LCD12864.h"
  5. #include <string.h>
  6. #include <stdio.h>
  7. sbit rst=P1^2;
  8. sbit date=P1^1;
  9. sbit busy=P1^0;               

  10. sbit BEEP=P2^0        ;
  11. sbit HY0=P2^2        ;
  12. sbit HY1=P2^3        ;
  13. sbit HY2=P2^4;
  14. sbit KEY1=P1^4;
  15. sbit LED=P1^3;
  16. #define SET_BEEP  BEEP = 0
  17. #define CLR_BEEP         BEEP = 1
  18. typedef unsigned int u16;         
  19. typedef unsigned char u8;
  20. signed long money_value;
  21. signed long  dat=0;
  22. unsigned char dat1=0,ii=0,iii=0,ii1=0,tt1=0;
  23. char string[]="           ";

  24. unsigned char code data2[4]  = {0x12,0,0,0};
  25. unsigned char code DefaultKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  26. unsigned char idata MLastSelectedSnr[4];
  27. unsigned char idata RevBuffer[30];  
  28. bit CmdValid;                           
  29. signed long xiaofei=0;
  30. signed long chongzhi=5000;
  31. unsigned char code ASCII_NUM[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
  32. unsigned char code  Yankey[6]  = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
  33. unsigned char code  XiugaiYunKey[16]= {0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x07,0x80,0x69,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};         
  34. unsigned char code  Nowkey[6]  = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFE};
  35. unsigned char code  XiugaiNowKey[16]= {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x07,0x80,0x69,0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};      
  36. unsigned char idata Read_Data[16]={0x00};
  37. unsigned char data OperationCard;

  38. uchar data bWarn,bPass,ttt=0,tt=0;

  39. #define        REGCARD                        0xa1
  40. #define        CONSUME                        0xa2
  41. #define READCARD                0xa3
  42. #define ADDMONEY                0xa4
  43. #define CHEXIAO                  0xa5
  44. void delay(u16 i)
  45. {
  46.         while(i--);      
  47. }
  48. void read(uchar z)                                                
  49. {
  50.         rst=1;
  51.         delay(220);
  52.         rst=0;                        
  53.         delay(220);
  54.         while(z>0)                 
  55.         {
  56.                 date=1;
  57.                 delay(110);
  58.                 date=0;
  59.                 delay(110);
  60.                 z--;
  61.         }
  62. }
  63. void STC_send_bluetooth(unsigned char a)      
  64. {                                                        
  65.         TI=0;      
  66.         SBUF=a;
  67.         while(TI==0);
  68.         TI=0;}
  69. void KeyScan(void)
  70. {
  71.          char string[]="           ";
  72.         if(ttt==0)
  73.         {
  74.         if(KEY1 == 0)
  75.                 {
  76.                                 delay_10ms(1);
  77.                                 if(KEY1 == 0 )
  78.                                 {
  79.         OperationCard=CHEXIAO;
  80.           tt=4;}
  81. }
  82.                 if(REGCARDBTN == 0)
  83.                 {
  84.                                 delay_10ms(1);
  85.                                 if(REGCARDBTN == 0 )
  86.                                                 OperationCard = REGCARD;      
  87.                                 tt=3;
  88.                 }
  89.                 if(CONSUMEBTN == 0)
  90.                 {
  91.                                 delay_10ms(1);
  92.                                 if(CONSUMEBTN == 0 )
  93.                                                 OperationCard = CONSUME;        tt=1;
  94.                 }
  95.                 if(ADDMONEYBTN == 0)
  96.                 {
  97.                                 delay_10ms(1);
  98.                                 if(ADDMONEYBTN == 0 )
  99.                                                 OperationCard = ADDMONEY;        tt=2;
  100.                 }
  101.         }
  102. }

  103. void Warn(void)
  104. {         
  105.   uchar data ii;
  106.   for(ii=0;ii<3;ii++)
  107.   {
  108.     SET_BEEP;
  109.     delay_10ms(5);
  110.     CLR_BEEP;
  111.     delay_10ms(5);
  112.   }         
  113. }
  114. void boyin()                                                           
  115. {
  116.       
  117.         read(1);
  118.         while(!busy);
  119.         if(OperationCard==CONSUME)
  120.         {
  121.         read(17);
  122.         while(!busy);
  123.         if(xiaofei/10000!=0)         
  124.         {
  125.                 read(xiaofei/10000+1);
  126.                 while(!busy);
  127.                 read(12);
  128.                 while(!busy);
  129.         }
  130.         if(xiaofei%10000/1000!=0)                                 
  131.         {
  132.     if((xiaofei/10000==0)&&(xiaofei%10000/1000==1))
  133.                 {      
  134.                  read(11);   
  135.                 while(!busy);}
  136.                 else   
  137.                 { read(xiaofei%10000/1000+1);
  138.                   while(!busy);
  139.                         read(11);
  140.                 while(!busy);}
  141.         }
  142.         else if ((xiaofei/10000!=0)&&(xiaofei%10000/1000==0))
  143.         {
  144.                 if(xiaofei%1000/100!=0)                                          
  145.         {
  146.            read(31);
  147.                 while(!busy);
  148.         }
  149.   }
  150.       
  151.         if(xiaofei%1000/100!=0)                                          
  152.         {
  153.                 read(xiaofei%1000/100+1);
  154.                 while(!busy);
  155.         }
  156.       
  157.         if(xiaofei%100/10!=0)                                          
  158.         {
  159.                 if((xiaofei/10000==0)&&(xiaofei%10000/1000==0)&&(xiaofei%1000/100==0))
  160.                 {
  161.                 read(31);
  162.                 while(!busy);
  163.      }
  164.                 read(13);
  165.     while(!busy);
  166.                 read(xiaofei%100/10+1);
  167.                 while(!busy);
  168.         }
  169.         if(xiaofei==0)
  170.         {
  171.    read(31);  
  172.                 while(!busy);
  173.   }
  174.           read(30);   
  175.                 while(!busy);
  176. }
  177.         if(OperationCard==ADDMONEY)
  178.         {
  179.   read(19);
  180.         while(!busy);
  181.         if(chongzhi/10000!=0)                                          
  182.         {
  183.                 read(chongzhi/10000+1);
  184.                 while(!busy);
  185.                 read(12);
  186.                 while(!busy);
  187.         }
  188.       
  189.         if(chongzhi%10000/1000!=0)                                            
  190.         {
  191.     if((chongzhi/10000==0)&&(chongzhi%10000/1000==1))
  192.                 {      
  193.                  read(11);
  194.                 while(!busy);}
  195.                 else   
  196.                 { read(chongzhi%10000/1000+1);
  197.                   while(!busy);
  198.                         read(11);
  199.                 while(!busy);}
  200.         }
  201.         else if ((chongzhi/10000!=0)&&(chongzhi%10000/1000==0))
  202.         {
  203.                 if(chongzhi%1000/100!=0)                                          
  204.         {
  205.            read(31);
  206.                 while(!busy);
  207.         }
  208.   }

  209.         if(chongzhi%1000/100!=0)                                          
  210.         {
  211.                 read(chongzhi%1000/100+1);
  212.                 while(!busy);
  213.         }
  214.         if(chongzhi==0)
  215.         {
  216.    read(31);
  217.                 while(!busy);
  218.   }
  219.         read(30);   
  220.                 while(!busy);
  221.   }
  222.       
  223.       
  224.         read(18);  
  225.         while(!busy);
  226.       
  227.         if(money_value/1000000!=0)                                          
  228.         {
  229.                 read(money_value/1000000+1);
  230.                 while(!busy);
  231.                 read(23);
  232.                 while(!busy);
  233.         }
  234.       
  235.       
  236.       
  237.         if(money_value%1000000/100000!=0)                                          
  238.         {
  239.                 read(money_value%1000000/100000+1);
  240.                 while(!busy);
  241.                 read(32);
  242.                 while(!busy);
  243.         }
  244.         else if((money_value/1000000!=0)&&(money_value%1000000/100000==0))
  245.         {
  246.    if((money_value%100000/10000==0)&&(money_value%10000/1000==0)&&(money_value%1000/100==0)){;}
  247.                 else
  248.                 {
  249.                 read(31);
  250.                 while(!busy);}
  251.    }               
  252.          
  253.       
  254.         if(money_value%100000/10000!=0)                                          
  255.         {
  256.                 read(money_value%100000/10000+1);
  257.                 while(!busy);
  258.                 read(12);
  259.                 while(!busy);
  260.         }
  261.         else if((money_value%1000000/100000!=0)&&(money_value%100000/10000==0))
  262.         {
  263.                
  264.                 if((money_value%10000/1000==0)&&(money_value%1000/100==0)){;}
  265.    else
  266.                 {
  267.                 read(31);
  268.                 while(!busy);}
  269.    }      

  270.          
  271.                 if(money_value%10000/1000!=0)                                          
  272.         {
  273.                
  274.                 read(money_value%10000/1000+1);
  275.                 while(!busy);
  276.                 read(11);
  277.                 while(!busy);
  278.         }
  279.         else if((money_value%100000/10000!=0)&&(money_value%10000/1000==0))
  280.         {
  281.    if(money_value%1000/100!=0)                                          
  282.         {
  283.                 read(31);
  284.                 while(!busy);}
  285.    }      
  286.       
  287.         if(money_value%1000/100!=0)                                          
  288.         {
  289.                 read(money_value%1000/100+1);
  290.                 while(!busy);
  291.         }
  292.       
  293.         if(money_value%100/10!=0)                                          
  294.         {
  295.                 if((money_value/1000000==0)&&(money_value%1000000/100000==0)&&(money_value%100000/10000==0)&&(money_value%10000/1000==0)&&(money_value%1000/100==0))               
  296.         {
  297.                 read(31);
  298.                 while(!busy);
  299.      }
  300.                 read(13);
  301.     while(!busy);
  302.                 read(money_value%100/10+1);
  303.                 while(!busy);
  304.         }
  305.         if(money_value==0)
  306.         {
  307.    read(31);
  308.                 while(!busy);
  309.   }
  310.         read(30);
  311.                 while(!busy);      
  312. }
  313. void WaitCardOff(void)
  314. {
  315.   char  status;
  316.   unsigned char        TagType[2];

  317.         while(1)
  318.         {
  319.                 status = PcdRequest(PICC_REQALL , TagType);
  320.                 if(status)
  321.                 {
  322.                         status = PcdRequest(PICC_REQALL , TagType);
  323.                         if(status)
  324.                         {
  325.                                 status = PcdRequest(PICC_REQALL , TagType);
  326.                                 if(status)
  327.                                 {
  328.                                         return;
  329.                                 }
  330.                         }
  331.                 }
  332.         }
  333. }
  334. void Pass(void)
  335. {      
  336.   SET_BEEP;
  337.   delay_10ms(30);
  338.   CLR_BEEP;
  339. }
  340. void CtrlProcess(void)
  341. {
  342.       
  343.         unsigned char idata Write_Consume_Data[16];
  344.           float f_money_value;
  345.           unsigned char ii;
  346.           char status;

  347.           status=PcdRequest(PICC_REQIDL,&RevBuffer[0]);
  348.    
  349.           if(status!=MI_OK)
  350.                           return;
  351.                
  352.                 for(ii=0;ii<2;ii++)
  353.                 {
  354.                                 string[2*ii]   = ASCII_NUM[(RevBuffer[ii]>>4)&0x0f];
  355.                                 string[2*ii+1] = ASCII_NUM[RevBuffer[ii]&0x0f];
  356.                        
  357.                 }
  358.                 string[4] = '\0';
  359.          
  360.                  LCD_PutString(0,2,"3μ??£o          ");
  361.                   LCD_PutString(0,3,"                ");
  362.                  
  363.                 status=PcdAnticoll(&RevBuffer[2]);
  364.                 if(status!=MI_OK)
  365.               return;

  366.           memcpy(MLastSelectedSnr,&RevBuffer[2],4);
  367.                 for(ii=0;ii<4;ii++)
  368.                 {
  369.                                 string[2*ii]   = ASCII_NUM[(MLastSelectedSnr[ii]>>4)&0x0f];
  370.                                 string[2*ii+1] = ASCII_NUM[MLastSelectedSnr[ii]&0x0f];
  371.                 }
  372.                 string[9] = '\0';
  373.                 LCD_PutString(3,2,string);
  374.                
  375.           status=PcdSelect(MLastSelectedSnr);

  376.           if(status!=MI_OK)
  377.                     return;
  378.                

  379.                         if(OperationCard==REGCARD)
  380.           {
  381.                     while(1)
  382.                         {
  383.                        
  384.                                 LCD_PutString(0,1,  ");
  385.                                 status=PcdAuthState(PICC_AUTHENT1A,7,Yankey,MLastSelectedSnr);
  386.                     
  387.                     if(status!=MI_OK)
  388.                     {                    LCD_PutString(0,3,"      "); LCD_PutString(0,4,"             ");Warn(); read(25);while(!busy); WaitCardOff(); break; }
  389.                     status=PcdWrite(7,XiugaiYunKey);
  390.                   
  391.                                 if(status!=MI_OK)
  392.                     {
  393.                              
  394.                               break;
  395.                     }

  396.                     for(ii=0;ii<16;ii++)
  397.                     {
  398.                               Write_Consume_Data[ii]=0xaa;
  399.                     }
  400.                                 memset( Write_Consume_Data, 0, sizeof(Write_Consume_Data) );
  401.                                 money_value = 0000;
  402.                                 memcpy( Write_Consume_Data, ( uchar * )&money_value, 4 );        
  403.                   
  404.                                 status=PcdWrite(4,&Write_Consume_Data[0]);

  405.                     if(status!=MI_OK)
  406.                     {
  407.                               bWarn=1;
  408.                       break;
  409.                     }
  410.                                 LCD_PutString(0,3,"    ");
  411.                                 LCD_PutString(0,4,"                ");
  412.                         Pass();                        
  413.                           PcdHalt();         
  414.                                 read(21);
  415.                         while(!busy);
  416.                         break;      
  417.                         }                              
  418.                 }
  419.                  if(OperationCard==CHEXIAO)
  420.           {
  421.                     while(1)
  422.                         {
  423.                         LCD_PutString(0,1,"   ");
  424.                         status = PcdAuthState(PICC_AUTHENT1A,7,Nowkey,MLastSelectedSnr);
  425.                     if(status!=MI_OK)
  426.                     {                    LCD_PutString(0,4,"   "); Warn(); read(15);  while(!busy);        WaitCardOff(); break; }
  427.                     status=PcdWrite(7,XiugaiNowKey);
  428.                   
  429.                                 if(status!=MI_OK)
  430.                     {
  431.                               break;
  432.                     }

  433.                     for(ii=0;ii<16;ii++)
  434.                     {
  435.                               Write_Consume_Data[ii]=0xaa;
  436.                     }
  437.                                 memset( Write_Consume_Data, 0, sizeof(Write_Consume_Data) );
  438.                                 money_value = 0000;
  439.                                 memcpy( Write_Consume_Data, ( uchar * )&money_value, 4 );        
  440.                   
  441.                                 status=PcdWrite(4,&Write_Consume_Data[0]);

  442.                     if(status!=MI_OK)
  443.                     {
  444.                               bWarn=1;
  445.                       break;
  446.                     }
  447.                                 LCD_PutString(0,3,"   ");
  448.                     Pass();               
  449.                         PcdHalt();        
  450.                                 read(22);
  451.                         while(!busy);
  452.                         break;      
  453.                         }                              
  454.                 }
  455.       
  456.           else if(OperationCard==CONSUME)
  457.           {
  458.                         while(1)
  459.                         {
  460.                               
  461.                            status=PcdAuthState(PICC_AUTHENT1A,7,Nowkey,MLastSelectedSnr);
  462.                         
  463.                      
  464.                             if(ii1==3) {ii1=0;Warn();}
  465.                                 status=PcdRead(4,Read_Data);

  466.                        if(status!=MI_OK)
  467.                       {
  468.                               break;
  469.                       }
  470.         
  471.                        memcpy( (uchar *)&money_value, Read_Data, 4 );
  472.               if(money_value>0)
  473.                                 {
  474.                        
  475.                                 STC_send_bluetooth('Y');
  476.                                 delay_10ms(10);
  477.                                 STC_send_bluetooth(string[0] );
  478.                                 STC_send_bluetooth(string[1] );
  479.                                 STC_send_bluetooth(string[2] );
  480.                                 STC_send_bluetooth(string[3] );
  481.                                 STC_send_bluetooth(string[4] );
  482.                                 STC_send_bluetooth(string[5] );
  483.                                 STC_send_bluetooth(string[6] );
  484.                                 STC_send_bluetooth(string[7] );
  485.                                 bPass=1;
  486.                                 delay_10ms(20);      
  487.                                 if(iii==0){ LCD_PutString(0,1,"  ");}
  488.                         money_value=money_value-xiaofei;  
  489.                 if(money_value>0)
  490.                                 {               
  491.                     if(iii==1){ if(HY0==1) {LCD_PutString(0,1,"  ");STC_send_bluetooth('S');}
  492.                 if((HY0==0)&&(HY1==1)) {LCD_PutString(0,1,"  ");STC_send_bluetooth('T');}
  493.                             if((HY0==0)&&(HY1==0)&&(HY2==1)) {LCD_PutString(0,1,"  ");STC_send_bluetooth('M');}
  494.                 if((HY0==0)&&(HY1==0)&&(HY2==0)) {LCD_PutString(0,1,"  ");STC_send_bluetooth('N');}
  495.                                   }
  496.                             if(iii==2){ LCD_PutString(0,1,"");}
  497.                 if(tt1==1) {  LED=0;  tt1=0;}                                                      }
  498.                                        
  499.                                 else  {money_value=money_value+xiaofei;xiaofei=0; LCD_PutString(0,1," ");Warn();iii=0;}
  500.                                 memcpy( Write_Consume_Data, (uchar *)&money_value, 4 );
  501.                         status=PcdWrite(4,&Write_Consume_Data[0]);
  502.                         delay_10ms(10);
  503.                        if(status!=MI_OK)
  504.                         {
  505.                               
  506.                               break;
  507.                         }               
  508.                               
  509.                                 LCD_PutString(0,3,"  ");
  510.                         LCD_PutString(0,4,"    ");      
  511.                                 string[0]=xiaofei/10000+0x30;
  512.                             string[1]=xiaofei%10000/1000+0x30;
  513.                                 string[2]=xiaofei%1000/100+0x30;
  514.                                 string[3]='.';
  515.                                 string[4]=xiaofei%100/10+0x30;
  516.                                 string[5] = '\0';
  517.                                 delay_10ms(3);
  518.                 LCD_PutString(3,3,string );
  519.                                 
  520.                               
  521.                                 f_money_value = money_value * 1.0/100;                       
  522.                                 sprintf(string,"%5.1f",f_money_value);      
  523.                                 LCD_PutString(3,4,string);
  524.                                 delay_10ms(10);
  525.                                 STC_send_bluetooth('Z');
  526.                                 delay_10ms(10);
  527.                                 STC_send_bluetooth(string[0]);
  528.                                 STC_send_bluetooth(string[1]);
  529.                                 STC_send_bluetooth(string[2]);
  530.                                 STC_send_bluetooth(string[3]);
  531.                                 STC_send_bluetooth(string[4]);
  532.                                 STC_send_bluetooth(string[5]);
  533.                 Pass();
  534.                 delay_10ms(10);
  535.                     LED=1;        
  536.                             if(iii==0){boyin();};
  537.                                 if(iii==1){ read(27);while(!busy);iii=0;}
  538.                             if(iii==2){ boyin();iii=0;}
  539.         }
  540.                                 else
  541.                                 {        LCD_PutString(0,3,"");
  542.                                         LCD_PutString(0,4,"       ");
  543.                                         f_money_value = money_value * 1.0/100;                       
  544.                                     sprintf(string,"%5.2f",f_money_value);      
  545.                                     LCD_PutString(3,4,string);
  546.                     Warn();
  547.                                         read(14);
  548.                             while(!busy);      
  549.                 }
  550.                     PcdHalt();
  551.                         break;      
  552.                         }
  553.                 }
  554.           else if(OperationCard==ADDMONEY)
  555.           {                while(1)
  556.                         {
  557.                                 LCD_PutString(0,1,"   ");
  558.                     status=PcdAuthState(PICC_AUTHENT1A,7,Nowkey,MLastSelectedSnr);
  559.                     status=PcdRead(4,Read_Data);

  560.                     if(status!=MI_OK)
  561.                     {
  562.                      
  563.                               break;
  564.                     }
  565.      
  566.                                 memcpy( (uchar *)&money_value, Read_Data, 4 );
  567.                         money_value=money_value+chongzhi;
  568.                                 memcpy( Write_Consume_Data, (uchar *)&money_value, 4 );
  569.                         status=PcdWrite(4,&Write_Consume_Data[0]);
  570.                            
  571.                                 if(status!=MI_OK)
  572.                     {
  573.                          break;
  574.                     }      
  575.                               
  576.                                 LCD_PutString(0,3,"    ");
  577.                         LCD_PutString(0,4,"        ");      
  578.                 string[0]=chongzhi/10000+0x30;      
  579.                 string[1]=chongzhi%10000/1000+0x30;
  580.                             string[2]=chongzhi%1000/100+0x30;
  581.                             string[3] = '\0';
  582.                              delay_10ms(1);
  583.                 LCD_PutString(3,3,string );
  584.                                 f_money_value = money_value * 1.0/100;                       
  585.                                 sprintf(string,"%5.1f",f_money_value);        
  586.                                 LCD_PutString(3,4,string);
  587.                                 delay_10ms(1);
  588.                         PcdHalt();      
  589.                                 Pass();
  590.                                 boyin()        ;
  591.                                 break;
  592.                 }
  593.         }
  594.               LED=1;        
  595.           WaitCardOff();
  596.                      PcdHalt();
  597.               BEEP=1;
  598. }

  599. void InitializeSystem()
  600. {

  601.          CmdValid=0;
  602.      PcdReset();
  603.      PcdAntennaOff();
  604.      PcdAntennaOn();  
  605.          M500PcdConfigISOType( 'A' );
  606. }


  607. void UartProcess(void)
  608. {
  609.     unsigned char baud;

  610.                 if(RevBuffer[0]==11)            
  611.                 {
  612.                                 RevBuffer[2]=RevBuffer[1];
  613.                           RevBuffer[0]=1;         
  614.                                 RevBuffer[1]=0;
  615.                                 CALL_isr_UART();               
  616.         LED_GREEN = 1;
  617.                                 delay_10ms(RevBuffer[2]);
  618.         LED_GREEN = 0;
  619.                 }
  620.                 else if(RevBuffer[0]==13)   
  621.           {
  622.                                 switch(RevBuffer[1])
  623.                                 {
  624.                                                 case 0:
  625.                                                                 baud=BAUD_9600;
  626.                                                                 break;
  627.                                                
  628.                                 }      
  629.                                 RevBuffer[0]=1;               
  630.                     RevBuffer[1]=0;
  631.                     CALL_isr_UART();
  632.                     delay_10ms(5);                       
  633.                     TR1   = 0;
  634.                     TH1   = baud;
  635.                     TL1   = TH1;
  636.                     delay_10ms(2);
  637.                     TR1   = TRUE;
  638.                 }
  639.                 else
  640.                 {
  641.       
  642.                                 CALL_isr_UART();
  643.                 }                       
  644. }

  645. void InitializeSystem1()
  646. {
  647.         P0 = 0xFF; P1 = 0xFF; P3 = 0xFF;P2 = 0xFF;
  648.     TMOD = 0x21;  
  649.     TH1 = 0xFd;                     
  650.     TL1 = 0xFd;
  651.     TH0 = 0xfe;                     
  652.     TL0 = 0x33;        
  653.       
  654.           ET0 = 1;
  655.     TR0 = 1;

  656.         SM0 = 0;
  657.         SM1 = 1;
  658.         REN = 1;
  659.           TR1 = 1;
  660.         ES = 1;
  661.         EA = 1;

  662. }  

  663. void timer0() interrupt 1   
  664. {
  665.         TH0=0xfe;                     
  666.   TL0=0xee;
  667. }

  668. void sint() interrupt 4         
  669. {
  670.         if(RI)                        
  671.     {
  672.        RI=0;
  673.        dat=SBUF;
  674.                          dat1=SBUF;
  675.                         if(ii==1)        {xiaofei=dat*100;ii=0;}
  676.                         if(ii==2)        {chongzhi=dat*100;ii=0;}
  677.                         if(dat1=='A')        { ii=1;}
  678.                         if(dat1=='G')        { tt1=1;}
  679.                         if(dat1=='H')        { ii=2;}
  680.                         if(dat1=='D')        { ii1=3;}
  681.                         if(dat1=='E')        { iii=1;}
  682.                         if(dat1=='F')        { iii=2;}
  683.                       if(dat1=='L') { xiaofei=0;}
  684.                         if(dat1=='T') { xiaofei=0;}
  685. }
  686.                         }
  687.                        
  688.                        
  689.                        
  690. void main( )
  691. {   
  692.             Init_ST7920();   
  693.                 ClrScreen();
  694.                 InitializeSystem( );
  695.                 InitializeSystem1( );
  696.                 OperationCard = 0;
  697.                 CALL_isr_UART();
  698.         STC_send_bluetooth('J');
  699.         tt=1;
  700.           OperationCard = CONSUME;
  701.     while (1)
  702.     {      
  703.                           if (CmdValid)
  704.                     {
  705.                                     CmdValid = FALSE;
  706.                                     UartProcess();
  707.                                 }
  708.                                 rst=0;
  709.        date=0;
  710.        busy=0;      
  711.                                 KeyScan();
  712.                 if(ttt==0 && tt==1)
  713. {      
  714.                 LCD_PutString(0,1,"                ");
  715.                 LCD_PutString(0,2,"   ");
  716.                 LCD_PutString(0,3,"    ");
  717.                 LCD_PutString(0,4,"                ");
  718.             CtrlProcess();
  719.            
  720. }

  721. if(tt==2)
  722. {      
  723.                 LCD_PutString(0,1,"                 ");
  724.                 LCD_PutString(0,2,"    ");
  725.                 LCD_PutString(0,3,"                 ");
  726.                 LCD_PutString(0,4,"                 ");
  727.             CtrlProcess();
  728.            
  729. }

  730. if(tt==3)
  731. {      
  732.                 LCD_PutString(0,1,"                 ");
  733.                 LCD_PutString(0,2,"     ");
  734.                 LCD_PutString(0,3,"                 ");
  735.                 LCD_PutString(0,4,"                 ");
  736.             CtrlProcess();
  737.            
  738. }
  739.         if(tt==4)
  740. {      
  741.                 LCD_PutString(0,1,"                 ");
  742.                 LCD_PutString(0,2,"      ");
  743.                 LCD_PutString(0,3,"                 ");
  744.                 LCD_PutString(0,4,"                 ");}
  745.             CtrlProcess();
  746.             ii=0;
  747.         tt1= 0;
  748.         ii1=0;
  749.         iii=0;
  750. }

  751. }

复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏4 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:1070914 发表于 2023-5-21 18:55 来自手机 | 只看该作者
您好,有没有参考资料?能不能分享一下,感谢
回复

使用道具 举报

板凳
ID:889242 发表于 2024-4-14 15:08 | 只看该作者
请问可以给一下资料学习吗
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表