Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Arduino.h>
- #define PJON_INCLUDE_TS true
- //#define PJON_INCLUDE_ETHERNET false
- #include <PJON.h>
- #include "AltSoftSerial.h"
- // <Strategy name> bus(selected device id)
- PJON<ThroughSerial> bus(2);
- AltSoftSerial serial;
- void receiver_function(uint8_t *payload, uint16_t length, const PJON_Packet_Info &packet_info) {
- /* Make use of the payload before sending something, the buffer where payload points to is
- overwritten when a new message is dispatched */
- Serial.println("RECEIVED");
- if(payload[0] == 'B') {
- digitalWrite(13, HIGH);
- delay(30);
- digitalWrite(13, LOW);
- }
- };
- void setup() {
- Serial.begin(9600);
- Serial.println("STARTING");
- pinMode(13, OUTPUT);
- digitalWrite(13, LOW); // Initialize LED 13 to be off
- serial.begin(9600);
- bus.begin();
- bus.set_receiver(receiver_function);
- bus.strategy.set_serial(&serial);
- };
- void loop() {
- bus.receive(1000);
- //bus.send(1, "B", 1);
- //delay(1000);
- };
Advertisement
Add Comment
Please, Sign In to add comment