欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 51單片機(jī)商品條形碼識(shí)別器設(shè)計(jì)(文檔+電路+程序) [打印本頁(yè)]

作者: dianzi787    時(shí)間: 2019-6-23 13:18
標(biāo)題: 51單片機(jī)商品條形碼識(shí)別器設(shè)計(jì)(文檔+電路+程序)
本次設(shè)計(jì)便攜式商品條形碼識(shí)別器,由四大模塊組成。激光掃描,單片機(jī),12864液晶顯示器,電源模塊。其工作的大致原理為,激光掃描到條形碼并進(jìn)行存儲(chǔ)。同時(shí)蜂鳴器開(kāi)始鳴響,然后掃描器將數(shù)據(jù)信息通過(guò)串口通信傳輸給單片機(jī),單片機(jī)收到信息后會(huì)與事先設(shè)定好的程序進(jìn)行對(duì)比,并將對(duì)比后的信息傳輸給12864液晶顯示器。顯示器也會(huì)根據(jù)事先設(shè)計(jì)好的程序進(jìn)行相應(yīng)的顯示格式,并完成工作。





單片機(jī)源程序如下:
  1. #include  
  2. #include
  3. #include
  4. #include
  5. #include
  6. #include
  7. #define uchar unsigned char
  8. #define uint unsigned int
  9. uint table1=0;
  10. unsigned char num,flag,a,i,j;
  11. uchar k;
  12. //uchar code table[]="I get ";
  13. uchar table_a[13]={"0123456789012"};
  14. uchar table_b[11]={"0123456789"};
  15. uchar code pin1[] = {"產(chǎn)品名稱(chēng):"};
  16. uchar code pin2[] = {"產(chǎn)品價(jià)格:"};
  17. uchar code pin3[] = {"              元"};
  18. uchar code dis0[] = {"0123456789."};
  19. uchar code dis1[] = {"碧禹飲用水  "};
  20. uchar code dis2[] = {"心相印衛(wèi)生紙"};
  21. uchar code dis3[] = {"小露珠抽紙  "};
  22. uchar code dis4[] = {"東立A4紙    "};
  23. uchar code dis5[] = {"美汁源可樂(lè)  "};
  24. uchar code dis6[] = {"便攜條形碼識(shí)別器"};
  25. uchar code s1[11] = {"36402200042"};          //碧禹應(yīng)用水
  26. uchar code s2[11] = {"22868289158"};          //心心相印紙
  27. uchar code s3[11] = {"34704601062"};          //小露珠抽紙
  28. uchar code s4[11] = {"23608677129"};          //東立A4紙
  29. uchar code s5[11] = {"56416200166"};          //美汁源
  30. uchar code s6[11] = {"56416200166"};          //美汁源
  31. void change();
  32. void duibi();
  33. char cmp(uchar *str,uchar *str1);
  34. void init()
  35. {
  36.         TMOD=0x20;
  37.         TH1=0xfd;
  38.         TL1=0xfd;
  39.         TR1=1;
  40.         REN=1;
  41.         SM0=0;
  42.         SM1=1;        
  43.         EA=1;
  44.         ES=1;        
  45. }
  46. void main()
  47. {
  48.         init();
  49.         Delay400Ms(); //啟動(dòng)等待,等LCD講入工作狀態(tài)
  50.     LCDInit();    //LCM初始化
  51.     Delay5Ms();   //延時(shí)片刻(可不要)
  52.         DisplayListChar(0,0,dis6);        //顯示字庫(kù)中的中文數(shù)字   
  53.         DisplayListChar(0,2,pin1);        //顯示字庫(kù)中的中文數(shù)字
  54.         DisplayListChar(0,4,pin3);        //顯示字庫(kù)中的中文數(shù)字
  55.         DisplayListChar(0,4,pin2);        //顯示字庫(kù)中的中文數(shù)字
  56.         while(1)
  57.         {
  58. //                change()
  59.                 duibi();
  60.                 switch(num)
  61.                 {
  62.                         case 0:DisplayListChar(0,3,dis1);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[3]);break;
  63.                         case 1:DisplayListChar(0,3,dis2);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[1]);break;
  64.                         case 2:DisplayListChar(0,3,dis3);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[3]);break;
  65.                         case 3:DisplayListChar(0,3,dis4);lcd_pos(3,5);WriteDataLCD(dis0[2]);WriteDataLCD(dis0[0]);break;
  66.                         case 4:DisplayListChar(0,3,dis5);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[4]);break;        
  67.                 }
  68. /*                lcd_pos(0,0);             //設(shè)置顯示位置為第二行的第1個(gè)字符            
  69.             for(i=0;i<11;i++)
  70.                   {
  71.                                    k=table_b[i]-0x30;
  72. //                                 k=s1[i]-0x30;
  73.                              WriteDataLCD(dis0[k]); //
  74.                                  Delay5Ms();                                 
  75.                   }                        */
  76.         }
  77. }
  78. void ser() interrupt 4
  79. {
  80.         RI=0;
  81.         table_a[table1]=SBUF;
  82.         if(table_a[0]==0x36)
  83.                 table1++;
  84. if(table1>12)  table1=0;
  85. }
  86. void duibi()
  87. {
  88.         for(i=0;i<13;i++)
  89.           {
  90.                    table_b[i]=table_a[i+2];                                 
  91.           }
  92.         if(cmp(table_b,s1)==1) num=0;
  93.         if(cmp(table_b,s2)==1) num=1;
  94.         if(cmp(table_b,s3)==1) num=2;
  95.         if(cmp(table_b,s4)==1) num=3;
  96.         if(cmp(table_b,s5)==1) num=4;
  97. }
  98. char cmp(uchar *str,uchar *str1)
  99. {
  100.          int d,c=0;
  101.          for(d=0;d<11;d++)
  102.          {
  103.                  if(str[d]!=str1[d])
  104.                         {c=0;break;}
  105.                 else c=1;                        
  106.          }
  107.          return c;
  108. }
復(fù)制代碼

全部資料51hei下載地址:
文檔 電路 程序.zip (977.27 KB, 下載次數(shù): 95)






歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1