Skip to content

Instantly share code, notes, and snippets.

@errkk
Created December 1, 2015 23:24
Show Gist options
  • Save errkk/e3c0efa51f3e73acd382 to your computer and use it in GitHub Desktop.
Save errkk/e3c0efa51f3e73acd382 to your computer and use it in GitHub Desktop.
#include <Manchester.h>
#define RX_PIN 0
#define RELAY_PIN 1
uint8_t data;
uint8_t id;
void setup() {
pinMode(RELAY_PIN, OUTPUT);
man.setupReceive(RX_PIN, MAN_1200);
man.beginReceive();
digitalWrite(RELAY_PIN, HIGH);
delay(10000);
digitalWrite(RELAY_PIN, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
if (man.receiveComplete()) { //received something
uint16_t m = man.getMessage();
man.beginReceive(); //start listening for next message right after you retrieve the message
if (man.decodeMessage(m, id, data)) { //extract id and data from message, check if checksum is correct
if(id == (uint8_t)4) {
digitalWrite(RELAY_PIN, HIGH);
delay(200000);
digitalWrite(RELAY_PIN, LOW);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment