This project implements a Master-Slave system where two devices communicate using RF24 (nRF24L01) modules to control the status of a green bulb on both devices. The Master device sends a signal to the Slave device, and based on the communication, the green bulb blinks on both devices. Once the Slave device acknowledges the message by pressing a button, both the Master and Slave bulbs stop blinking.
- 3x Arduino (Master and two Slaves devices)
- 3x nRF24L01 modules
- 3x Green LEDs (for both Master and Slave)
- 3x Red LED (optional)
- 3x Blue LED (optional)
- 6x Push buttons
- Jumper wires
- Breadboard
- nRF24L01 module:
- VCC -> 3.3V
- GND -> GND
- CE -> Pin 7
- CSN -> Pin 8
- SCK -> Pin 13
- MOSI -> Pin 11
- MISO -> Pin 12
- Green LED -> Pin 4
- Red LED (optional) -> Pin 3
- Blue LED (optional) -> Pin 5
- Push button (optional) -> Pin 6 (used for manual input)
- nRF24L01 module:
- VCC -> 3.3V
- GND -> GND
- CE -> Pin 53
- CSN -> Pin 48
- SCK -> Pin 13
- MOSI -> Pin 11
- MISO -> Pin 12
- Green LED -> Pin 4
- Red LED (optional) -> Pin 7
- Push button -> Pin 6
This project requires the following libraries:
- SPI: Standard SPI library for Arduino
- RF24: Library to interface with the nRF24L01 modules
- RF24Network: Library for creating networked communication between Arduino devices
- Open the Arduino IDE.
- Go to Sketch > Include Library > Manage Libraries.
- In the Library Manager, search for
RF24andRF24Network. - Install both libraries.
- The master device will push a button to either slave device to be called
- The Master device will constantly listen for a button press on the Slave device.
- When the Slave button is pressed, the Master sends a signal to the Slave to initiate blinking of the green LED.
- The Master then starts blinking its green LED for a duration (1 second) after receiving the signal from the Slave.
- The Slave device listens for a signal from the Master device.
- Upon receiving a signal from the Master, the Slave device starts blinking its green LED for the same duration.
- After acknowledging the signal, the green LED on both Master and Slave turns off.
- the slave devices can also communicate which each other.
The Master code listens for button presses and sends a signal to the Slave when the button is pressed. The green bulb will blink for a defined period when the signal is sent. The code uses RF24Network to handle communication between the Master and Slave.
while (network.available()) {
RF24NetworkHeader header;
payload_t response;
network.read(header, &response, sizeof(response));
greenBlink = true;
if (greenBlink) {
greenBlink = false;
digitalWrite(bulbGreen, LOW);
}
}