I am trying to turn a LED on and off using 434Mhz receiver and transmitter. I am able to to get the basic communication work between the receiver and transmitter. However, I cannot the coding work by using the text message the receiver gets. Please see my coding below:
on the transmitter side:
#include <RH_ASK.h>
#include <SPI.h>
...
...
...
loop(){
const char* msg1="Y";
driver.send((uint8_t *)msg1, strlen(msg1));
driver.waitPacketSent();
}
On the receiver side:
uint8_t buf[1];
uint8_t buflen = sizeof(buf);
if (rf_driver.recv(buf, &buflen))
{
// Message received with valid checksum
Serial.print("Message Received: ");
Serial.println((char*)buf);
if ((char*)buf=="Y")Serial.println("light on");
}
the serial monitor shows:
18:45:49.151 -> Message Received: Y
18:45:49.424 -> Message Received: Y
18:45:49.697 -> Message Received: Y
18:45:49.972 -> Message Received: Y
18:45:50.245 -> Message Received: Y
18:45:50.519 -> Message Received: Y
18:45:50.760 -> Message Received: Y
why does not the coding on the receiver side if ((char*)buf=="Y")Serial.println("light on"); work???
Please help.