Skip to content

Instantly share code, notes, and snippets.

@Girgitt
Created April 21, 2017 21:37
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/f5b1d2d92d3e734f5d94ff38584d2051 to your computer and use it in GitHub Desktop.
Save Girgitt/f5b1d2d92d3e734f5d94ff38584d2051 to your computer and use it in GitHub Desktop.
PJON WINX86 platform arduino code
#include <PJON.h>
// <Strategy name> bus(selected device id)
PJON<ThroughSerial> bus(44);
void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, LOW); // Initialize LED 13 to be off
Serial.begin(115200);
bus.strategy.set_serial(&Serial);
bus.begin();
bus.set_receiver(receiver_function);
bus.set_synchronous_acknowledge(true);
bus.send_repeatedly(45, "ABC test", 8, 1000000);
};
void receiver_function(
uint8_t *payload,
uint16_t length,
const PJON_Packet_Info &packet_info
) {
if(payload[0] == 'B') {
digitalWrite(13, HIGH);
delay(5);
digitalWrite(13, LOW);
}
}
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