Nrf24L01-2.4GHz-ExampleSketches
Nrf24L01-2.4GHz-ExampleSketches
These are example Arduino software sketches that show how to use the nRF24L01 radio modules. Start with our overall nRF24L01 Information and How-To HERE to make sure you connect the nRF24L01 modules correctly. Consider using one of the ["base modules"] to get stable 3.3V DC power to your modules. Otherwise consider soldering capacitors across Vcc and Gnd on your modules. See the How-To..
Below are the different examples as they are written and tested here. Click on the names below. There are also many examples that come with the RF24 library and you can see them RIGHT HERE
Bare Minimum example:
This is not a very good example for practical use, but it details the few minimum things you need to do to create radio sketches that work for nRF24L01 Transmit and Receive. Copy and paste these examples into a BLANK window on your Arduino IDE. VERIFY to check them out. You NEED the RF24 library downloaded and installed. See the How-To.
nRF24L01-SimpleTransmit-01
nRF24L01-SimpleReceive-01
TRANSMIT JOYSTICK POSITION DATA TO ANOTHER ARDUINO WITH 2 SERVOS
These examples include a full round-trip error checking and acknowledge system. They use many of the features of the nRF24L01 Radios and the RF24 Library by TMRH2O such as setting the channel frequency and the power output level. They print the activity and data received on the Serial Monitor at 115200 speed.
- OPTIONS:** //**Hardware**// - This version defaults to using fixed data with no required Joystick or Servos, for test purposes. There is a variable in both sketches called 'hasHardware' which is set to 'false'. When you have joystick and/or servo hardware connected then set hasHardware = true;
- OPTIONS: //Radio RF Power Level//** - If you get your radios communicating OK and you think you have good 3.3V power, you can set the RF Power Amplifier to "RF24_PA_MAX". It is initially set to "RF24_PA_LOW" to be less sensitive to poor 3.3V power. See This Page about nRF24L01 problems, power solutions. We strongly recommend the 'base modules' to get reliable information.
- SERVOS:** Servos draw a lot of current and will **not** work when the Arduino is powered from USB. You must use some external 5V power supply for the servos. The YourDuino RoboRED pictured on the How-to page has a built-in 5V 2A power supply that can run 2 servos when the External power connector is supplied with 9 to 12V.
SKETCH: JOYSTICK DATA TRANSMITTED TO ANOTHER ARDUINO
(Cut and paste into a blank Arduino IDE window)
SKETCH: JOYSTICK DATA RECEIVED FROM ANOTHER ARDUINO
(Cut and paste into a blank Arduino IDE window)
zz