   }
 } // end loop()
 
-void readWristInterrupt() {
-  // interrupt occurs on CHANGE - need to determine if now high (start of pulse) or low (end of pulse
-  if(digitalRead(WristInterrupt) == HIGH){
+/********************
+----- FUNCTIONS -----
+********************/
+
+void readWristInterruptPin() {
+  // interrupt occurs on CHANGE - need to determine if now high 
+  // (start of pulse) or low (end of pulse
+  if(digitalRead(WristInterruptPin) == HIGH){
     wristTimer = micros();  // get time stamp for initiation of pulse
   }
   else{   
     // pin must now be low - end of pulse; calculate pulse width
     wristPW = micros() - wristTimer;
-    flag = true;
+    wristFlag = true;
   }
-} // end readWristInterrupt()
+} // end readWristInterruptPin()
 
-void readClawInterrupt() {
-  // interrupt occurs on CHANGE - need to determine if now high (start of pulse) or low (end of pulse
-  if(digitalRead(ClawInterrupt) == HIGH){
-    clawTimer = micros();  // get time stamp for initiation of pulse
+void readClawInterruptPin()        // works just like wrist interrupt
+  if(digitalRead(ClawInterruptPin) == HIGH){
+    clawTimer = micros(); 
   }
-  else{   
-    // pin must now be low - end of pulse; calculate pulse width
+  else{
     clawPW = micros() - clawTimer;
-    flag = true;
+    clawFlag = true;
   }
-} // end readClawInterrupt()
+} // end readClawInterruptPin()

/*
dfrdb
DFRobot Romeo Drive Bot
Robot for MakerFaire Kansas City Arch Reactor booth

Read RC signal pulse width by using interrupt then control servos of
SparkFun robot arm (https://www.sparkfun.com/products/11524 and  https://www.sparkfun.com/products/11674 )


DFRobot Romeo v2 controller board 
http://www.dfrobot.com/wiki/index.php/Romeo_V2-All_in_one_Controller_(R3)_(SKU:DFR0225)

Board has pin config like Leonardo - plan to take advantage of fact that Leonardo has 4 hardware
interrupts for my 4 controller signals; see http://www.arduino.cc/en/Reference/AttachInterrupt 

                   
Helpful resources:

http://rcarduino.blogspot.com/2012/01/how-to-read-rc-receiver-with.html
https://beyondszine.wordpress.com/2013/10/31/part-ii-all-pin-interrupt-method-for-rc-in-arduino/

Using HobbyKing Turnigy 5X 5 channel mini transmitter and receiver
https://www.hobbyking.com/hobbyking/store/uh_viewItem.asp?idProduct=43854
Right joystick for steering/speed, Left for claw (fwd/back for arm position, 
side to side to open/close claw)

Will assume full range of signal (1000 - 2000), simplifies programming
Extreme values outside range only occur with extremes of trim, which 
should be a rare outlier - will avoid the overhead of a constrain() operation


******************************************************************************/

/********************
*** DECLARATIONS ****
********************/
#include <Servo.h>

Servo wrist;
Servo claw;

const int WristInterruptPin = 3; // interrupt 0 is on pin 3 for wrist
const int WristInterrupt = 0;
const int ClawInterruptPin = 2;
const int ClawInterrupt = 1;
const int WristPin = 12;
const int ClawPin = 13;

volatile unsigned long wristPW = 0;   // volatile since will be in interrupt 
                                      // function
volatile unsigned long clawPW = 0;
volatile unsigned long wristTimer = 0;
volatile unsigned long clawTimer = 0;
volatile boolean wristFlag = false;
volatile boolean clawFlag = false;
unsigned long wristPulse = 0;
unsigned long clawPulse = 0;

int clawAngle = 85;
int ClawRDZ = 1450; // threshold for closing claw - right limit of dead zone
int ClawLDZ = 1550; // threshold for opening claw
const int minClawAngle = 5;      // limit travel to protect servo
const int maxClawAngle = 135;

/********************
====== BODY =========
********************/

void setup() {
  attachInterrupt(WristInterrupt, readWristInterruptPin, CHANGE); 
  attachInterrupt(ClawInterrupt, readClawInterruptPin, CHANGE); 
  wrist.attach(WristPin);
  claw.attach(ClawPin);
  wrist.write(90); // starting position
