本次設(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)的顯示格式,并完成工作。
130911zz5wlztntrtwf0ew.png (21 KB, 下載次數(shù): 53)
下載附件
2019-6-24 02:41 上傳
1.PNG (90.42 KB, 下載次數(shù): 37)
下載附件
2019-6-23 13:17 上傳
單片機(jī)源程序如下:
- #include
- #include
- #include
- #include
- #include
- #include
- #define uchar unsigned char
- #define uint unsigned int
- uint table1=0;
- unsigned char num,flag,a,i,j;
- uchar k;
- //uchar code table[]="I get ";
- uchar table_a[13]={"0123456789012"};
- uchar table_b[11]={"0123456789"};
- uchar code pin1[] = {"產(chǎn)品名稱:"};
- uchar code pin2[] = {"產(chǎn)品價(jià)格:"};
- uchar code pin3[] = {" 元"};
- uchar code dis0[] = {"0123456789."};
- uchar code dis1[] = {"碧禹飲用水 "};
- uchar code dis2[] = {"心相印衛(wèi)生紙"};
- uchar code dis3[] = {"小露珠抽紙 "};
- uchar code dis4[] = {"東立A4紙 "};
- uchar code dis5[] = {"美汁源可樂(lè) "};
- uchar code dis6[] = {"便攜條形碼識(shí)別器"};
- uchar code s1[11] = {"36402200042"}; //碧禹應(yīng)用水
- uchar code s2[11] = {"22868289158"}; //心心相印紙
- uchar code s3[11] = {"34704601062"}; //小露珠抽紙
- uchar code s4[11] = {"23608677129"}; //東立A4紙
- uchar code s5[11] = {"56416200166"}; //美汁源
- uchar code s6[11] = {"56416200166"}; //美汁源
- void change();
- void duibi();
- char cmp(uchar *str,uchar *str1);
- void init()
- {
- TMOD=0x20;
- TH1=0xfd;
- TL1=0xfd;
- TR1=1;
- REN=1;
- SM0=0;
- SM1=1;
- EA=1;
- ES=1;
- }
- void main()
- {
- init();
- Delay400Ms(); //啟動(dòng)等待,等LCD講入工作狀態(tài)
- LCDInit(); //LCM初始化
- Delay5Ms(); //延時(shí)片刻(可不要)
- DisplayListChar(0,0,dis6); //顯示字庫(kù)中的中文數(shù)字
- DisplayListChar(0,2,pin1); //顯示字庫(kù)中的中文數(shù)字
- DisplayListChar(0,4,pin3); //顯示字庫(kù)中的中文數(shù)字
- DisplayListChar(0,4,pin2); //顯示字庫(kù)中的中文數(shù)字
- while(1)
- {
- // change()
- duibi();
- switch(num)
- {
- case 0:DisplayListChar(0,3,dis1);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[3]);break;
- case 1:DisplayListChar(0,3,dis2);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[1]);break;
- case 2:DisplayListChar(0,3,dis3);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[3]);break;
- case 3:DisplayListChar(0,3,dis4);lcd_pos(3,5);WriteDataLCD(dis0[2]);WriteDataLCD(dis0[0]);break;
- case 4:DisplayListChar(0,3,dis5);lcd_pos(3,5);WriteDataLCD(dis0[0]);WriteDataLCD(dis0[4]);break;
- }
- /* lcd_pos(0,0); //設(shè)置顯示位置為第二行的第1個(gè)字符
- for(i=0;i<11;i++)
- {
- k=table_b[i]-0x30;
- // k=s1[i]-0x30;
- WriteDataLCD(dis0[k]); //
- Delay5Ms();
- } */
- }
- }
- void ser() interrupt 4
- {
- RI=0;
- table_a[table1]=SBUF;
- if(table_a[0]==0x36)
- table1++;
- if(table1>12) table1=0;
- }
- void duibi()
- {
- for(i=0;i<13;i++)
- {
- table_b[i]=table_a[i+2];
- }
- if(cmp(table_b,s1)==1) num=0;
- if(cmp(table_b,s2)==1) num=1;
- if(cmp(table_b,s3)==1) num=2;
- if(cmp(table_b,s4)==1) num=3;
- if(cmp(table_b,s5)==1) num=4;
- }
- char cmp(uchar *str,uchar *str1)
- {
- int d,c=0;
- for(d=0;d<11;d++)
- {
- if(str[d]!=str1[d])
- {c=0;break;}
- else c=1;
- }
- return c;
- }
復(fù)制代碼
全部資料51hei下載地址:
文檔 電路 程序.zip
(977.27 KB, 下載次數(shù): 95)
2019-6-23 13:18 上傳
點(diǎn)擊文件名下載附件
文檔+電路+程序 下載積分: 黑幣 -5
|