Hi guys, I need some help.
I made a simple code to make a bi-directional communication between two Arduinos.
When pressing the button on any one of them, the other receives the info and flashes the led.
When loading the code I change the radioID to have the reverse pipes between them.
Well, on one side I send the signal and the other receives it, conversely the information does not go.
I inverted the NRF24L01 between the Arduinos and the same thing continues, the NRF that sent starts to receive what it received starts to send, but it seems that it is something on the Arduino, because the LED on pin 13 of the pro mini is the SCK pin of the SPI, in an arduino it behaves in a way when sending the info it erases right afterwards it lights up, in the other that receives more it does not send it blinks fast, then afterwards it erases and lights up again.
my code:
#include <nRF24L01.h>
//#include <SPI.h>
#include <RF24.h>
#define radioID 0
RF24 radio(7, 8);
char text[32] = "";
const char texto[] = "nrftest";
byte node_A_address[6] = "NodeA";
byte node_B_address[6] = "NodeB";
//-------------------------------------------------------------------------------------
// SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP SETUP ///////
//-------------------------------------------------------------------------------------
void setup()
{
pinMode(2, OUTPUT);
pinMode(10, INPUT_PULLUP);
radio.begin();
#if radioID == 1
radio.openWritingPipe(node_B_address);
radio.openReadingPipe(1, node_A_address);
#else
radio.openWritingPipe(node_A_address);
radio.openReadingPipe(1, node_B_address);
#endif
radio.setPALevel(RF24_PA_MIN);
radio.setDataRate(RF24_250KBPS);
radio.startListening();
delay(500);
}
void loop()
{
if(radio.available() )
{
radio.read( &text, sizeof(text) );
String transData = String(text);
if(transData == "nrftest")
{
digitalWrite(2, HIGH);
delay(50);
digitalWrite(2, LOW);
delay(5);
transData = "";
}
}
if(!digitalRead(10))
{
radio.stopListening();
delay(50);
radio.write(&texto, sizeof(texto) );
delay(250);
radio.startListening();
}
}