-1

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

  • 1
    Surely. You can program your Arduino to stop, if no data was received for a specific amount of time. Though we cannot really give you more advice without more information from you. Please include your code into the question (and format it correctly as code). Also please give us more information, how everything is connected. – chrisl Jun 24 at 7:54
  • use a heartbeat signal – jsotola Jun 24 at 23:00
0

You can do somthing like:

while(radio.hasData()){
}

This works in the NRFLite library. I don't know about other libraries like RF24 etc.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.