Log in Page Discussion History Go to the site toolbox

RPI Haptics:Vibrobyte Transmitter

From BluWiki

The Vibrobyte transmitter runs on an Arduino wearing the Radios, Inc. MTX-103 shield. A further description is contained in the code itself.

Source

/*
 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);
}

Site Toolbox:

Personal tools
TOOLBOX
LANGUAGES
GNU Free Documentation License 1.2
This page was last modified on 8 July 2008, at 21:44.
Disclaimers - About BluWiki