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

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索

nrf24l01無線輸液監(jiān)測系統(tǒng) 單片機程序與原理圖

查看數(shù): 3042 | 評論數(shù): 1 | 收藏 1
關(guān)燈 | 提示:支持鍵盤翻頁<-左 右->
    組圖打開中,請稍候......
發(fā)布時間: 2017-8-7 22:01

正文摘要:

nrf24l01芯片做的單片機無線輸液監(jiān)測系統(tǒng)的全部資料分享給大家 程序和原理圖 單片機源程序如下: /*-----------------------------------------------   名稱:外部中斷0電平觸發(fā)  &nbs ...

回復(fù)

ID:1 發(fā)表于 2017-8-7 23:35
一對二數(shù)據(jù)中轉(zhuǎn)
  1. /****************************************Copyright (c)****************************************************
  2. **                                       遼寧科技大學(xué)
  3. **                                    
  4. **                                         電子協(xié)會
  5. **
  6. **--------------File Info---------------------------------------------------------------------------------
  7. ** File Name:           main.c
  8. ** Last modified Date:
  9. ** Last Version:
  10. ** Description:         主函數(shù)
  11. **
  12. **--------------------------------------------------------------------------------------------------------
  13. ** Created By:          王愷
  14. ** Created date:        2013/03/28
  15. ** Version:             V1.0
  16. ** Descriptions:                 NRF24L01無線模塊測試程序
  17. **                                                波特率:4800
  18. **--------------------------------------------------------------------------------------------------------
  19. ** Modified by:
  20. ** Modified date:
  21. ** Version:
  22. ** Description:
  23. **
  24. *********************************************************************************************************/


  25. /*********************************************************************************************************
  26.   包含頭文件
  27. *********************************************************************************************************/
  28. #include "reg51.h"
  29. #include "intrins.h"
  30. #include "nrf24l01.h"
  31. #include "main.h"

  32.   bit no1 = 0,no2 = 0;
  33.   sbit key1 = P3^2;
  34.         unsigned char rx_buf1[4]={0x99,0x99,0x99,0x99};        //必須是4位數(shù)組
  35.         unsigned char rx_buf2[4]={0x99,0x99,0x99,0x99};        //必須是4位數(shù)組
  36.         unsigned char rx_buf[4]={0x00,0x00,0x00,0x00};        //必須是4位數(shù)組

  37. void UART_Send_Str(unsigned char *s);
  38. void SendByte(unsigned char dat);

  39. /*------------------------------------------------
  40.                     串口初始化
  41. ------------------------------------------------*/
  42. void UART_Init(void)
  43. {

  44.     SCON  = 0x50;                        // SCON: 模式 1, 8-bit UART, 使能接收  
  45.     TMOD |= 0x20;               // TMOD: timer 1, mode 2, 8-bit 重裝
  46.     TH1   = 0xFD;               // TH1:  重裝值 9600 波特率 晶振 11.0592MHz  
  47.     TR1   = 1;                  // TR1:  timer 1 打開                        
  48.     EA    = 1;                  //打開總中斷
  49.    // ES    = 1;                  //打開串口中斷
  50. }  
  51. void Delay10ms()                //@12.000MHz
  52. {
  53.         unsigned char i, j;

  54.         i = 117;
  55.         j = 184;
  56.         do
  57.         {
  58.                 while (--j);
  59.         } while (--i);
  60. }



  61. /*********************************************************************************************************
  62. ** Function name:       main
  63. ** Descriptions:        主函數(shù)(接收)
  64. ** input parameters:    無
  65. ** output parameters:   無
  66. ** Returned value:                無
  67. //*********************************************************************************************************/
  68. void main()
  69. {
  70.          
  71.         uchar number = 0,i = 1,j=0,k = 0;

  72.          uchar number1 = 0;
  73.    uchar data1[20] = {0};

  74.         NRF24L01Int();
  75.         UART_Init();
  76.         /*
  77.          *        接收
  78.          */
  79.         while (1)
  80.         {


  81.                         if(no1 == 0)
  82.                         {
  83.                           s_dizhi(0);//設(shè)置地址
  84.                                 NRF24L01Int();
  85.                 NRFSetRXMode();//設(shè)置為接收模式
  86.                 if (NRFRevDate(rx_buf))//開始接受數(shù)
  87.                   {       

  88.                           SendByte(65); //A
  89.                                 SendByte(70); //F
  90.                           SendByte(rx_buf[0]); //此為數(shù)據(jù)       
  91.                                 SendByte(rx_buf[1]); //此為數(shù)據(jù)       
  92.                                 SendByte(rx_buf[2]); //從機編碼               
  93.                                 SendByte(rx_buf[3]);   //從機發(fā)送的次數(shù)       
  94.                                 SendByte(70); //F
  95.                           SendByte(65); //A
  96.                                 NRF24L01Int();//進行初始化并且切換地址掃描
  97. //                                 if(dizhi == 1)no1 = 1;
  98. //                                 if(dizhi == 2)no2 = 1;

  99.             }
  100.                         }
  101.                 if(no2 == 0)
  102.                         {
  103.                           s_dizhi(1);//設(shè)置地址
  104.                                 NRF24L01Int();
  105.                  NRFSetRXMode();//設(shè)置為接收模式
  106.                 if (NRFRevDate(rx_buf))//開始接受數(shù)
  107.                   {       
  108.                           SendByte(65); //A
  109.                                 SendByte(70); //F
  110.                           SendByte(rx_buf[0]);  //此為數(shù)據(jù)               
  111.                                 SendByte(rx_buf[1]);  //此為數(shù)據(jù)               
  112.                                 SendByte(rx_buf[2]);  //從機編碼               
  113.                                 SendByte(rx_buf[3]);  //從機發(fā)送的次數(shù)       
  114.                                 SendByte(70); //F
  115.                           SendByte(65); //A
  116.         NRF24L01Int();
  117. //                                 if(dizhi == 1)no1 = 1;
  118. //                                 if(dizhi == 2)no2 = 1;

  119.             }
  120.                         }
  121.        
  122.         }
  123. }

  124.    void SendByte(unsigned char dat)
  125. {
  126. SBUF = dat;
  127. while(!TI);
  128.       TI = 0;
  129. }
  130. /*------------------------------------------------
  131.                     發(fā)送一個字符串
  132. ------------------------------------------------*/
  133. void UART_Send_Str(unsigned char *s)
  134. {
  135. while(*s!='\0')// \0 表示字符串結(jié)束標(biāo)志,通過檢測是否字符串末尾
  136.   {
  137.   SendByte(*s);
  138.   s++;
  139.   }
  140. }
  141. /*------------------------------------------------
  142.                      串口中斷程序
  143. ------------------------------------------------*/
  144. void UART_SER (void) interrupt 4 //串行中斷服務(wù)程序
  145. {
  146.     unsigned char Temp;          //定義臨時變量
  147.    
  148.    if(RI)                        //判斷是接收中斷產(chǎn)生
  149.      {
  150.           RI=0;                      //標(biāo)志位清零
  151.           Temp=SBUF;                 //讀入緩沖區(qū)的值
  152.           P1=Temp;                   //把值輸出到P1口,用于觀察
  153.       SBUF=Temp;                 //把接收到的值再發(fā)回電腦端
  154.          }
  155.    if(TI)                        //如果是發(fā)送標(biāo)志位,清零
  156.      TI=0;
  157. }
復(fù)制代碼

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表