Created
October 8, 2019 11:18
-
-
Save RobolinkAkademi/2c5a8c350d296cf785de134c068c46b6 to your computer and use it in GitHub Desktop.
arduino_hm_trlr_s_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 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