Skip to content

Instantly share code, notes, and snippets.

@Girgitt
Created August 17, 2016 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Girgitt/81eb7dbf8e879bd781c3fd01cf55b3ab to your computer and use it in GitHub Desktop.
Save Girgitt/81eb7dbf8e879bd781c3fd01cf55b3ab to your computer and use it in GitHub Desktop.
PJON_test_receiver
#include <PJON.h>
// <Strategy name> bus(selected device id)
//PJON<SoftwareBitBang> bus(44);
PJON<OverSampling> bus(44);
void setup() {
pinModeFast(13, OUTPUT);
digitalWriteFast(13, LOW); // Initialize LED 13 to be off
bus.set_pins(8, 7);
bus.set_receiver(receiver_function);
bus.begin();
bus.set_communication_mode(HALF_DUPLEX);
//bus.include_sender_info(false);
//bus.set_acknowledge(true);
//bus.set_packet_auto_deletion(true);
//bus.set_router(false);
Serial.begin(9600);
};
void receiver_function(uint8_t *payload, uint8_t length, const PacketInfo &packet_info) {
if(payload[0] == 'B') {
//Serial.println("BLINK");
digitalWriteFast(13, !digitalRead(13));
//delay(10);
//digitalWrite(13, LOW);
//bus.reply("C1", 2);
//bus.update();
}
}
void loop() {
bus.update();
bus.receive(1000);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment