 /*
-  DigitalReadSerial
- Reads a digital input on pin 2, prints the result to the serial monitor 
- 
- This example code is in the public domain.
+Reads digital inputs 2-9, debounces them using a shift register.  Outputs
+char codes '0' - '7' on the serial line when the buttons are pushed.
+
+Expects SPST pushbuttons connected between digital pins 2-9 and ground.
+Uses the internal pull ups.
  */
 
 unsigned int debounce[8] = {1,1,1,1, 1,1,1,1};

  int i;
  int val;
  
  for (i = 0; i < 8; i++) {
    val = digitalRead(i+2);
    debounce[i] = (debounce[i] << 1) | val;
    if (debounce[i] == 0) {  // normally high.
      if (repeat[i] == 0){
        Serial.write(output_vals[i]);
        repeat[i] = 40;
      }
      else
      {

  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
  
  // Enable internal pull-ups on the inputs.
  pinMode(2, INPUT_PULLUP);
  pinMode(3, INPUT_PULLUP);
  pinMode(4, INPUT_PULLUP);
