 
 static void Reset_Target() {
     digitalWrite(RESET, 1);
-    digitalWrite(SCK, 0); // has to be set LOW at startup, or PE fails
+    digitalWrite(PIN_SCK, 0); // has to be set LOW at startup, or PE fails
     delay(30);
     digitalWrite(RESET, 0);
     delay(30); // minimum delay here is 20ms for the ATmega8

        }
    }

    pinMode(SCK, INPUT);
    pinMode(MOSI, INPUT);
    pinMode(RESET, INPUT);
    
    digitalWrite(SCK, 0);
    digitalWrite(MOSI, 0);
    digitalWrite(RESET, 0);
    
    delay(10); // let the serial port finish

static byte XferByte(byte v) {
    byte result = 0;
    for (byte i = 0; i < 8; ++i) {
        digitalWrite(PIN_MOSI, v & 0x80);
        digitalWrite(PIN_SCK, 0); // slow pulse, max 60KHz
        digitalWrite(PIN_SCK, 1);
        v <<= 1;
        result = (result << 1) | digitalRead(PIN_MISO);
    }
    return result;
}
