Ok, I got it. I used some code from Principia Labs "MultiJoy" sketch to keep the wireless data organized. He uses the term "error protection". Anyway, if anyone cares here is the code I used:
Handheld:
// Original code borrowed from "Blink without delay"
// and "Multijoy" by Principia Labs
const int buttonPin = 2; // the number of the pushbutton pin
const int LEDPin = 12; // the number of the LED pin
int LEDButton = 9; // LED on Pin 9 assigned to button
int LEDSync = 11; // LED on Pin 11 assigned to button
int buttonState = 0; // variable for reading the pushbutton status
int pinState = LOW; // set initial state of pin
int t = 0; // switching variable
// Import the Arduino Servo library
#include <Servo.h>
// User input for servo and position
int userInput[3]; // raw input from serial buffer, 3 bytes
int startbyte; // start byte, begin reading input
int servo; // which servo to pulse?
int pos; // servo angle 0-180
int i; // iterator
void setup(){
// Initialize outputs
pinMode(LEDButton, OUTPUT); // set pin named "LEDButton" as output
pinMode(LEDSync, OUTPUT);
pinMode(LEDPin, OUTPUT);
pinMode(buttonPin, INPUT); // set pin named "buttonPin" as input
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
if (t == 0) {
Serial.print(char(255)); // error protection
Serial.print(char(99)); // send command for "case 99"
Serial.print(char(180)); // send state command
digitalWrite(LEDPin, HIGH);
t = 1;
}
}
else {
if (t == 1) {
Serial.print(char(255)); // error protection
Serial.print(char(99)); // send command for "case 99"
Serial.print(char(0)); // send state command
digitalWrite(LEDPin, LOW);
t = 0;
}
}
}
Serial.begin(9600); //set baud rate on Arduino to 9600
}
void loop(){
// Wait for serial input (min 3 bytes in buffer)
if (Serial.available() > 2) {
// Read the first byte
startbyte = Serial.read();
// If it's really the startbyte (255) ...
if (startbyte == 255) {
// ... then get the next two bytes
for (i=0;i<2;i++) {
userInput[i] = Serial.read();
}
// First byte = servo to move?
servo = userInput[0];
// Second byte = which position?
pos = userInput[1];
// Packet error checking and recovery
if (pos == 255) { servo = 255; }
// Assign new position to appropriate servo
switch (servo) {
// Upon receiving signal from the other units
// determine the case number and the condition
// and set the corresponding pinstate.
case 98:
if (pos == 180) {
if (pinState == LOW)
pinState = HIGH;
}
else pinState = LOW;
if (pos == 0) {
pinState = LOW;
}
digitalWrite(LEDButton, pinState);
break;
case 97:
if (pos == 180) {
if (pinState == LOW)
pinState = HIGH;
}
else pinState = LOW;
if (pos == 0) {
pinState = LOW;
}
digitalWrite(LEDSync, pinState);
break;
}
}
}
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
if (t == 0) { // switching variable allows only one loop per state change
Serial.print(char(255)); // error control
Serial.print(char(99)); // send command for "case 99"
Serial.print(char(180)); // send state command
digitalWrite(LEDPin, HIGH); // turn the LED on
t = 1; // if buttonState HIGH and t = 0, do the above and change "t" to 1
}
}
else {
if (t == 1) {
Serial.print(char(255)); // error protection
Serial.print(char(99)); // send command for "case 99"
Serial.print(char(0)); // send state command
digitalWrite(LEDPin, LOW); // turn the LED off
t = 0;
}
}
}
The handheld transmits a signal to Logger 1 and also receives a signal from Logger 1 as confirmation that you are still in range.