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

        }
    }

    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

#include <avr/sleep.h>

// pin definitions
#define PIN_SCK     14  // PC0 - AIO1 - serial clock to target avr
#define PIN_MISO    4   // PD4 - DIO1 - input from target avr
#define PIN_MOSI    17  // PC3 - AIO4 - output to target avr
#define RESET       7   // PD7 - DIO4 - reset pin of the target avr
#define DONE_LED    9   // B1 - blue LED on JN USB, blinks on start and when ok

