找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1553|回复: 0
打印 上一主题 下一主题
收起左侧

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

[复制链接]
跳转到指定楼层
楼主
24L01无线模块,要的可下




单片机源程序如下:
  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. }
复制代码

所有资料51hei提供下载:
台产24L01 资料.rar (2.98 MB, 下载次数: 10)


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

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

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

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