I was using the nRF24L01 and when I was verifying my program, I noticed an error message. The ‘Void loop’ section of my program is:
void loop()
{
fsrReading = analogRead(0);
if (radio.available() )
{
if (fsrReading < 500);
radio.write(fsrReading);
}
}
and the error message says:
no matching function for call to ‘RF24::write(int&)’
Buttons_and_Bluetooths.ino: In function ‘void loop()’:
Buttons_and_Bluetooths:38: error: no matching function for call to ‘RF24::write(int&)’
/Users/richcoughlan/Documents/Arduino/libraries/RF24/RF24.h:152: note: candidates are: bool RF24::write(const void*, uint8_t)
/Users/richcoughlan/Documents/Arduino/libraries/RF24/RF24.h:271: note: bool RF24::write(const void*, uint8_t, bool)
I’m not sure what this means, and I don’t know how to fix it. If you explain what to do, could you also explain what this means? (Especially explain what ‘bool’ is, I’m very curious.)
I think you'll find that radio.write is expecting a buffer (holding a string of characters) and a length;
So you'd usually use something like
radio.write(fsrReading,100);// (assuming fsrReading is a character array)
//if fsrReading is an integer, you'd use something like
char buffer[20];
sprintf(buffer,"%d",fsrReading);
radio.write(buffer,20);
KenF:
I think you'll find that radio.write is expecting a buffer (holding a string of characters) and a length;
So you'd usually use something like
radio.write(fsrReading,100);// (assuming fsrReading is a character array)
//if fsrReading is an integer, you'd use something like
char buffer[20];
sprintf(buffer,"%d",fsrReading);
radio.write(buffer,20);
I have no idea what that means. (I'm sorry for my noobishness. I just joined and started programming, and I'm only 12, and... I don't think noobishness is a word...)
In which case you want to convert to an array of chars as KenF suggest. I will explain his code:
char buffer[20]; //Create an array of char, 20 long.
sprintf(buffer,"%d",fsrReading); //print the contents of fsrReading into the array of chars called buffer
radio.write(buffer,20); // Write the contents of the array buffer which is 20 long over the radio.