Arduinoed again- help me declare this?

There are a few problems with this:
‘void value ignored as it ought to be (67,12)’
'a value of type ‘void’ cannot be assigned to an entity of type ‘bool’.

But this is my biggest problem:
getData is a function, and it’s called for in void loop. It’s undeclared in this scope.

I’m going to have to try to resolve these declaration problems. There are too many. Since all the examples are written for Arduino, there’s a lot of secret handshake stuff.



#include <Arduino.h>
#include <SPI.h>
#include "nRF24L01.h"
#include "RF24.h"
//#include "printf.h"

#define ledPin 4

// Set up nRF24L01 radio on SPI bus plus pins 9 & 10
RF24 radio(9, 10);

// Radio pipe addresses for the 2 nodes to communicate.
const uint64_t pipes[2] = {
    0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL};

void setup(void)
  pinMode(ledPin, OUTPUT);
  // printf_begin();
  // printf("THIS IS THE RECIVER");


  // optionally, increase the delay between retries & # of retries
  radio.setRetries(15, 15);
  // optionally, reduce the payload size.  seems to
  // improve reliability

  radio.openReadingPipe(1, pipes[0]);

  //radio.printDetails(); uncomment to debug

void loop(void)
  unsigned long data_in = getData();
  if (data_in == 999)
    Serial.println("THE VALUE IS HIGH!");
    digitalWrite(ledPin, HIGH);
  else if (data_in == 111)
    Serial.println("THE VALUE IS LOW");
    digitalWrite(ledPin, LOW);
  else if (data_in != 111 || data_in != 999)
    Serial.println("UNEXPECTED DATA IN");

unsigned long getData()
  unsigned long got_time;
  if (radio.available())
    // Dump the payloads until we've gotten everything
    bool done = false;
    while (!done)
      // Fetch the payload, and see if this was the last one.
      done =, sizeof(unsigned long)); // return true when done
      // Spew it
      // printf("Got payload %lu...",got_time);
  return (got_time);

I might be going blind, but the only assignment to a bool that Ican see is:

Not counting the assignment of false obviously.

This implies that is returning void and not a bool value. You need to check in the headerfile for the radio class, for the return type for read().

Either put getData() above any other function which calls it, like loop(), or, just add:

unsigned long getData();

After the various includes. In C++ you must declare any function before it is called. The Arduino system hides this from you. As demonstrated here: Tutorial for creating multi cpp file arduino project - #38 by NormanDunbar


Nitpick: This logic is wrong. You want to say that, if that data is not 111 and it is not 999 as well, the data is unexpected. So it has to be else if (data_in != 111 && data_in != 999). Play it through with data_in = 999. Then, with your current logic, data != 200 is true and data != 999 is false, and true | false gives true, thus making the data “unexpected”.

However, you have already handled all valid values above, so just write it as an else statement and not else if. Everything else not handled above is unexpected.

@normandunbar is correct. The read function is defined as

and thus void. For correct usage, just follow the example a little above in the header file