I am using two nano-combo for a RC car and when the remote emitter battery is too down if the car was running and battery finally empty the car was still running...is there any way by programming to check communication between the two nanos and solve this problem??. Thanks.
here is the code: //Receiver program
#include <SPI.h>; #include "Mirf.h" #include "nRF24L01.h" #include "MirfHardwareSpiDriver.h" Nrf24l Mirf = Nrf24l(10, 9);
void setup() { Serial.begin(9600); Mirf.spi = &MirfHardwareSpi; Mirf.init(); Mirf.setRADDR((byte *)"FGHIJ"); //Set your own address (receiver address) using 5 characters Mirf.payload = sizeof(datos); Mirf.channel = 90; //Set the used channel Mirf.config(); //Serial.println("Listening..."); //Start listening to received data
void loop()
{
if (Mirf.dataReady()) { //When the program is received, the received data is
output from the serial port
Mirf.getData(datos);
delay(5);
if (datos[7] >= 150) { //motor forward
analogWrite(3,0);
analogWrite(5,255);
}
if (datos[7] <= 90) { motor back
analogWrite(3,255);
analogWrite(5,0);
}
if (datos[7] > 90 && datos[7] < 150 or datos[7] == 0) { //motor stop
analogWrite(5,0);
analogWrite(3,0);
} } }
it works perfect I can control dc motor no problem but if remoto control battery is low or empty then no communication with NANO receiver and the motor spin itself non stop.
I try different things in the void loop like:
if (!Mirf.dataReady()) { analogWrite(5,0); analogWrite(3,0); }
but still the same problem. So that´s why must be something inside Rf library to check if remote control NANO comms is off I don`t know...
Thanks