完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
全部悬赏分都用了,只求大神能帮忙改一下这个程序!!!!
实现的功能在附件里面,程序也在附件里面!! 图片是作品实物图的效果!! 出现的故障有: 1. 销售总价价格算错了 2. 销量一开始就是4,把它改为0 3. 那些没刷到的卡也会通过GSM模块发送信息到手机上,这点是不是吧销量设计为0就不会出现了呢? 求联系 Q358372599 谢谢各位大神了!!! |
|
相关推荐
1个回答
|
|
#include "output.h"
#include "delay.h" #include "sys.h" #include "rc522.h" #include "key.h" //¾ØÕó¼üÅÌÄ£¿é #include "led.h" #include "usart.h" #include "string.h" #include "LCD12864.h" ////////////////////////////////////////////////////////// //M1¿¨·Öžé16‚€ÉÈ…^£¬Ã¿‚€ÉÈ…^ÓÉ4‰K£¨‰K0¡¢‰K1¡¢‰K2¡¢‰K3£©½M³É //ÎÒ‚ƒÒ²Œ¢16‚€ÉÈ…^µÄ64‚€‰K°´½^Œ¦µØÖ·¾ŽÌ–0~63 //µÚ0ÉÈ…^µÄ‰K0£¨¼´½^Œ¦µØÖ·0‰K£©£¬ËûÓÃ춴æ·ÅSÉÌ´ú´a£¬Òѽ›¹Ì»¯£¬²»¿É¸ü¸Ä //ÿ‚€ÉÈ…^µÄ‰K0¡¢‰K1¡¢‰K2žé”µ“þ‰K£¬¿ÉÓÃ춴æ·Å”µ“þ //ÿ‚€ÉÈ…^µÄ‰K3žé¿ØÖƉK£¨½^Œ¦µØÖ·‰K3¡¢7¡¢11....£©£¬°üÀ¨ÁËÃÜ´aA£¬´æÈ¡¿ØÖÆ¡¢ÃÜ´aB¡£ /******************************* *Á¬Ïß˵Ã÷£º *1--SS <----->PF0 *2--SCK <----->PB13 *3--MOSI<----->PB15 *4--MISO<----->PB14 *5--Ðü¿Õ *6--GND <----->GND *7--RST <----->PF1 *8--VCC <----->VCC ************************************/ /*È«¾Ö±äÁ¿*/ unsigned char CT[2];//¿¨ÀàÐÍ unsigned char SN[4]; //¿¨ºÅ unsigned char RFID[16]; //´æ·ÅRFID unsigned char lxl_bit=0; unsigned char card1_bit=0; unsigned char card2_bit=0; unsigned char card3_bit=0; unsigned char card4_bit=0; unsigned char total=0; extern u8 SMS_Text1[30]; //maojin_table[10]; unsigned int mao_jin_danjia=7,maojin=0,mao_jin_kucun=8,mao_jin_xiaoliang=4,mao_jin_xiao_shou_zongjia=28, xi_fa_lu_danjia=18,xi_fa_lu=0,xi_fa_lu_kucun=8,xi_fa_lu_xiaoliang=4,xi_fa_lu_xiao_shou_zongjia=72, mu_yu_lu_danjia=22,mu_yu_lu=0,mu_yu_lu_kucun=8,mu_yu_lu_xiaoliang=4,mu_yu_lu_xiao_shou_zongjia=88, niu_nai_danjia=22,niu_nai=0,niu_nai_kucun=8,niu_nai_xiaoliang=4, niu_nai_xiao_shou_zongjia=88; //niu_nai_zheng_xiang_danjia=70, //unsigned char lxl[4]={6,109,250,186}; unsigned char lxl[4]={0X2A,0x4A,0xB2,0xAB}; unsigned char lxl_1[4]={0X33,0xE4,0xB1,0xAB}; unsigned char lxl_2[4]={0X86,0x49,0x9E,0xBB}; unsigned char lxl_3[4]={0X73,0x57,0x70,0x3B}; u8 KEY[6]={0xff,0xff,0xff,0xff,0xff,0xff}; unsigned char RFID1[16]={0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x07,0x80,0x29,0xff,0xff,0xff,0xff,0xff,0xff}; unsigned char Empt_Flag=0,Empt_Flag_1,Empt_Flag_2,Empt_Flag_3; /*º¯ÊýÉùÃ÷*/ void ShowID(u16 x,u16 y, u8 *p); //ÏÔʾ¿¨µÄ¿¨ºÅ£¬ÒÔÊ®Áù½øÖÆÏÔʾ void PutNum(u16 x,u16 y, u32 n1,u8 n0, u16 charColor, u16 bkColor); //ÏÔʾÓà¶îº¯Êý void Store(u8 *p,u8 store,u8 cash);//×îÖØÒªµÄÒ»¸öº¯Êý void maojin_dis(u16 f); unsigned char LCD_String[4]="000 "; int main(void) { unsigned char status; unsigned char s=0x08; //u8 Data[16]; //u8 i; u8 t,key,x,y,z; //u8 k;//¶Áд´íÎóÖØÊÔ´ÎÊý u8 j; u16 zong_xiaoshou_e; delay_init(); //ÑÓʱº¯Êý³õʼ»¯ NVIC_Configuration(); //ÉèÖÃNVICÖжϷÖ×é2:2λÇÀÕ¼ÓÅÏȼ¶£¬2λÏìÓ¦ÓÅÏȼ¶ //OUTPUT_Init(); //Êä³öÄ£¿é³õʼ»¯ uart_init(9600); LCD12864_Init(); LED_Init(); KEY_Init(); GSM_Init(); //sprintf((char*)lcd_id,"LCD ID:%04X",lcddev.id);//½«LCD ID´òÓ¡µ½lcd_idÊý×é¡£ //LEDA=1; delay_ms(2); InitRc522(); //³õʼ»¯ÉäƵ¿¨Ä£¿é LED0=0; LCD_WriteChstr1616(16,16,"³¬ÊнáÕËϵͳ",1); LCD12864_Refresh_GDRAM(); delay_ms(2); Empt_Flag=0; Empt_Flag_1=0; Empt_Flag_2=0; Empt_Flag_3=0; while(1) { zong_xiaoshou_e=mao_jin_xiao_shou_zongjia+xi_fa_lu_xiao_shou_zongjia+mu_yu_lu_xiao_shou_zongjia; if(KEY0==0) { while(KEY0==0); sprintf((char*)SMS_Text1,"maojin:%d,xifalu:%d,muyulu:%d,zong_xiaoshou_e:%d",mao_jin_xiao_shou_zongjia,xi_fa_lu_xiao_shou_zongjia,mu_yu_lu_xiao_shou_zongjia,zong_xiaoshou_e); delay_ms(2); Send_SMS(SMS_Text1); } status = PcdRequest(PICC_REQALL,CT);/*Œ¤¿¨*/ if(status==MI_OK)//Œ¤¿¨³É¹¦ { //WriteCmd(0x01); delay_ms(2); // locate16(1,1); // DisStr("PcdRequest_MI_OK"); //LCD_WriteChstr1212(0,0,"PcdRequest_MI_OK",1); //LCD12864_Refresh_GDRAM(); LED0=1; status=MI_ERR; status =PcdAnticoll(SN);/*·À³åײ*/ } if (status==MI_OK)//·ÀÐnײ³É¹¦ { status=MI_ERR; //ShowID(3,1,SN); //ÔÚÒº¾§ÆÁÉÏÏÔʾ¿¨µÄIDºÅ //delay_ms(500); if((SN[0]==lxl[0])&&(SN[1]==lxl[1])&&(SN[2]==lxl[2])&&(SN[3]==lxl[3])) { lxl_bit=1; LCD_Clear(0); LCD_WriteChstr1212(40,0,"ë ½í",1); delay_ms(2); LCD_WriteChstr1212(12,13,"µ¥ ¼Û£º",1); LCD_WriteChstr1212(70,13,"7 Ôª",1); LCD_WriteChstr1212(12,26,"¿â ´æ£º",1); LCD_String[0]=mao_jin_kucun/100%10+48; LCD_String[1]=mao_jin_kucun/10%10+48; LCD_String[2]=mao_jin_kucun%10+48; LCD_WriteChstr1212(70,26,LCD_String,1); if(mao_jin_kucun>0) mao_jin_kucun--; if(mao_jin_kucun<2 && Empt_Flag==0) //×ÜÁ¿Ð¡ÓÚ2£¬ÇÒ֮ǰ²»Îª¿Õ { sprintf((char*)SMS_Text1,"maojin_kucun:%d",mao_jin_kucun); delay_ms(2); Send_SMS(SMS_Text1); Empt_Flag=1; //±ê¼ÇÉÌÆ·ÊýÁ¿Îª¿Õ } if(mao_jin_kucun>=2) { Empt_Flag=0; } LCD_WriteChstr1212(12,39,"Ïú Á¿£º",1); LCD_String[0]=mao_jin_xiaoliang/100%10+48; LCD_String[1]=mao_jin_xiaoliang/10%10+48; LCD_String[2]=mao_jin_xiaoliang%10+48; LCD_WriteChstr1212(70,39,LCD_String,1); mao_jin_xiaoliang++; LCD_WriteChstr1212(12,52,"ÏúÁ¿×ܼۣº",1); mao_jin_xiao_shou_zongjia=mao_jin_xiaoliang*mao_jin_danjia; LCD_String[0]=mao_jin_xiao_shou_zongjia/100%10+48; LCD_String[1]=mao_jin_xiao_shou_zongjia/10%10+48; LCD_String[2]=mao_jin_xiao_shou_zongjia%10+48; LCD_WriteChstr1212(70,52,LCD_String,1); LCD12864_Refresh_GDRAM(); } else if((SN[0]==lxl_1[0])&&(SN[1]==lxl_1[1])&&(SN[2]==lxl_1[2])&&(SN[3]==lxl_1[3])) { lxl_bit=1; LCD_Clear(0); LCD_WriteChstr1212(40,0,"Ï´ ·¢ ¶",1); delay_ms(2); LCD_WriteChstr1212(12,13,"µ¥ ¼Û£º",1); LCD_WriteChstr1212(70,13,"18 Ôª",1); LCD_WriteChstr1212(12,26,"¿â ´æ£º",1); LCD_String[0]=xi_fa_lu_kucun/100%10+48; LCD_String[1]=xi_fa_lu_kucun/10%10+48; LCD_String[2]=xi_fa_lu_kucun%10+48; LCD_WriteChstr1212(70,26,LCD_String,1); if(xi_fa_lu_kucun>0) xi_fa_lu_kucun--; if(xi_fa_lu_kucun<2 && Empt_Flag_1==0) //×ÜÁ¿Ð¡ÓÚ2£¬ÇÒ֮ǰ²»Îª¿Õ { sprintf((char*)SMS_Text1,"xi_fa_lu_kucun:%d",xi_fa_lu_kucun); delay_ms(2); Send_SMS(SMS_Text1); Empt_Flag_1=1; //±ê¼ÇÉÌÆ·ÊýÁ¿Îª¿Õ } if(xi_fa_lu_kucun>=2) { Empt_Flag_1=0; } LCD_WriteChstr1212(12,39,"Ïú Á¿£º",1); LCD_String[0]=xi_fa_lu_xiaoliang/100%10+48; LCD_String[1]=xi_fa_lu_xiaoliang/10%10+48; LCD_String[2]=xi_fa_lu_xiaoliang%10+48; LCD_WriteChstr1212(70,39,LCD_String,1); xi_fa_lu_xiaoliang++; LCD_WriteChstr1212(12,52,"ÏúÁ¿×ܼۣº",1); xi_fa_lu_xiao_shou_zongjia=xi_fa_lu_xiaoliang*xi_fa_lu_danjia; LCD_String[0]=xi_fa_lu_xiao_shou_zongjia/100%10+48; LCD_String[1]=xi_fa_lu_xiao_shou_zongjia/10%10+48; LCD_String[2]=xi_fa_lu_xiao_shou_zongjia%10+48; LCD_WriteChstr1212(70,52,LCD_String,1); LCD12864_Refresh_GDRAM(); } else if((SN[0]==lxl_2[0])&&(SN[1]==lxl_2[1])&&(SN[2]==lxl_2[2])&&(SN[3]==lxl_2[3])) { lxl_bit=1; LCD_Clear(0); LCD_WriteChstr1212(40,0,"ãå Ô¡ ¶",1); delay_ms(2); LCD_WriteChstr1212(12,13,"µ¥ ¼Û£º",1); LCD_WriteChstr1212(70,13,"22 Ôª",1); LCD_WriteChstr1212(12,26,"¿â ´æ£º",1); LCD_String[0]=mu_yu_lu_kucun/100%10+48; LCD_String[1]=mu_yu_lu_kucun/10%10+48; LCD_String[2]=mu_yu_lu_kucun%10+48; LCD_WriteChstr1212(70,26,LCD_String,1); if(mu_yu_lu_kucun>0) mu_yu_lu_kucun--; if(mu_yu_lu_kucun<2 && Empt_Flag_2==0) //×ÜÁ¿Ð¡ÓÚ2£¬ÇÒ֮ǰ²»Îª¿Õ { sprintf((char*)SMS_Text1,"mu_yu_lu_kucun:%d",mu_yu_lu_kucun); delay_ms(2); Send_SMS(SMS_Text1); Empt_Flag_2=1; //±ê¼ÇÉÌÆ·ÊýÁ¿Îª¿Õ } if(mu_yu_lu_kucun>=2) { Empt_Flag_2=0; } LCD_WriteChstr1212(12,39,"Ïú Á¿£º",1); LCD_String[0]=mu_yu_lu_xiaoliang/100%10+48; LCD_String[1]=mu_yu_lu_xiaoliang/10%10+48; LCD_String[2]=mu_yu_lu_xiaoliang%10+48; LCD_WriteChstr1212(70,39,LCD_String,1); mu_yu_lu_xiaoliang++; LCD_WriteChstr1212(12,52,"ÏúÁ¿×ܼۣº",1); mu_yu_lu_xiao_shou_zongjia=mu_yu_lu_xiaoliang*mu_yu_lu_danjia; LCD_String[0]=mu_yu_lu_xiao_shou_zongjia/100%10+48; LCD_String[1]=mu_yu_lu_xiao_shou_zongjia/10%10+48; LCD_String[2]=mu_yu_lu_xiao_shou_zongjia%10+48; LCD_WriteChstr1212(70,52,LCD_String,1); LCD12864_Refresh_GDRAM(); } else if((SN[0]==lxl_3[0])&&(SN[1]==lxl_3[1])&&(SN[2]==lxl_3[2])&&(SN[3]==lxl_3[3])) { lxl_bit=1; LCD_WriteChstr1212(40,0,"Å£ ÄÌ",1); delay_ms(2); LCD_WriteChstr1212(12,13,"µ¥ ¼Û£º",1); LCD_WriteChstr1212(70,13,"22 Ôª",1); LCD_WriteChstr1212(12,26,"¿â ´æ£º",1); LCD_String[0]=niu_nai_kucun/100%10+48; LCD_String[1]=niu_nai_kucun/10%10+48; LCD_String[2]=niu_nai_kucun%10+48; LCD_WriteChstr1212(70,26,LCD_String,1); if(niu_nai_kucun>0) niu_nai_kucun--; if(niu_nai_kucun<2 && Empt_Flag_3==0) //×ÜÁ¿Ð¡ÓÚ2£¬ÇÒ֮ǰ²»Îª¿Õ { sprintf((char*)SMS_Text1,"niu_nai_kucun:%d",niu_nai_kucun); delay_ms(2); Send_SMS(SMS_Text1); Empt_Flag_3=1; //±ê¼ÇÉÌÆ·ÊýÁ¿Îª¿Õ } if(niu_nai_kucun>=2) { Empt_Flag_3=0; } LCD_WriteChstr1212(12,39,"Ïú Á¿£º",1); LCD_String[0]=niu_nai_xiaoliang/100%10+48; LCD_String[1]=niu_nai_xiaoliang/10%10+48; LCD_String[2]=niu_nai_xiaoliang%10+48; LCD_WriteChstr1212(70,39,LCD_String,1); niu_nai_xiaoliang++; LCD_WriteChstr1212(12,52,"ÏúÁ¿×ܼۣº",1); niu_nai_xiao_shou_zongjia=niu_nai_xiaoliang*niu_nai_danjia; LCD_String[0]=niu_nai_xiao_shou_zongjia/100%10+48; LCD_String[1]=niu_nai_xiao_shou_zongjia/10%10+48; LCD_String[2]=niu_nai_xiao_shou_zongjia%10+48; LCD_WriteChstr1212(70,52,LCD_String,1); LCD12864_Refresh_GDRAM(); } status =PcdSelect(SN); } if(status==MI_OK)//ßx¿¨³É¹¦ { status=MI_ERR; status =PcdAuthState(0x60,0x09,KEY,SN); } if(status==MI_OK)//òž×C³É¹¦ { //LCD_ShowString(0,64,200,16,16,"PcdAuthState_MI_OK "); status=MI_ERR; status=PcdRead(s,RFID); //status=PcdWrite(s,RFID1); } if(status==MI_OK)//×x¿¨³É¹¦ { //LCD_ShowString(0,80,200,16,16,"READ_MI_OK"); status=MI_ERR; delay_ms(100); } if(key==2) { for(t=0;t<16;t++) //¿ªÆôÉäƵģ¿é { USART_ClearFlag(USART1,USART_FLAG_TC); //¶ÁÈ¡USART_SR USART_SendData(USART1,RFID[t]); //Ïò´®¿Ú2·¢ËÍÊý¾Ý while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET); //µÈ´ý·¢ËͽáÊø } } } } /************************************* *º¯Êý¹¦ÄÜ£ºÏÔʾ¿¨µÄ¿¨ºÅ£¬ÒÔÊ®Áù½øÖÆÏÔʾ *²ÎÊý£ºx£¬y ×ø±ê * p ¿¨ºÅµÄµØÖ· * charcolor ×Ö·ûµÄÑÕÉ« * bkcolor ±³¾°µÄÑÕÉ« ***************************************/ void ShowID(u16 x,u16 y, u8 *p) //ÏÔʾ¿¨µÄ¿¨ºÅ£¬ÒÔÊ®Áù½øÖÆÏÔʾ { u8 num[9]; u8 i; for(i=0;i<4;i++) { num[i*2]=p[i]/16; num[i*2]>9?(num[i*2]+='7'):(num[i*2]+='0'); num[i*2+1]=p[i]%16; num[i*2+1]>9?(num[i*2+1]+='7'):(num[i*2+1]+='0'); } num[8]=0; // locate16(x,y); // DisStr("The Card ID is:"); // //DisplayString(x,y+16,num,charColor,bkColor); for(i=0;i<8;i++) { //LCD_ShowNum(x+16*i,y+16,num[i],2,16); // locate16(x+16*i,y+16); // WriteData(num[i]); delay_ms(2); } } /******************************** *º¯Êý¹¦ÄÜ£ºÇópµÄn´ÎÃÝ */ int power(u8 p,u8 n) { int pow=1; u8 i; for(i=0;i pow*=p; } return pow; } u8 ReadData(u8 addr,u8 *pKey,u8 *pSnr,u8 *dataout) { u8 status,k; status=0x02;// k=5; do { status=PcdAuthState(PICC_AUTHENT1A,addr,pKey,pSnr); k--; //printf("AuthState is wrongn"); }while(status!=MI_OK && k>0); status=0x02;// k=5; do { status=PcdRead(addr,dataout); k--; //printf("ReadData is wrongn"); }while(status!=MI_OK && k>0); return status; } void maojin_dis(u16 f) { u8 count=0; u16 f0; int num; f0=f; while(f) { f=f/10; count++; } memset(SMS_Text1,0,sizeof(SMS_Text1)); for(num=count-1;num>=0;num--) { SMS_Text1[num]=f0%10+48; f0=f0/10; } } 这个是程序 |
|
|
|
只有小组成员才能发言,加入小组>>
3046 浏览 3 评论
1520 浏览 3 评论
4652 浏览 1 评论
2013 浏览 1 评论
3262 浏览 2 评论
513浏览 1评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 14:37 , Processed in 1.291101 second(s), Total 82, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号