0% found this document useful (0 votes)
33 views

Code Function Line of Code RF24, : Step I

The document describes the process of setting up wireless communication between an RF24 radio transmitter and receiver module connected to Arduino boards. It involves initializing the RF24 radio objects, setting the transmitter and receiver addresses to match, setting the transmitter power level and switching it to transmit mode, and setting the receiver to listen for incoming data packets addressed to it. The receiver will then print any received data to the serial monitor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

Code Function Line of Code RF24, : Step I

The document describes the process of setting up wireless communication between an RF24 radio transmitter and receiver module connected to Arduino boards. It involves initializing the RF24 radio objects, setting the transmitter and receiver addresses to match, setting the transmitter power level and switching it to transmit mode, and setting the receiver to listen for incoming data packets addressed to it. The receiver will then print any received data to the serial monitor.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CODE FUNCTION LINE OF CODE

RF24 radio(7, 8); // CE, CSN


Two RF24 objects are created. The two arguments here are the CSN and CE
STEP I
pins. The pins CSN and CE can be connected to any digital pin of the Arduino
board and they are used for setting the module in standby or active mode, as
well as for switching between transmit or command mode.
STEP II const byte address[6] = "00001";
We create a byte array which will represent the address, or the so called pipe
through which the two modules will communicate. We can change the value of
this address to any 5 letter string and this enables to choose to which receiver
we will talk, so in our case we will have the same address at both the receiver
and the transmitter.
STEP III We can set the sensitivity of Accelerometer by putting min and max value in #define minVal -50
the code
#define MaxVal 50
STEP IV radio.openWritingPipe(address);
In the setup section, we initialized the radio object and using the
radio.openWritingPipe() function we set the address of the receiver to which
we will send data, the 5 letter string we previously set.
STEP V radio.setPALevel(RF24_PA_MIN);
Power Amplifier level is set, in our case, to minimum as the transmitter and
receiver modules are very close to each other.
STEP VI radio.stopListening();
Next we have the radio.stopListening() function which sets module as
transmitter
RECEIVER
At the beginning of the setup function we can now print the frame. This lcd.setCursor(0, 0);
function is very simple, it uses lcd.setCursor(#,#) to move the cursor and lcd.print("Accident/Road Threat ");
lcd.print(“”) to print the given string. The function will print the top and lcd.setCursor(0, 1);
bottom horizontal lines, then printing other custom characters. lcd.print(" Alert System ");
delay(15000);
lcd.clear();
lcd.print("Initializing");
lcd.setCursor(0, 1);
lcd.print("Please Wait...");
delay(5000);
lcd.clear();
lcd.print("Callibrating ");
lcd.setCursor(0, 1);
lcd.print("Accelerometer");
lcd.clear();
Next using radio.setReadingPipe() function we set the same address as radio.openReadingPipe(0, address);
transmitter and in that way we enable the communication between transmitter
and receiver.
The next step is to set the module as a receiver and start receiving data. To do radio.startListening();
that we use radio.startListening() function. From that moment the modem
waits for data sent to the specified address.

In the loop function: The sketch checks whether any data has arrived at the if (radio.available())
address using radio.available() method. This method returns TRUE value if we {
any data is available in buffer. char text[32] = {0};
If the data is received, then it creates an array of 32 characters filled with zeros radio.read(&text, sizeof(text));
(later the program will fill it with the received data). To read the data we use Serial.println(text);
the method radio.read (& text, sizeof (text)). This will store the received data }
in to our character array.

You might also like