標(biāo)題: 怎么將ZIGBEE模塊接收到的數(shù)據(jù)在顯示屏上顯示 [打印本頁]

作者: 東東legend    時間: 2017-4-20 16:04
標(biāo)題: 怎么將ZIGBEE模塊接收到的數(shù)據(jù)在顯示屏上顯示
已經(jīng)成功地將兩個模塊能進(jìn)行串口通信。但是利用ZIGBEE模塊從主機(jī)端發(fā)送數(shù)據(jù)給從機(jī)端,從機(jī)端怎么接收到數(shù)據(jù)并在顯示屏上顯示?
同學(xué)會要利用數(shù)組,可是代碼不會寫。重點是我不知道你收到的數(shù)據(jù)在哪里可以看到或者寫什么代碼。
#include <reg51.h>
#include <intrins.h>       
#define uchar unsigned char
#define uint  unsigned int
/*12864端口定義*/
#define LCD_data  P0             //數(shù)據(jù)口
sbit LCD_RS  =  P3^5;            //寄存器選擇輸入
sbit LCD_RW  =  P3^6;            //液晶讀/寫控制
sbit LCD_EN  =  P3^4;            //液晶使能控制
sbit LCD_PSB =  P3^7;            //串/并方式控制
sbit wela    =  P2^6;
sbit dula    =  P2^7;
sbit beep=P2^3;


u8 recdat[8];
strcpy(recdat,你收到的數(shù)據(jù)){
for(i=0,i<8;i++)
printf("%x,"recdat[i]);  
}


重點是我不知道你收到的數(shù)據(jù)在哪里可以看到或者寫什么代碼。或者有人教我怎么用數(shù)組寫

/*******************************************************************/
/*                                                                 */
/*  延時函數(shù)                                                       */
/*                                                                 */
/*******************************************************************/
void delay(int ms)
{
uchar i;
    while(ms--)
        {

          for(i=0;i<250;i++)  
           {
           _nop_();                          
                _nop_();
                _nop_();
                _nop_();
      _nop_();
           }
        }
}               
/*******************************************************************/
/*                                                                 */
/*檢查LCD忙狀態(tài)                                                    */
/*lcd_busy為1時,忙,等待。lcd-busy為0時,閑,可寫指令與數(shù)據(jù)。      */
/*                                                                 */
/*******************************************************************/
bit lcd_busy()
{                          
    bit result;
    LCD_RS = 0;
    LCD_RW = 1;
    LCD_EN = 1;
    delayNOP();
    result = (bit)(P0&0x80);
    LCD_EN = 0;
    return(result);
}
/*******************************************************************/
/*                                                                 */
/*寫指令數(shù)據(jù)到LCD                                                  */
/*RS=L,RW=L,E=高脈沖,D0-D7=指令碼。                             */
/*                                                                 */
/*******************************************************************/
void lcd_wcmd(uchar cmd)
{                          
   while(lcd_busy());
    LCD_RS = 0;
    LCD_RW = 0;
    LCD_EN = 0;
    _nop_();
    _nop_();
    P0 = cmd;
    delayNOP();
    LCD_EN = 1;
    delayNOP();
    LCD_EN = 0;  
}
/*******************************************************************/
/*                                                                 */
/*寫顯示數(shù)據(jù)到LCD                                                  */
/*RS=H,RW=L,E=高脈沖,D0-D7=數(shù)據(jù)。                               */
/*                                                                 */
/*******************************************************************/
void lcd_wdat(uchar dat)
{                          
   while(lcd_busy());
    LCD_RS = 1;
    LCD_RW = 0;
    LCD_EN = 0;
    P0 = dat;
    delayNOP();
    LCD_EN = 1;
    delayNOP();
    LCD_EN = 0;
}
/*******************************************************************/
/*                                                                 */
/*  LCD初始化設(shè)定                                                  */
/*                                                                 */
/*******************************************************************/
void lcd_init()
{

    LCD_PSB = 1;         //并口方式

    lcd_wcmd(0x34);      //擴(kuò)充指令操作
    delay(5);
    lcd_wcmd(0x30);      //基本指令操作
    delay(5);
    lcd_wcmd(0x0C);      //顯示開,關(guān)光標(biāo)
    delay(5);
    lcd_wcmd(0x01);      //清除LCD的顯示內(nèi)容
    delay(5);






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