极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 14586|回复: 1

nRF24L01的字符串传输的例子修正

[复制链接]
发表于 2013-10-1 06:08:05 | 显示全部楼层 |阅读模式
http://arduino-info.wikispaces.com/nRF24L01-Mirf-Examples

这个例子不错,不过里面有2个BUG。

1. Server:  Serial.print(c)  需要修改为 Serial.print((char)c);

void loop()
{

  byte c;

  // is there any data pending?
  if( Mirf.dataReady() )
  {
     // well, get it
     Mirf.getData(&c);

    // ... and write it out to the PC
     Serial.print(c);
  }
}


Sensor 的  Setup 函数里面缺一行

在Mirf.init(); 前面加一行:
Mirf.spi = &MirfHardwareSpi;


void setup()
{
  
  // init the transceiver
  Mirf.init();

  
  // we transmit only a single byte each time
  Mirf.payload = 1;
  
  // selecting a channel which is not too noisy
  Mirf.channel = 90;
  Mirf.config();

  // Set 1MHz data rate
  Mirf.configRegister(RF_SETUP,0x06);
  
  // Set address - this one must match the
  // address the receiver is using!
  Mirf.setTADDR((byte *)"TX_01");
}


两个陷阱,过分,给没用过的朋友提个醒。




回复

使用道具 举报

发表于 2018-12-4 19:51:41 | 显示全部楼层
谢谢楼主分享,正在学习这个
回复 支持 反对

使用道具 举报

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

本版积分规则 需要先绑定手机号

Archiver|联系我们|极客工坊

GMT+8, 2024-4-17 00:25 , Processed in 0.038269 second(s), 18 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2021, Tencent Cloud.

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