無線點菜系統(tǒng)基于NRF2401無線芯片和51單片機
0.png (24.6 KB, 下載次數(shù): 139)
下載附件
2016-4-9 22:16 上傳
所有源代碼和電路圖下載:
無線點菜系統(tǒng).zip
(235.54 KB, 下載次數(shù): 216)
2016-4-9 21:55 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
部分源碼預(yù)覽:
- #include<stdio.h>
- #include"delay.h"
- #include"NRF2401.H"
- sbit RS = P2^4;
- sbit RW = P2^5;
- sbit E = P2^6;
- sbit RES = P2^3;
- sbit PSB = P2^1;
- sbit PAUSE = P3^0;
- #define DataPort P0
- unsigned char *num[10]={"0","1","2","3","4","5","6","7","8","9"};
- unsigned char i=1;
- unsigned char temp[8];
- unsigned char tf =0;
- unsigned char RxBuf[20]={0};
- /*------------------------------------------------
- 檢測忙位
- ------------------------------------------------*/
- void Check_Busy()
- {
- RS=0;
- RW=1;
- E=1;
- DataPort=0xff;
- while((DataPort&0x80)==0x80);//忙則等待
- E=0;
- }
- /*------------------------------------------------
- 寫命令
- ------------------------------------------------*/
- void Write_Cmd(unsigned char Cmd)
- {
- Check_Busy();
- RS=0;
- RW=0;
- E=1;
- DataPort=Cmd;
- DelayUs2x(5);
- E=0;
- DelayUs2x(5);
- }
- /*------------------------------------------------
- 寫數(shù)據(jù)
- ------------------------------------------------*/
- void Write_Data(unsigned char Data)
- {
- Check_Busy();
- RS=1;
- RW=0;
- E=1;
- DataPort=Data;
- DelayUs2x(5);
- E=0;
- DelayUs2x(5);
- }
- /*------------------------------------------------
- 液晶屏初始化
- ------------------------------------------------*/
- void Init_ST7920()
- {
- DelayMs(40); //大于40MS的延時程序
- PSB=1; //設(shè)置為8BIT并口工作模式
- DelayMs(1); //延時
- RES=0; //復(fù)位
- DelayMs(1); //延時
- RES=1; //復(fù)位置高
- DelayMs(10);
- Write_Cmd(0x30); //選擇基本指令集
- DelayUs2x(50); //延時大于100us
- Write_Cmd(0x30); //選擇8bit數(shù)據(jù)流
- DelayUs2x(20); //延時大于37us
- Write_Cmd(0x0c); //開顯示(無游標、不反白)
- DelayUs2x(50); //延時大于100us
- Write_Cmd(0x01); //清除顯示,并且設(shè)定地址指針為00H
- DelayMs(15); //延時大于10ms
- Write_Cmd(0x06); //指定在資料的讀取及寫入時,設(shè)定游標的移動方向及指定顯示的移位,光標從右向左加1位移動
- DelayUs2x(50); //延時大于100us
- }
- /*------------------------------------------------
- 顯示字符串
- x:橫坐標值,范圍0~8
- y:縱坐標值,范圍1~4
- ------------------------------------------------*/
- void LCD_PutString(unsigned char x,unsigned char y,unsigned char code *s)
- {
- switch(y)
- {
- case 1: Write_Cmd(0x80+x);break;
- case 2: Write_Cmd(0x90+x);break;
- case 3: Write_Cmd(0x88+x);break;
- case 4: Write_Cmd(0x98+x);break;
- default:break;
- }
- while(*s>0)
- {
- Write_Data(*s);
- s++;
- DelayUs2x(50);
- }
- }
- /*------------------------------------------------
- 顯示菜名
- ------------------------------------------------*/
- void Dispaly(void)
- {
- switch(RxBuf[1])
- {
- case 1:LCD_PutString(0,i," 01.魚香肉絲 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 2:LCD_PutString(0,i," 02.宮保雞丁 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 3:LCD_PutString(0,i," 03.麻婆豆腐 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 4:LCD_PutString(0,i," 04.紅燒鯉魚 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 5:LCD_PutString(0,i," 05.老醋花生 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 6:LCD_PutString(0,i," 06.炒茼蒿 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 7:LCD_PutString(0,i," 07.醬脊骨 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 8:LCD_PutString(0,i," 08.拌蕨粉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 9:LCD_PutString(0,i," 09.爆炒腰花 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 10:LCD_PutString(0,i," 10.燉牛肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 11:LCD_PutString(0,i," 11.蒜苗炒肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 12:LCD_PutString(0,i," 12.蔥爆羊肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 13:LCD_PutString(0,i," 13.蔥爆牛肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 14:LCD_PutString(0,i," 14.孜然羊肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 15:LCD_PutString(0,i," 15.孜然牛肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 16:LCD_PutString(0,i," 16.干煸豆角 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 17:LCD_PutString(0,i," 17.干煸兩樣 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 18:LCD_PutString(0,i," 18.紅燒雞翅 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 19:LCD_PutString(0,i," 19.疙瘩湯 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 20:LCD_PutString(0,i," 20.溜肥腸 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 21:LCD_PutString(0,i," 21.水煮肉片 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 22:LCD_PutString(0,i," 22.水煮魚 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 23:LCD_PutString(0,i," 23.醋溜白菜 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 24:LCD_PutString(0,i," 24.角瓜炒肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 25:LCD_PutString(0,i," 25.五香牛肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 26:LCD_PutString(0,i," 26.鹽水大蝦 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 27:LCD_PutString(0,i," 27.白菜豆腐 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 28:LCD_PutString(0,i," 28.韭菜雞蛋 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 29:LCD_PutString(0,i," 29.蒜臺炒肉 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- case 30:LCD_PutString(0,i," 30.紅燒排骨 ");
- LCD_PutString(7,i,num[RxBuf[2]]);
- break;
- default:break;
- }
- }
- /*------------------------------------------------
- 清屏
- ------------------------------------------------*/
- void ClrScreen()
- {
- Write_Cmd(0x01);
- DelayMs(15);
- }
- /*------------------------------------------------
- 主程序
- ------------------------------------------------*/
- void main()
- {
-
- init_NRF24L01();
- Init_ST7920();
- DelayMs(500);
- LCD_PutString(0,1," -無線點菜系統(tǒng)- ");
- while(1)
- {
- SetRX_Mode();
- nRF24L01_RxPacket(RxBuf);
- if(RxBuf[0]==0XAA)
- {
- if(i==5)
- {
- i=1;
- }
- Dispaly();
- RxBuf[0] = 0x00;
- RxBuf[1] = 0x00;
- RxBuf[2] = 0x00;
- i++;
- }
- }
- }
復(fù)制代碼
|