I'm trying to communicate two arduino boards using nrf transreceivers. when the program goes into loop for both boards( where they look for any message received) and i reset one board then automatically the other board resets. any kind of help will be appreciated.
any kind of help will be appreciated.
Sorry. My crystal ball is out for repairs. A schematic and the code on both ends would be needed to help you.
Code:
#include <SPI.h>
#include <Mirf.h>
#include <nRF24L01.h>
#include <MirfHardwareSpiDriver.h>
int c=0;
int k=5;
long wait;
void setup(){
Serial.begin(9600);
Serial.println("starting");
Mirf.spi=&MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"00000");
Mirf.payload=32;
Mirf.config();
while(k)
{
address_resolution();
k=k-1;
}
Serial.println(c);
}
void loop(){
while(Mirf.dataReady())
{
c++;
Mirf.getData((byte *)test_msg);
Serial.println(c);
}
}
void address_resolution(){
Serial.println(k);
unsigned char test_msg[3]={'a','b','c'};
Mirf.setTADDR((byte *)"00001");
Mirf.send((byte *)test_msg);
Serial.println("before is sending");
while(Mirf.isSending())
{
}
Serial.println("after is sending");
randomSeed(analogRead(A0));
wait=random(20000,100000);
Serial.println(wait);
while(wait){
while(Mirf.dataReady())
{
Mirf.getData((byte *)test_msg);
c++;
Serial.println(c);
}
wait--;
}
// Serial.println("call finished");
}
Power for nrf is from 3.3 V pin of arduino. Code for other board is same just receiev and transmitting address is different(obviously).