EDABOSS电子论坛

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 679|回复: 1

[资料共享] 台产24L01+无线模块资料与单片机源程序

[复制链接]

79

主题

20

回帖

375

E币

技术员

Rank: 2

积分
178
发表于 2018-8-18 09:51:29 | 显示全部楼层 |阅读模式
24L01无线模块,要的可下


捕获.PNG

单片机源程序如下:
  1. /******************************************************************************/
  2. /*
  3. //  文件名:main.c                                                              
  4. //  说明:供客户测试模块通信使用程序                                                                  
  5. //  编写人员:                                                                  
  6. //  编写日期:                                                              
  7. //  程序维护:
  8. //  维护记录:
  9. //
  10. //                                                         
  11. */
  12. // 免责声明:该程序仅用于学习与交流
  13. // (c) Anxinke Corporation. All rights reserved.                                                               
  14. /******************************************************************************/
  15. #include "typedef.h"
  16. #include "gpio.h"
  17. #include "uart.h"
  18. #include "nrf24l01p.h"
  19. #include "delay.h"

  20. uchar txData[32] = {0x00};
  21. uchar rxData[32] = {0x00};

  22. /******************************************************************************/
  23. // 函数名称:main
  24. // 输入参数:
  25. // 输出参数:
  26. // 函数功能:
  27. /******************************************************************************/
  28. void main(void)
  29. {
  30.     unsigned char i=0;
  31.     uartInit();   
  32.     Delay100ms();
  33.     init_nrf24l01_io();
  34.     led1ON();
  35.     Delay100ms();
  36.     led1OFF();
  37.     Delay100ms();
  38.     led1ON();
  39.     Delay100ms();
  40.     led1OFF();
  41.    
  42.     Delay100ms();
  43.     uartSendString("System initialization is complete!\r\n");
  44.     receive_mode_init();
  45.    
  46.     while(1)
  47.     {
  48.         KEY1 = 1;
  49.         KEY2 = 1;
  50.         /*
  51.          * 判断是否按下KEY
  52.         */
  53.         if (key1ON() || key2ON()) {
  54.             _delay_us(500);
  55.             txData[0] = 0;
  56.             if (key1ON()) {
  57.                 txData[0] = 0xAA; // 如果按下K1  则将数据置为0xAA  
  58.                 uartSendString("You press the left button\r\n");
  59.             } else if (key2ON()){
  60.                 txData[0] = 0x55; // 如果按下K2  则将数据置为0x55
  61.                 uartSendString("You press the Right button\r\n");
  62.             }
  63.             /*
  64.              * 根据不同的数据LED提示
  65.             */
  66.             if (send_data(txData) == 1) {
  67.                 uartSendString("Success of sending data\r\n");
  68.                 if (txData[0] == 0xAA) {
  69.                     led1ON();   
  70.                 } else if (txData[0] == 0x55) {
  71.                     led2ON();
  72.                 }
  73.                 Delay100ms();   
  74.                 led1OFF();
  75.                 led2OFF();
  76.             } else {
  77.                 uartSendString("Failed to send data\r\n");
  78.             }      
  79.             receive_mode_init();
  80.         }
  81.         rxData[0] = 0;
  82.         led1OFF();
  83.         led2OFF();
  84.         if (receive_data(rxData)) {
  85.             if (rxData[0] == 0xAA) {
  86.                 led1ON();
  87.                 uartSendString("Receiving the data, from the Left\r\n");
  88.             } else if (rxData[0] == 0x55) {
  89.                 led2ON();
  90.                 uartSendString("Receiving the data, from the Right\r\n");
  91.             }
  92.             Delay100ms();
  93.         }
  94.    
  95.     }
  96. }
复制代码



台产24L01 资料.rar

2.98 MB, 下载次数: 3, 下载积分: E币 -5 元

积分规则
回复

使用道具 举报

30

主题

33

回帖

39

E币

技术员

Rank: 2

积分
93
发表于 2018-10-25 21:55:34 | 显示全部楼层
谢谢分享
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|EDABOSS电子论坛

GMT+8, 2024-4-24 21:10 , Processed in 0.042204 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表