#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(2,3); //CE,CSN
const byte address[6] = "00001";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address); //6 pipes can be opened on the same address for reading at the same time
radio.startListening(); //sets module as a receiver
}
void loop() {
// put your main code here, to run repeatedly:
//Serial.println(radio.isChipConnected());
Serial.println("hello");
delay(1000);
}
I am attempting to establish wireless communication between an arduino Uno and arduino micro, both equipped with nRF24L01 modules.
My problem is that when I uncomment the Serial.println(radio.isChipConnected()); the entire program stops working as nothing is printed to the Serial. As soon as a comment out the Serial.println(radio.isChipConnected()), the program runs and the serial prints "hello" every second as expected.
I am not sure as to why the function .isChipConnected() stops the entire program whenever it is present. As a matter of fact, even when I switch the order of isChipConnected() and "hello", as shown below, the program will still not print anything to the serial.
void loop() {
// put your main code here, to run repeatedly:
Serial.println("hello");
Serial.println(radio.isChipConnected());
delay(1000);
}
Even a Serial.print() command in the setup portion (which should run long before the loop even begins) will not print to the serial.
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(2,3); //CE,CSN
const byte address[6] = "00001";
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address); //6 pipes can be opened on the same address for reading at the same time
radio.startListening(); //sets module as a receiver
Serial.println("setup message");
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("hello");
Serial.println(radio.isChipConnected());
delay(1000);
}
I am genuinely confused as to how a single line of code seemingly violates everything I know about programming. Am I missing something incredibly obvious?