I have been using the common RF (Radio frequency) modules in some of my recent projects in combination with the Arduino. I have managed to send singular messages between each module, furthermore i have been trying to find a way to be able to change the message without having to re-upload the code each time.
Project context:
I want the transmitter to be able to send either "yes" or "no" depending on the High input of ptm buttons to the Arduino. And for the Receiving module to maybe light up a LED depending on the "yes" or "no" input.
Thanks in advance
Notes:
i have been using the radiohead library: RadioHead: RadioHead Packet Radio library for embedded microprocessors
Error:
C:\Users\Spades\Desktop\ask_transmitterYesNo\ask_transmitterYesNo.ino:5:14: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
char Blank = ".";
^
C:\Users\Spades\Desktop\ask_transmitterYesNo\ask_transmitterYesNo.ino: In function 'void loop()':
C:\Users\Spades\Desktop\ask_transmitterYesNo\ask_transmitterYesNo.ino:23:13: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
Blank = "Yes";
^
C:\Users\Spades\Desktop\ask_transmitterYesNo\ask_transmitterYesNo.ino:27:13: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
Blank = "No";
^
C:\Users\Spades\Desktop\ask_transmitterYesNo\ask_transmitterYesNo.ino:31:13: warning: invalid conversion from 'const char*' to 'char' [-fpermissive]
Blank = ".";
^
C:\Users\Spades\Desktop\ask_transmitterYesNo\ask_transmitterYesNo.ino:33:23: warning: invalid conversion from 'char' to 'const char*' [-fpermissive]
const char *msg = Blank;
^
Code:
#include <RH_ASK.h>
#include <SPI.h> // Not actually used but needed to compile
int YesPin = 7;
int NoPin = 6;
char Blank = "."; //blank is the variable that will be stated when there is no input from YesPin and NoPin
RH_ASK driver(2000, 9, 2, 10); // ESP8266 or ESP32: do not use pin 11
void setup()
{
Serial.begin(9600); // Debugging only
pinMode(YesPin, INPUT);
pinMode(NoPin, INPUT);
if (!driver.init())
Serial.println("init failed");
}
void loop()
{
if (digitalRead (YesPin)== HIGH);
{
Blank = "Yes";
}
if (digitalRead (NoPin)== HIGH);
{
Blank = "No";
}
if (digitalRead (YesPin) == LOW and digitalRead (YesPin) == LOW);
{
Blank = ".";// if YesPin or NoPin is neither high then "." will apear
}
const char *msg = Blank;// previous setup for singular message would be const char *msg = "example"
Serial.println(Blank);
driver.send((uint8_t *)msg, strlen(msg));
driver.waitPacketSent();
delay(1000);// checks if blank variable has been changed every second
}
ask_transmitterYesNo.ino (795 Bytes)