Created
October 8, 2019 11:09
-
-
Save RobolinkAkademi/15bc91c9ae1ddd32e6794ed9d43b5ebd to your computer and use it in GitHub Desktop.
arduino_hm_trlr_dw_433mhz_rf_receiver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <HRFMessage.h> | |
#define led 4 | |
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