Send a big int array (NRF24L01+)

Hello!

I am sorry if this seems like a silly question but I don’t really understand what I’m doing (I’m more of a hardware guy and don’t know that much about programming).

This is my project, I’m trying to build a wireless controller for my PC (mainly to learn about multiplexing and such).
What I don’t really know is how I should approach to send my data through a NRF24L01+. My idea was that I just put all variables and put them into an array and then send all button states and joystick states through integers. This means that for now the array is 22 integer long (all with values below 255).
I read that the NRF24L01+ can only handle 32 bytes of data and wondering if that’s my problem?

The problem I’m facing is that the nano gets stuck at radio.write(sendData, sizeof(22)); I believe since when I troubleshoot I get to that point and not further (hence the random Serial.println(“x”); numbers).

Again, I am not a programmer at no means and my code is messy but I just want to try and understand why I’m failing. Sorry for the true eye-sore.

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

int pin_Out_S0 = 5;
int pin_Out_S1 = 4;
int pin_Out_S2 = 3;
int pin_In_Mux1 = A6;
int Mux1_State[8] = {0};

int latchPin = 6;
int dataPin = 10;
int clockPin = 9;

byte switchVar1 = 72;  //01001000
byte switchVar2 = 159; //10011111
int sendData[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0};

int HY;
int VX;
int VY;
int HX;
int R1;
int R2;

RF24 radio(8, 7); // CE, CSN
const byte address[6] = "00001";

void setup() {
  
  pinMode(pin_Out_S0, OUTPUT);
  pinMode(pin_Out_S1, OUTPUT);
  pinMode(pin_Out_S2, OUTPUT);
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, INPUT);
  //pinMode(pin_In_Mux1, INPUT);
  Serial.begin(9600);

  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();
  
}

void loop() {
  Serial.println("0");
  updateMux1();

    //Pulse the latch pin:
  //set it to 1 to collect parallel data
  digitalWrite(latchPin,1);
  //set it to 1 to collect parallel data, wait
  delayMicroseconds(20);
  //set it to 0 to transmit data serially  
  digitalWrite(latchPin,0);

  //while the shift register is in serial mode
  //collect each shift register into a byte
  //the register attached to the chip comes in first
  switchVar1 = shiftIn(dataPin, clockPin);
  switchVar2 = shiftIn(dataPin, clockPin);
  Serial.println("1");

  for (int n=0; n<=7; n++)
  {
    //so, when n is 3, it compares the bits
    //in switchVar1 and the binary number 00001000
    //which will only return true if there is a
    //1 in that bit (ie that pin) from the shift
    //register.
    if (switchVar1 & (1 << n) ){
      //print the value of the array location
      sendData[n] = 1;
      
    }
  }

  Serial.println("2");

  for (int n=0; n<=7; n++)
  {
    //so, when n is 3, it compares the bits
    //in switchVar1 and the binary number 00001000
    //which will only return true if there is a
    //1 in that bit (ie that pin) from the shift
    //register.
    if (switchVar2 & (1 << n) ){
      //print the value of the array location
      int a = 8;
      int y = n + a;
      sendData[y] = 1;
      
    }
  }

  Serial.println("3");

  for(int g = 0; g <= 21; g++)
    {
      Serial.println(sendData[g]);
    }

  Serial.println("4");
  radio.write(sendData, sizeof(22));
  delay(20);
  Serial.println("5");
  int sendData[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0};
  
}

void updateMux1 () {
  for (int i = 0; i < 8; i++){
    digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
    digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
    digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
    Mux1_State[i] = analogRead(pin_In_Mux1);
    if(i == 0) {sendData[16] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 1) {sendData[17] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 4) {sendData[18] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 6) {sendData[19] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 5) {sendData[20] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 7) {sendData[21] = map(Mux1_State[i], 0, 1023, 0, 255);}
  }
}


  byte shiftIn(int myDataPin, int myClockPin) {
  int i;
  int temp = 0;
  int pinState;
  byte myDataIn = 0;

  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, INPUT);

//we will be holding the clock pin high 8 times (0,..,7) at the
//end of each time through the for loop

//at the begining of each loop when we set the clock low, it will
//be doing the necessary low to high drop to cause the shift
//register's DataPin to change state based on the value
//of the next bit in its serial information flow.
//The register transmits the information about the pins from pin 7 to pin 0
//so that is why our function counts down
  for (i=7; i>=0; i--)
  {
    digitalWrite(myClockPin, 0);
    delayMicroseconds(2);
    temp = digitalRead(myDataPin);
    if (temp) {
      pinState = 1;
      //set the bit to 0 no matter what
      myDataIn = myDataIn | (1 << i);
    }
    else {
      //turn it off -- only necessary for debuging
     //print statement since myDataIn starts as 0
      pinState = 0;
    }

    //Debuging print statements
    //Serial.print(pinState);
    //Serial.print("     ");
    //Serial.println (dataIn, BIN);

    digitalWrite(myClockPin, 1);

  }
  //debuging print statements whitespace
  //Serial.println();
  //Serial.println(myDataIn, BIN);
  return myDataIn;
}

Before anyone makes a comment about it, I have tried googling, and the answers I find (or well, might be answers) are too advanced for me to understand and adapt to my code. I’m way out of my league of this but I truly want to learn and need help.

Thank you all in advance!

BunnyPig:
My idea was that I just put all variables and put them into an array and then send all button states and joystick states through integers. This means that for now the array is 22 integer long (all with values below 255).

So just use uint8_t as type of the array, which makes it 22 bytes long.

Whandall:
So just use uint8_t as type of the array, which makes it 22 bytes long.

So it should be like this instead?

uint8_t sendData[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0};

That could work, if handled correctly.

  radio.write(sendData, sizeof(22));

Seems you were sending only two bytes, that should be changed.

  int sendData[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0};

Absolute nonsense.

Given these two finds the quality of your code seems questionalble.

I don't think delay has a place in communiction programs.

Whandall:
That could work, if handled correctly.

  radio.write(sendData, sizeof(22));

Seems you were sending only two bytes, that should be changed.

  int sendData[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0};

Absolute nonsense.

Given these two finds the quality of your code seems questionalble.

I don't think delay has a place in communiction programs.

As I previously mentioned I am well aware that my coding is far below standards.
I changed the first one to;

radio.write(sendData, sizeof(sendData));

but what do you mean by nonsense? I want to reset the array since I want all buttons to be off when sending the data. If I don't they will stay 1. Is there a better way of doing this you mean?

The statement does not reset any array, it declares a new one, maybe with the name of a previous one.
Then the array goes out of scope directly.
The compiler notices that this unreferenced declaration is never used and will reove it from the program.

To answer your question, any method would be better than a non existent one.

I would suggest you work through a basic C/C++ tutorial before continuing.

Whandall:
The statement does not reset any array, it declares a new one, maybe with the name of a previous one.
Then the array goes out of scope directly.
The compiler notices that this unreferenced declaration is never used and will reove it from the program.

To answer your question, any method would be better than a non existent one.

I would suggest you work through a basic C/C++ tutorial before continuing.

Can you at least point me to which direction I should look?
If I don't know what I should look up I can't do anything, the entire library for C/C++ is huge and I don't even know what I should look for in this regard. I know some basics but like I mentioned before, I just want help.
I don't want you to write the code for me, I just want help so I know where I am doing wrong. Everything in the code works for the needs I need even if it is ugly and badly optimized.

You don't need a library, but a basic C/C++ knowledge about scope, data types etc.
That type of information can be learned from a basic tutorial.

Maybe somebody will help you fix your program right now,
but learning to do it yourself is the better way IMHO.

BunnyPig:
So it should be like this instead?

uint8_t sendData[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0};

Have you tried a revised of the program with that in it? By the way, you need an equivalent modification in the receiving program.

What happened when you tried it?

Please post the revised version of your two programs (Tx and RX) in your next Reply.

...R
Simple nRF24L01+ Tutorial

Robin2:
Have you tried a revised of the program with that in it? By the way, you need an equivalent modification in the receiving program.

What happened when you tried it?

Please post the revised version of your two programs (Tx and RX) in your next Reply.

…R
Simple nRF24L01+ Tutorial

Hi! Yeah, I tried it with no progress. I also managed to clean up some things after I read some things about arrays and stuff like that.
I also followed your post in fact about getting it to work but I am now very certain that my issue is that the nrf24l01 that I have are broken (or well, one of them, I only have 2 of them). I get scrambled garbage even if I just try to send 1 bit of data or 1 byte.

The code I’m trying to use now is on the reciever;

// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

char dataReceived[10]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        Serial.println(dataReceived);
        newData = false;
    }
}

and the master;

// SimpleTx - the master or the transmitter

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define CE_PIN   9
#define CSN_PIN 10

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

char dataToSend[10] = "Message 0";
char txNum = '0';


unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 1000; // send once per second


void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
}

//====================

void loop() {
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {

    bool rslt;
    rslt = radio.write( &dataToSend, sizeof(dataToSend) );
        // Always use sizeof() as it gives the size as the number of bytes.
        // For example if dataToSend was an int sizeof() would correctly return 2

    Serial.print("Data Sent ");
    Serial.print(dataToSend);
    if (rslt) {
        Serial.println("  Acknowledge received");
        updateMessage();
    }
    else {
        Serial.println("  Tx failed");
    }
}

//================

void updateMessage() {
        // so you can see that new data is being sent
    txNum += 1;
    if (txNum > '9') {
        txNum = '0';
    }
    dataToSend[8] = txNum;
}

The error I get when I try to use the nrf24l01 is;

Data received B⸮!B⸮!	
Data received 
Data received 
Data received 
Data received B⸮!B⸮!	
Data received 
Data received 
Data received 
Data received B⸮!B⸮!	
Data received 
Data received 
Data received 
Data received B⸮!B⸮!	
Data received 
Data received 
Data received 
Data received B⸮!B⸮!	

etc…

So, from what I understand is that my modules are not working properly (I’ve checked all the wiring and I’ve also soldered them so I get a 100% connection. Also I’ve added the caps to the 3.3v lines and ground. The modules has also been powered by an external power source to make sure they get the power they need.).

It's always a good idea to have some spare nRF24s for situations like this. And a good idea to be sure things are working before soldering them :slight_smile:

Does it make any difference if you upload the Tx program to the RX Arduino and vice versa?

...R

Robin2:
It's always a good idea to have some spare nRF24s for situations like this. And a good idea to be sure things are working before soldering them :slight_smile:

Does it make any difference if you upload the Tx program to the RX Arduino and vice versa?

...R

Well actually, I managed to borrow some modules from my friend and they are working, so mine are probably busted.
Swapping them as TX and RX didn't make a difference. So I'm very certain they are broken and I will order some new ones now.

This might be an unrelated question, if I'm certain that I can't send data (it gets stuck at radio.write(&sendData, sizeof(sendData)); ), is it because I'm trying to send something that's too large for the module to process?

BunnyPig:
This might be an unrelated question, if I’m certain that I can’t send data (it gets stuck at radio.write(&sendData, sizeof(sendData)); ), is it because I’m trying to send something that’s too large for the module to process?

You need to post the complete programs for the Tx and the Rx. The devil is in the detail.

…R

Well, this is what I have so far and of course, I know it is horrendous to look at but I don’t see why it shouldn’t work even if it’s garbage :frowning:

TX side;

// SimpleTx - the master or the transmitter
//------------------------- Radio -------------------------//
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>


#define CE_PIN   8
#define CSN_PIN 7

const byte slaveAddress[5] = {'R','x','A','A','A'};


RF24 radio(CE_PIN, CSN_PIN); // Create a Radio

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 100; // send once per 100 ms

//------------------------- Radio -------------------------//

//------------------------- Values -------------------------//

int pin_Out_S0 = 5;
int pin_Out_S1 = 4;
int pin_Out_S2 = 3;
int pin_In_Mux1 = A6;
int Mux1_State[8] = {0};

int latchPin = 6;
int dataPin = 10;
int clockPin = 9;

byte switchVar1 = 72;  //01001000
byte switchVar2 = 159; //10011111
byte sendData[8] = {0, 0, 0, 0, 0, 0, 0, 0};

//------------------------- Values -------------------------//

void setup() {

    Serial.begin(9600);
//------------------------- Radio -------------------------//
    Serial.println("SimpleTx Starting");

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5); // delay, count
    radio.openWritingPipe(slaveAddress);
//------------------------- Radio -------------------------//

//------------------------- Values -------------------------//
    pinMode(pin_Out_S0, OUTPUT);
    pinMode(pin_Out_S1, OUTPUT);
    pinMode(pin_Out_S2, OUTPUT);
    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
    pinMode(dataPin, INPUT);
    pinMode(pin_In_Mux1, INPUT);
//------------------------- Values -------------------------//
}

//====================

void loop() {

      digitalWrite(latchPin,1);
      delayMicroseconds(20); 
      digitalWrite(latchPin,0);
      switchVar1 = shiftIn(dataPin, clockPin);
      sendData[0] = switchVar1;
      switchVar2 = shiftIn(dataPin, clockPin);
      sendData[1] = switchVar2; 
      updateMux1();
  
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        send();
        prevMillis = millis();
    }
}

//====================

void send() {

    //Displaying my values to send in serial
    for(int i = 0; i < 8; i++) {
        Serial.print(sendData[i]);
        Serial.print(", ");
        if(i == 7) {Serial.println(" ");}
        }

    //Sending
    radio.write( &sendData, sizeof(sendData) );
  
}


//================

void updateMux1 () {
  for (int i = 0; i < 8; i++){
    digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
    digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
    digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
    Mux1_State[i] = analogRead(pin_In_Mux1);
    if(i == 0) {sendData[2] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 1) {sendData[3] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 4) {sendData[4] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 6) {sendData[5] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 5) {sendData[6] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 7) {sendData[7] = map(Mux1_State[i], 0, 1023, 0, 255);}
  }
}


  byte shiftIn(int myDataPin, int myClockPin) {
  int i;
  int temp = 0;
  int pinState;
  byte myDataIn = 0;

  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, INPUT);

  for (i=7; i>=0; i--)
  {
    digitalWrite(myClockPin, 0);
    delayMicroseconds(2);
    temp = digitalRead(myDataPin);
    if (temp) {
      pinState = 1;
      myDataIn = myDataIn | (1 << i);
    }
    else {
      pinState = 0;
    }
    digitalWrite(myClockPin, 1);
  }
  return myDataIn;
}

RX side;

// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

byte dataReceived[8]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        for(int i = 0; i < 8; i++) {

            Serial.print(dataReceived[i]);
            Serial.print(", ");
            if(i == 7) {Serial.println(" ");}
          
        }
        newData = false;
    }
}

Again, if you have any pointers at all I’d be very happy to hear them so I can improve my code.
To recap, I can’t send the data, it gets stuck on radio.write( &sendData, sizeof(sendData) ); when I troubleshoot it.
Thank you for helping me!

You have added a huge amount of code to my SimpleTx program.

I presume you tested the program regularly while it was growing. At what point while you were adding code, did it stop working?

Have you tried a very simple version that just sends the byte array, and perhaps increments the values in the array between transmissions?

...R

Robin2:
You have added a huge amount of code to my SimpleTx program.

I presume you tested the program regularly while it was growing. At what point while you were adding code, did it stop working?

Have you tried a very simple version that just sends the byte array, and perhaps increments the values in the array between transmissions?

...R

Yeah I did. I tried to narrow it down to when I'm reading from the shift register chips.
Weird thing is that the array in itself will be sent if I manually put in some values (I tried "simulating" the values that should be sent and then it works). But as soon as I try to grab some values and insert them into the array it stops working.
I've tried changing the array type to different ones to see if it's the byte value that gets messed up but no luck.

I am very certain that everything is in order until it hits the radio.write command, then it just hangs. During my troubleshooting I make sure to write the values in serial monitor so I know that the values are in the array and that they are correct, and they are.

Edit: noticed I typed a lot of text to just say "Yes I tried it in steps and I think it stops when I take read values and insert them into the array" so left this here for clearance.

BunnyPig:
I am very certain that everything is in order until it hits the radio.write command, then it just hangs.

If that radio.write() sends the array correctly when the array is NOT updated by other parts of your program then it seems to me very unlikely that radio.write() is the cause of the problem.

I would need to create all of your hardware to reproduce your problem and I can't do that.

If this was my problem I would set aside the Tx program and start again with a minimal Tx program that sends the byte array.

Then I would add a few lines of code that update one of the elements in the byte array and check that the program still works. If it does I would add another few lines of code and test etc etc etc

...R

Robin2:
If that radio.write() sends the array correctly when the array is NOT updated by other parts of your program then it seems to me very unlikely that radio.write() is the cause of the problem.

I would need to create all of your hardware to reproduce your problem and I can't do that.

If this was my problem I would set aside the Tx program and start again with a minimal Tx program that sends the byte array.

Then I would add a few lines of code that update one of the elements in the byte array and check that the program still works. If it does I would add another few lines of code and test etc etc etc

...R

Yeah, that's true.
I'll set up everything and I'll post an update as soon as I find anything. I really appreciate your help!

Okay, I’ve been tinkering around now with the code and I’m not sure what to think, I’ll try to explain it as well as I can.

Something is colliding with the dataToSend[0] = shiftIn(dataPin, clockPin); and radio.write( &dataToSend, sizeof(dataToSend) );

If I disable the radio.write() command on the TX side, the code runs flawlessly. I can read all my buttons and I can read all my joysticks. Everything looks good when I print each value from dataToSend array in serial monitor.

But the problem is, as soon as I activate the radio.write() command it just stops. I still get all values as I want them and how they worked before activating the command.

If I then disable dataToSend command and send everything else over the nRF24L01, it works on both the RX and TX side, getting everything I need except the two first values in dataToSend array.

I was thinking the data was corrupt on dataToSend[0] and dataToSend[1] but I still get the right values through serial monitor.

TX;

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   8
#define CSN_PIN 7

const byte slaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

byte dataToSend[8] = {0};

unsigned long currentMillis;
unsigned long prevMillis;
unsigned long txIntervalMillis = 500;

int pin_Out_S0 = 5;
int pin_Out_S1 = 4;
int pin_Out_S2 = 3;
int pin_In_Mux1 = A6;
int Mux1_State[8] = {0};

int latchPin = 6;
int dataPin = 10;
int clockPin = 9;

byte switchVar1 = 1;
byte switchVar2 = 2;

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleTx Starting");

    pinMode(pin_Out_S0, OUTPUT);
    pinMode(pin_Out_S1, OUTPUT);
    pinMode(pin_Out_S2, OUTPUT);

    pinMode(latchPin, OUTPUT);
    pinMode(clockPin, OUTPUT);
    pinMode(dataPin, INPUT);

    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.setRetries(3,5);
    radio.openWritingPipe(slaveAddress);
    
}

//====================

void loop() {

    updateMux1(); 
    updateButtons();
    currentMillis = millis();
    if (currentMillis - prevMillis >= txIntervalMillis) {
        radio.write( &dataToSend, sizeof(dataToSend) );
        prevMillis = millis();
    }
}

void updateMux1 () {
  for (int i = 0; i < 8; i++){
    digitalWrite(pin_Out_S0, HIGH && (i & B00000001));
    digitalWrite(pin_Out_S1, HIGH && (i & B00000010));
    digitalWrite(pin_Out_S2, HIGH && (i & B00000100));
    Mux1_State[i] = analogRead(pin_In_Mux1);
    if(i == 0) {dataToSend[2] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 1) {dataToSend[3] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 4) {dataToSend[4] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 6) {dataToSend[5] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 5) {dataToSend[6] = map(Mux1_State[i], 0, 1023, 0, 255);}
    if(i == 7) {dataToSend[7] = map(Mux1_State[i], 0, 1023, 0, 255);}
  }
}


void updateButtons() {

  digitalWrite(latchPin,1);
  delayMicroseconds(20);
  digitalWrite(latchPin,0);

  //dataToSend[0] = shiftIn(dataPin, clockPin);
  //dataToSend[1] = shiftIn(dataPin, clockPin);
  
}


byte shiftIn(int myDataPin, int myClockPin) {
  int i;
  int temp = 0;
  int pinState;
  byte myDataIn = 0;

  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, INPUT);

  for (i=7; i>=0; i--)
  {
    digitalWrite(myClockPin, 0);
    delayMicroseconds(2);
    temp = digitalRead(myDataPin);
    if (temp) {
      pinState = 1;
      //set the bit to 0 no matter what
      myDataIn = myDataIn | (1 << i);
    }
    else {
      pinState = 0;
    }
    digitalWrite(myClockPin, 1);
  }
  return myDataIn;
}

RX;

// SimpleRx - the slave or the receiver

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

#define CE_PIN   9
#define CSN_PIN 10

const byte thisSlaveAddress[5] = {'R','x','A','A','A'};

RF24 radio(CE_PIN, CSN_PIN);

byte dataReceived[8]; // this must match dataToSend in the TX
bool newData = false;

//===========

void setup() {

    Serial.begin(9600);

    Serial.println("SimpleRx Starting");
    radio.begin();
    radio.setDataRate( RF24_250KBPS );
    radio.openReadingPipe(1, thisSlaveAddress);
    radio.startListening();
}

//=============

void loop() {
    getData();
    showData();
}

//==============

void getData() {
    if ( radio.available() ) {
        radio.read( &dataReceived, sizeof(dataReceived) );
        newData = true;
    }
}

void showData() {
    if (newData == true) {
        Serial.print("Data received ");
        for(int i = 0; i < 8; i++) {
          Serial.print(dataReceived[i]);
          Serial.print(", ");
          if(i == 7) {Serial.println(" ");} 
        }
        newData = false;
    }
}

Edit: After some more troubleshooting, I think it’s specifically shiftIn(dataPin, clockPin); that’s causing the issue. Even if I just try to enter the value from shiftIn into a variable the radio.write(); doesn’t do anything.

You don't seem to have any Serial.print() statements to allow you to see what your shiftIn() function does.

What happens if you modify the end of the shiftIn() function like this

    digitalWrite(myClockPin, 1);
  }
  myDataIn = 123;
  return myDataIn;
}

Also, what is the purpose of the pinState variable - it does not seem to be used.

...R