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 [Link](address);
In the setup section, we initialized the radio object and using the
[Link]() function we set the address of the receiver to which
we will send data, the 5 letter string we previously set.
STEP V [Link](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 [Link]();
Next we have the [Link]() function which sets module as
transmitter
RECEIVER
At the beginning of the setup function we can now print the frame. This [Link](0, 0);
function is very simple, it uses [Link](#,#) to move the cursor and [Link]("Accident/Road Threat ");
[Link](“”) to print the given string. The function will print the top and [Link](0, 1);
bottom horizontal lines, then printing other custom characters. [Link](" Alert System ");
delay(15000);
[Link]();
[Link]("Initializing");
[Link](0, 1);
[Link]("Please Wait...");
delay(5000);
[Link]();
[Link]("Callibrating ");
[Link](0, 1);
[Link]("Accelerometer");
[Link]();
Next using [Link]() function we set the same address as [Link](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 [Link]();
that we use [Link]() 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 ([Link]())
address using [Link]() 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 [Link](&text, sizeof(text));
(later the program will fill it with the received data). To read the data we use [Link](text);
the method [Link] (& text, sizeof (text)). This will store the received data }
in to our character array.