Overview:
This routine is divided into sending and receiving parts. The sending terminal consists of the SunFounder Mega 2560, five buttons, and NRF24L01 module. The receiving terminal consists of SunFounder Nano, 4-channel relay module, and NRF24L01 module. The five keys on the sending terminal are defined as sw1, sw2, sw3, sw4, and sw5. The first four keys are corresponding to the four channels on the relay module of the receiving terminal. The sw5 key is a close key. When any keys are pressed on the sending terminal, the corresponding relay channel on the receiving terminal will be energized. When sw5 is pressed, all the relays will be disconnected.
Components:
-1 * SunFounder Mega 2560
-1 * SunFounder Nano
-2 * NRF24L01
-1 * 4-channel relay module
-1 * Breadboard
-1 * USB Cable for Mega 2560
-1 * USB Cable for Nano
-Several jumper wires
-5 * Buttons
Experimental Procedures
Step1: Build the circuit
Sending Terminal
1)The wiring between the five buttons and SunFounder Mega 2560 is as follows:
Buttons | SunFounder Mega 2560 |
Sw1 | 2 |
Sw2 | 3 |
Sw3 | 4 |
Sw4 | 5 |
Sw5 | 6 |
GND | GND |
2)The wiring between NRF24L01 and SunFounder Mega 2560 is as follows:
NRF24L01 | SunFounder Mega 2560 |
CE | 22 |
CSN | 24 |
SCK | 26 |
MOSI | 28 |
MISO | 30 |
IRQ | 32 |
GND | GND |
VCC | 5V |
Receiving Terminal
1) The wiring between NRF24L01 and SunFounder Nano is as follows:
NRF24L01 | SunFounder Nano |
CE | 8 |
CSN | 9 |
SCK | 10 |
MOSI | 11 |
MISO | 12 |
IRQ | 13 |
GND | GND |
VCC | 5V |
2)The wiring between 4-Channel Relay Module and SunFounder Nano is as follows:
4-Channel Relay Module | SunFounder Nano |
IN1 | 6 |
IN2 | 5 |
IN3 | 4 |
IN4 | 3 |
VCC | 3.3V |
GND | GND |
Step2: Program
Step3: Compile
Step4: Burn nrfTest_send into SunFounder Mega2560 and nrfTest_receive into SunFounder Nano
Summary
When you press button 1 on the sending board, relay 1 of the 4-channel relay module on the receiving board will be energized and IN1 will light up. When you press button 2, relay 2 will closed and IN2 will light up. The same as for button 3, button 4 and button 5.