4ch transmitter and receiver nrf24l01

I haw this code tor transmitter:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN         
const byte address[6] = "00001";     //Byte of array representing the address. This is the address where we will send the data. This should be same on the receiving side.
int button_pin = 2;
boolean button_state = 0;
void setup() {
pinMode(button_pin, INPUT);
radio.begin();                  //Starting the Wireless communication
radio.openWritingPipe(address); //Setting the address where we will send the data
radio.setPALevel(RF24_PA_MIN);  //You can set it as minimum or maximum depending on the distance between the transmitter and receiver.
radio.stopListening();          //This sets the module as transmitter
}
void loop()
{
button_state = digitalRead(button_pin);
if(button_state == HIGH)
{
const char text[] = "Your Button State is HIGH";
radio.write(&text, sizeof(text));                  //Sending the message to receiver
}
else
{
const char text[] = "Your Button State is LOW";
radio.write(&text, sizeof(text));                  //Sending the message to receiver 
}
radio.write(&button_state, sizeof(button_state));  //Sending the message to receiver 
delay(1000);
}

and this code for receiver:

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
boolean button_state = 0;
int led_pin = 3;
void setup() {
pinMode(6, OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);   //Setting the address at which we will receive the data
radio.setPALevel(RF24_PA_MIN);       //You can set this as minimum or maximum depending on the distance between the transmitter and receiver.
radio.startListening();              //This sets the module as receiver
}
void loop()
{
if (radio.available())              //Looking for the data.
{
char text[32] = "";                 //Saving the incoming data
radio.read(&text, sizeof(text));    //Reading the data
radio.read(&button_state, sizeof(button_state));    //Reading the data
if(button_state == HIGH)
{
digitalWrite(6, HIGH);
Serial.println(text);
}
else
{
digitalWrite(6, LOW);
Serial.println(text);}
}
delay(5);
}

I need to expand to 4 channels, 2 day woking and solutions. Only this work.Schematisc is:

radio.write(&text, sizeof(text));

You need to learn the difference between the size of an array holding a string, and the length of the string in the array.

I need to expand to 4 channels, 2 day woking and solutions.

Try working, instead.

Dumping the useless text being sent is not rocket science. Do it.

Putting 4 switch states in an array, and sending the array is not rocket surgery. Show us what you tried and tell us what the code actually did, how you know that, and how it differs from what you wanted it to do.

I can not write the code in the arduino only simple modification and logically copy cod

This text in the Tx program

const char text[] = "Your Button State is HIGH";

is sending 24 characters (if my counting is correct). You can interpret them separately as 24 channels.

However it may be more sensible to send an array of 4 ints rather than an array of 24 chars

This code in the Rx program

char text[32] = "";                 //Saving the incoming data
radio.read(&text, sizeof(text));    //Reading the data

should be matched to the type and size of the data being sent - i.e. 24 characters.

...R Simple nRF24L01+ Tutorial

How to add more button to tx an more led to rx? add int button_pin3 = 3; next pin?

boolean button_state = 0; and add: boolean button_state2 = 0; ??? or not?

How to add more button to tx an more led to rx?

Did you miss the part about using arrays?

PaulS: Did you miss the part about using arrays?

no part, part add is simple, need me arduino code for mor button and let to rx. after add 2 button me self add more.

Need me code for this picture

If you know how to read from one pin, and store the value in a variable, reading from the nth pin in an array, and storing the result in the nth element of an array, and doing that in a loop is trivial.

Give it a shot, and show us what you come up with.

djgorandj: How to add more button to tx an more led to rx?

Have you carefully studied the examples in my Tutorial - they have most of what you need.

...R