Ok, I changed some lines in my sketch and now it looks like this:
#include <LiquidCrystal.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>
int led_sensor = 8;
int led_error = 6;
int sensor[1];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Ready");
radio.begin();
radio.openReadingPipe(1,pipe);
radio.startListening();
pinMode(led_sensor, OUTPUT);
pinMode(led_error, OUTPUT);
}
void loop()
{
if (radio.available())
{
bool done = false;
while (!done)
{
done = radio.read(sensor, sizeof(sensor));
Serial.println(sensor[0]);
delay(20);
if (sensor[0] > 600)
{
digitalWrite(led_error, LOW);
digitalWrite(led_sensor, LOW);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Sleep");
}
else
{
digitalWrite(led_error, LOW);
digitalWrite(led_sensor, HIGH);
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Working");
}
}
}
else
{
lcd.clear();
lcd.setCursor(0, 1);
lcd.print("Radio off");
Serial.println("Radio off");
digitalWrite(led_error, HIGH);
digitalWrite(led_sensor, LOW);
delay(1000);
}
}
Unfortunetly it doesn't work. On the display is only word "ready".
I tried to program the example "Hello world!" and it works, but my sketch not. Is still something wrong in my code?