So I have been working a project for a while which uses a NRF24L01 (has no 10 microfarad capacitor) and I found myself with a problem.
Here is the link of a youtube video the demonstrates everything about the project:
But in case you don't have time, basically is a car that can fire a dart, activate a buzzer, turn on lights and two wheels. It is controlled with a remote control and the car has two sensors: a HC SR04 and a light sensor built with a LDR and a resistor.
Right now it does not have a cable anymore, it has a 7.4 v battery with 1300 mAh (lippo battery).
Here is the problem, whenever the car loses signal I can't get it back (I have to switch it off and on) and it does the last command it receives (so if its last order was to go forward it will keep going forward).
Here it is the code:
of the car:
of the command:
Here it is what I tried to do:
if (radio.available()) {
radio.read(&dataSendFinal, sizeof(struct data));
radio.writeAckPayload(1, &DataOutFinal, sizeof(DataOutFinal));
Serial.println("Command:");
dataSendFinal.print();
Serial.println("Sensors");
DataOutFinal.print();
}else{
wheelControl(0, 26, 27); //rignt wheel
wheelControl(0, 28, 29); //left wheel
digitalWrite(3,1);
delay(25);
digitalWrite(3,0);
delay(25);
digitalWrite(3,1);
delay(25);
digitalWrite(3,0);
delay(25); //one of the LEDs blinks when radio is not available
}
The modification is on the else statement, but it did not go well.
What happens is that it stops and it goes forward over and over again and it blinks the LED more times than, at least, I would expect. I pretend to find a way of making it stop when it loses signal, but it would be nice to find a way to make it able to get control again.
NOTE: in the video there is a GUI, I did not put the code, because I don't believe it is import.