Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
arduino_hm_trlr_s_433mhz_rf_receiver
#include <HRFMessage.h>
#define led 2
HRFMessage client(&Serial1);
long lastSendTime = 0;
void setup()
{
pinMode(led, OUTPUT);
Serial.begin(9600);
Serial1.begin(9600);
}
void loop()
{
long thisTime = millis();
if (thisTime > lastSendTime + 1000)
{
client.send((uint8_t*)"Robolink\n", 11);
lastSendTime = thisTime;
}
uint8_t buf[HRF_MAX_MESSAGE_LEN];
uint8_t len = sizeof(buf);
if (client.recv((uint8_t*)&buf, &len))
{
if(len==9) { Serial.print("Alinan: ");
Serial.println((const char*)buf);
client.send((uint8_t*)"Led Yandi\n", 11);
digitalWrite(led,HIGH);
}
if(len==12)
{
Serial.print("Alinan: ");
Serial.println((const char*)buf);
client.send((uint8_t*)"Led Sondu\n", 11);
digitalWrite(led,LOW);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.