/* A controller (host computer) sends 3-byte packets to the transmitter, which then repeats them to a receiver. When the transmitter is not receiving any data from the host it transmits the null packet, which may be used by the receiver for syncing to the transmitter. The host may transmit at any baud rate, but if it exceeds the baud rate of the transmitter for anything but short bursts, the serial buffer of the transmitter will get full and start dropping packets. */ #define packetSize 3 #define baudRate 19200 int nullPacket[packetSize] = {191, 186, 154}; int inputPacket[packetSize]; int inputPosition = 0; void setup() { Serial.begin(baudRate); } void loop() { while(Serial.available() > 0) { inputPacket[inputPosition++] = Serial.read(); if(inputPosition == packetSize) { printPacket(inputPacket); inputPosition = 0; } } printPacket(nullPacket); } void printPacket(int packet[]) { for(int i = 0; i < packetSize; i++) Serial.print(nullPacket[i], BYTE); }