Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #define INCLUDE_ASYNC_ACK true
  2. #include <PJON.h>
  3.  
  4.  
  5. // <Strategy name> bus(selected device id)
  6. PJON<ThroughSerial> bus(44);
  7.  
  8. void setup() {
  9. //pjon
  10. pinModeFast(13, OUTPUT);
  11. digitalWriteFast(13, LOW); // Initialize LED 13 to be off
  12. bus.begin();
  13. bus.set_receiver(receiver_function);
  14. Serial.begin(9600);
  15. bus.strategy.set_serial(&Serial);
  16. bus.strategy.set_enable_RS485_pin(2);
  17.  
  18. }
  19.  
  20. void receiver_function(uint8_t *payload, uint16_t length, const PacketInfo &packet_info) {
  21. if(payload[0] == 'A') {
  22. digitalWrite(13, HIGH);
  23. delay(30);
  24. digitalWrite(13, LOW);
  25. delay(60);
  26. digitalWrite(13, HIGH);
  27. delay(30);
  28. digitalWrite(13, LOW);
  29. } else {
  30. if(payload[0] == 'B') {
  31. digitalWrite(13, HIGH);
  32. delay(30);
  33. digitalWrite(13, LOW);
  34. }
  35. }
  36. };
  37.  
  38. void loop() {
  39. bus.receive(1000);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement