szpapas 发表于 2013-10-1 06:08:05

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

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");
}


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




redtxd 发表于 2018-12-4 19:51:41

谢谢楼主分享,正在学习这个
页: [1]
查看完整版本: nRF24L01的字符串传输的例子修正