Created
August 17, 2016 14:43
-
-
Save Girgitt/6161cf65ac5b774909e0a00e09dd33d3 to your computer and use it in GitHub Desktop.
PJON_test_transmitter
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 <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