This is the code for the transmitter (just for testing the code)
#include <SoftwareSerial.h>
SoftwareSerial hc(10, 11); // HC-12 TX Pin, HC-12 RX Pin
double first;
double second;
void setup() {
// put your setup code here, to run once:
hc.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
hc.write(first, second); //the compiler shows "no matching function for call to 'SoftwareSerial::write(double&, double&)'"
delay(5);
}
And this is the code for the receiver (just for testing the code)
#include <SoftwareSerial.h>
SoftwareSerial hc(10, 11); // HC-12 TX Pin, HC-12 RX Pin
double first;
double second;
void setup() {
// put your setup code here, to run once:
hc.begin(9600);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if(hc.available()){
hc.read(first, second); //the compiler shows no matching function for call to 'SoftwareSerial::read(double&, double&)'
Serial.write(first);
Serial.write("is the first value and");
Serial.write(second);
Serial.println("is the second value");
delay(250);
}
}
I also tried in the receiver code,
hc.read() = first, second;
but the compiler shows "lvalue required as left operand of assignment"