Ciao! I finally released PJON in version 1.0 and is now stable, full of working examples and with a decent readme. PJON is a opensource Arduino multimaster communications bus system. With this library you can connect up to 255 Arduino boards (Duemilanove, Uno, Nano, Mini and Mega are supported) on the same wire and have communication speed of more then 4kB/s without using any interrupt or timer. Timing and syncronization is obtained using only micros() and delayMicroseconds(). This library is designed to be not interrupt driven and non-blocking.
Here the blink example. An arduino communicates a B every second over the wire to the second arduino that will blink if receives B:
#include <PJON.h> // Transmitter board code
PJON network(12, 45); // Bus connection to pin 12, device id 45
void setup() {
network.send(44, "B", 1, 1000000);
// Send to device 44, "B" content of 1 byte length every 1000000 microseconds (1 second)
}
void loop() {
network.update();
}
/* ---------------------------------------------------------------------------- */
#include <PJON.h> // Receiver board code
PJON network(12, 44); // Bus connection to pin 12, device id 45
void setup() {
network.set_receiver(receiver_function); // Set the function used to receive messages
};
static void receiver_function(uint8_t length, uint8_t *payload) {
if(payload[0] == 'B') { // If the first letter of the received message is B
digitalWrite(13, HIGH);
delay(30);
digitalWrite(13, LOW);
}
}
void loop() {
network.receive(1000);
}