Hi all,
I am trying to use the nRF24L01 and Arduino Uno on a project.
I have been trying to read from the radio on line 41 after the 'break' and compare the 'level' value with the character 'e'.
On starting, the program wait to receive the character '1' from the transmitting node then print the 'number'.
I want the program to check the radio for 'level' at each iteration and if the 'level' value received is 'e' print the message 'ok'.
At the moment, my code included here gives me this output with no change when I send 'e' or any other character from the transmitter.
Receiver
iB: 49
Number: 1
level:
.
.
.
.
etc
Thanks for the help.
#include <Wire.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(5, 6); //CSE and CE of the wifi module
int number=0;
int iB = 0;
char level = 0;
int i=0;
const byte rxAddr[6] = "00001"; //Communication channel for the nRF24L01
void setup()
{
Serial.begin(9600);//
//-------nRF24L01-----
radio.begin(); //Start the nRF24L01 module
radio.openReadingPipe(0, rxAddr); //Open channel
radio.startListening();//Await for data
Serial.println("Receiver"); //This is the receiver
}
void loop()
{
while (radio.available()>0)
{
radio.read(&iB, sizeof(iB));
Serial.print("iB: ");
Serial.println(iB);
{
while(iB==49) //49, 50, 51 are equal 1, 2 and 3 respectively
{
for(int i=0; i<=30; i++)
{
number=number+1;
Serial.print("Number: ");
Serial.println(number);
delay(50);
break;
}
radio.read(&level, sizeof(level));
delay(50);
Serial.print("level: ");
Serial.println(level);
if(level=='e')
{
Serial.println("ok");
}
}
}
}
}