Check if Nrf24l01 is connected?


I'm making a robot for autonomous driving in a compotition, converted RC car. But just for having some fun I'm also converting a Playstation 2 controller into a remote controll, so I can drive the car as a RC car.

My question is. Is there a way for my RX arduino to check if there is a nrf24l01 chip connected. That way I don't need to reprogram the RX arduino between the autonomous and RC sketch. The sketches is almost done as separate sketches, I just need to make my new hardware, the old car was rubbish so I'm converting a better car now.

I know that I can use IFDEF to load different configuration, but how can I dismiss everything that is assosiated with the nrf24l01 setup? I have a separate tab in the IDE conserning the nrf24l01.

The only thing I have used IFDEF with is debugging so far.

Using the Mirf library

Thanks Kjell B


is a compile-time directive. You can't use it to change the behavior of your sketch on-the-fly.

I would have a global variable which holds the current state: autonomous or RC. Then test that with if() statements to select the proper behavior for the current state.

I'm not going to remove the nrf24l01 while power is on. Turn of the car and then change to autonomous or RC.

One way would be for the transmitter to send some character at regular intervals - mayby 5 or 10 times per second. If the receiver does not get that character it will know it is intended to be in autonomous mode.