Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PJON_test_transmitter
#include <PJON.h>
// <Strategy name> bus(selected device id)
//PJON<SoftwareBitBang> bus(45);
PJON<OverSampling> bus(45);
long start_ts;
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.include_sender_info(false);
//bus.set_acknowledge(false);
//bus.set_packet_auto_deletion(true);
//bus.set_router(false);
start_ts = millis();
}
void receiver_function(uint8_t *payload, uint8_t length, const PacketInfo &packet_info) {
if(payload[0] == 'C') {
//Serial.println("BLINK");
digitalWriteFast(13, !digitalRead(13));
//delay(10);
//digitalWrite(13, LOW);
}
}
boolean fired=false;
void loop() {
bus.update();
bus.receive(1000);
if (millis() % 1000 < 20){
if(!fired){
fired = true;
start_ts=millis();
digitalWriteFast(13, HIGH);
delay(10);
digitalWrite(13, LOW);
delay(10);
digitalWriteFast(13, HIGH);
delay(10);
digitalWrite(13, LOW);
bus.send(44, "B123", 4);
};
}else{
fired = false;
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment