So i've inherited a sketch and as i'm already discovering it's using some obscure libraries and configurations. In a nutshell it's a simple remote control using 2 RF Nano's
//Transmitter program
#include <SPI.h>
#include "Mirf.h"
#include "nRF24L01.h"
#include "MirfHardwareSpiDriver.h"
Nrf24l Mirf = Nrf24l(10, 9);
int value;
const int BUTTON1 = 2;
const int BUTTON2 = 3;
const int BUTTON3 = 4;
const int BUTTON4 = 5;
const int BUTTON5 = 6;
const int BUTTON6 = 7;
int BUTTONstate1 = 0;
int BUTTONstate2 = 0;
int BUTTONstate3 = 0;
int BUTTONstate4 = 0;
int BUTTONstate5 = 0;
int BUTTONstate6 = 0;
void setup()
{
pinMode(BUTTON1, INPUT);
pinMode(BUTTON2, INPUT);
pinMode(BUTTON3, INPUT);
pinMode(BUTTON4, INPUT);
pinMode(BUTTON5, INPUT);
pinMode(BUTTON6, INPUT);
Serial.begin(9600);
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
//Set your own address (sender address) using 5 characters
Mirf.setRADDR((byte *)"ABCDE");
Mirf.payload = sizeof(value);
Mirf.channel = 90; //Set the channel used
Mirf.config();
}
void loop()
{
Mirf.setTADDR((byte *)"FGHIJ"); //Set the receiver address
Button1();
Button2();
Button3();
Button4();
Button5();
Button6();
delay(1000);
}
void Button1()
{
BUTTONstate1 = digitalRead(BUTTON1);
if (BUTTONstate1 == HIGH)
{
value = 1;
}
Mirf.send((byte *)&value); //Send instructions, send random number value
Serial.print("Wait for sending.....");
while (Mirf.isSending()) delay(1); //Until you send successfully, exit the loop
Serial.print("Send success:");
Serial.println(value);
}
void Button2()
{
BUTTONstate2 = digitalRead(BUTTON2);
if (BUTTONstate2 == HIGH)
{
value = 2;
}
Mirf.send((byte *)&value); //Send instructions, send random number value
Serial.print("Wait for sending.....");
while (Mirf.isSending()) delay(1); //Until you send successfully, exit the loop
Serial.print("Send success:");
Serial.println(value);
}
void Button3()
{
BUTTONstate3 = digitalRead(BUTTON3);
if (BUTTONstate3 == HIGH)
{
value = 3;
}
Mirf.send((byte *)&value); //Send instructions, send random number value
Serial.print("Wait for sending.....");
while (Mirf.isSending()) delay(1); //Until you send successfully, exit the loop
Serial.print("Send success:");
Serial.println(value);
}
void Button4()
{
BUTTONstate4 = digitalRead(BUTTON4);
if (BUTTONstate4 == HIGH)
{
value = 4;
}
Mirf.send((byte *)&value); //Send instructions, send random number value
Serial.print("Wait for sending.....");
while (Mirf.isSending()) delay(1); //Until you send successfully, exit the loop
Serial.print("Send success:");
Serial.println(value);
}
void Button5()
{
BUTTONstate5 = digitalRead(BUTTON5);
if (BUTTONstate5 == HIGH)
{
value = 5;
}
Mirf.send((byte *)&value); //Send instructions, send random number value
Serial.print("Wait for sending.....");
while (Mirf.isSending()) delay(1); //Until you send successfully, exit the loop
Serial.print("Send success:");
Serial.println(value);
}
void Button6()
{
BUTTONstate6 = digitalRead(BUTTON6);
if (BUTTONstate6 == HIGH)
{
value = 6;
}
Mirf.send((byte *)&value); //Send instructions, send random number value
Serial.print("Wait for sending.....");
while (Mirf.isSending()) delay(1); //Until you send successfully, exit the loop
Serial.print("Send success:");
Serial.println(value);
}
and the receiver
//Receiver program
#include <SPI.h>
#include "Mirf.h"
#include "nRF24L01.h"
#include "MirfHardwareSpiDriver.h"
Nrf24l Mirf = Nrf24l(10, 9);
int value;
const int LED1 = 2;
const int LED2 = 3;
const int LED3 = 4;
const int LED4 = 5;
const int LED5 = 6;
const int LED6 = 7;
void setup()
{
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(LED5, OUTPUT);
pinMode(LED6, OUTPUT);
Serial.begin(9600);
Mirf.spi = &MirfHardwareSpi;
Mirf.init();
Mirf.setRADDR((byte *)"FGHIJ"); //Set your own address (receiver address) using 5 characters
Mirf.payload = sizeof(value);
Mirf.channel = 90; //Set the used channel
Mirf.config();
Serial.println("Listening..."); //Start listening to received data
}
void loop()
{
if (Mirf.dataReady()) { //When the program is received, the received data is output from the serial port
Mirf.getData((byte *) &value);
Serial.print("Got data: ");
Serial.println(value);
case1();
case2();
case3();
case4();
case5();
case6();
}
}
void case1()
{
if (value == 1)
{
digitalWrite(LED1, HIGH);
}
else{
digitalWrite(LED1, LOW);
}
}
void case2()
{
if (value == 2)
{
digitalWrite(LED2, HIGH);
}
else{
digitalWrite(LED2, LOW);
}
}
void case3()
{
if (value == 3)
{
digitalWrite(LED3, HIGH);
}
else{
digitalWrite(LED3, LOW);
}
}
void case4()
{
if (value == 4)
{
digitalWrite(LED4, HIGH);
}
else{
digitalWrite(LED4, LOW);
}
}
void case5()
{
if (value == 5)
{
digitalWrite(LED5, HIGH);
}
else{
digitalWrite(LED5, LOW);
}
}
void case6()
{
if (value == 6)
{
digitalWrite(LED6, HIGH);
}
else{
digitalWrite(LED6, LOW);
}
}
Currently when compiling i get the error message
receiver:6:27: error: no matching function for call to 'Nrf24l::Nrf24l(int, int)'
Nrf24l Mirf = Nrf24l(10, 9);
^
In file included from C:\Users\thomas\Dropbox\Arduino\2.4g_remote_nano\receiver\receiver\receiver.ino:3:0:
C:\Users\thomas\Dropbox\My PC (DESKTOP-D9H8EF8)\Documents\Arduino\libraries\Mirf/Mirf.h:42:3: note: candidate: Nrf24l::Nrf24l()
Nrf24l();
^~~~~~
C:\Users\thomas\Dropbox\My PC (DESKTOP-D9H8EF8)\Documents\Arduino\libraries\Mirf/Mirf.h:42:3: note: candidate expects 0 arguments, 2 provided
C:\Users\thomas\Dropbox\My PC (DESKTOP-D9H8EF8)\Documents\Arduino\libraries\Mirf/Mirf.h:40:7: note: candidate: constexpr Nrf24l::Nrf24l(const Nrf24l&)
class Nrf24l {
^~~~~~
C:\Users\thomas\Dropbox\My PC (DESKTOP-D9H8EF8)\Documents\Arduino\libraries\Mirf/Mirf.h:40:7: note: candidate expects 1 argument, 2 provided
C:\Users\thomas\Dropbox\My PC (DESKTOP-D9H8EF8)\Documents\Arduino\libraries\Mirf/Mirf.h:40:7: note: candidate: constexpr Nrf24l::Nrf24l(Nrf24l&&)
C:\Users\thomas\Dropbox\My PC (DESKTOP-D9H8EF8)\Documents\Arduino\libraries\Mirf/Mirf.h:40:7: note: candidate expects 1 argument, 2 provided
exit status 1
no matching function for call to 'Nrf24l::Nrf24l(int, int)'
It's beyond my ability to rewrite this from scratch and i've spent 2 days googling terms and library names to try and understand how to fix the problem myself with no luck. I /assume/ (since that's been a recurring problem) that i'm using the wrong library version or settings but am clueless as to what or how it should be?
Help?