Issue with changing values in nRF24L01

Currently trying to finish a project for my university class, and I can't get the signals to send properly from my nRF24L01 transceivers. I'm trying to send a character through the transceiver that will tell a motor what to on the other end. I've been trying to get this to work for a week to no avail. Right now just for simplicity's sake, the code is supposed to change an LED, not worried about the motor just yet. This is my first time posting to the arduino forums so if I did anything wrong in the post let me know too.

Transmitter code:

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

//create an RF24 object
RF24 radio(9, 8);  // CE, CSN

//address through which two modules communicate.
const byte address = 00001;
void setup()
{
  radio.begin();
  Serial.begin(9600);
  
  //set the address
  radio.openWritingPipe(address);
  
  //Set module as transmitter
  radio.stopListening();
}
void loop()
{
  //Send message to receiver
  char text = '0';
  radio.write(text, 1);
  Serial.println(text);
  delay(1000);
  text = '1';
  radio.write(text, 1);
  Serial.println(text);
  delay(1000);
}

Receiver code:

//Include Libraries
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
int LED_pin= 2;
//create an RF24 object
RF24 radio(9, 8);  // CE, CSN

//address through which two modules communicate.
const byte address = 00001;

void setup()
{

  while (!Serial);
    Serial.begin(9600);

  radio.begin();

  //set the address
  radio.openReadingPipe(0, address);

  //Set module as receiver
  radio.startListening();
  pinMode(LED_pin, OUTPUT);
}

void loop()
{
  //Read the data if available in buffer
  if (radio.available())
  {
    char text='0';
    radio.read(text,1);
    Serial.println(text);
    if (text=='1')
    { digitalWrite(LED_pin, HIGH);
    }
    else{
      digitalWrite(LED_pin, LOW);
    }

Have you read through this handy tutorial: Simple nRF24L01+ 2.4GHz transceiver demo - #2 by Robin2

I've read so much haha, including that. Funny enough, my partner and I have been working on this for 10+ hours. I decide to make a post on these forums and apparently it works if we use a struct.

The write method takes a address not a value. Same with read.
Try

radio.write(&text, 1);

The documentation is here : Optimized high speed nRF24L01+ driver class documentation: RF24 Class Reference

You are using a bogus address for the pipe also, you have to use the address of a five byte array,
not an octal 1, like you do.

const byte address[] = "00001";

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.