This circuit integrates an Arduino UNO microcontroller board with an NRF24L01 radio frequency transceiver module. The purpose of the circuit is to enable wireless communication capabilities for the Arduino UNO using the NRF24L01 module. The Arduino UNO is programmed to read analog input from a potentiometer (connected to pin A3) and transmit the processed data wirelessly via the NRF24L01 module.
#include <SPI.h> // to handle the communication interface with the modem
#include <nRF24L01.h> // to handle this particular modem driver
#include <RF24.h> // the library which helps us to control the radio modem
#define pot_pin A3 // Variable pin of POT is to be connected to analog pin A3
RF24 radio(4,5); // Creating instance 'radio' (CE, CSN) CE -> D4 | CSN -> D5
const byte Address[6] = "00009"; // Address to which data to be transmitted
void setup() {
Serial.begin(9600);
pinMode(pot_pin, INPUT); // Setting A3 (POT pin) as input
radio.begin(); // Activate the modem
radio.openWritingPipe(Address); // Sets the address of transmitter to which program will send the data
}
void loop() {
radio.stopListening(); // Setting modem in transmission mode
int value = analogRead(pot_pin); // Reading analog value at pin A3 and storing in variable 'value'
int data = map(value, 0, 1023, 0, 255); // Converting the 10-bit value to 8-bit
radio.write(&data, sizeof(data)); // Sending data over NRF 24L01
Serial.print("Transmitting Data: ");
Serial.println(data); // Printing POT value on serial monitor
}
The code provided is for the Arduino UNO microcontroller. It initializes the serial communication, configures the analog input pin for the potentiometer, and sets up the NRF24L01 module for data transmission. The loop
function reads the analog value, maps it to an 8-bit value, and transmits it wirelessly. The transmitted data is also printed to the serial monitor for debugging purposes.