     digitalWrite(dirPin, HIGH);
     Serial.begin(9600);
     findsensor(maxPulse);
-    //Serial.write(sReady);
-    Serial.println("arduino ready");
+    defaults();
+    Serial.write(sReady);
+}
+
+void defaults() {
+    halfTurns = 1;
+    duration = 500;
+    startPitch = 72;
+    endPitch = 36;
+    dir = true;
+    recentre = true;
 }
 
 int pitchToPulse(float pitch) {

#define rRecentre      10
#define rNoRecentre    11
#define rSetDuration   12
#define rDurlength      5
#define rLength        12
/*
 * ranges:
    13-20  tests
    21-39  set halfturns
    40-112 set startpitch
   120-192 set endpitch
 */

char serialIncoming[rLength];
char newDuration[rDurlength];
int halfTurns         = 1;
unsigned int duration = 500;
float startPitch      = 72;
float endPitch        = 36;
boolean dir           = true;
boolean recentre      = true;
boolean newData       = false;

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

        Serial.println(recentre, BIN);
    } else {
        // show test styles
        Serial.println("203: 0xcb: turn");
        Serial.println("204: 0xcc: gliss");
        Serial.println("205: 0xcd: timedturn");
        Serial.println("206: 0xce: durationturn");
        Serial.println("207: 0xcf: durationgliss");
        Serial.println("208: 0xd0: scale");
        Serial.println("209: 0xd1: show settings");
    }
    delay(333);
}

void processdata() {
    for (byte i=0; i<rLength; i++) {
        byte data = serialIncoming[i];
        if (data == rEOM) {
            newData = false;
            return;
        } else if (data == rQuery) {
            findsensor(maxPulse);
            Serial.write(sReady);
            flashled();
        } else if (data == rTurn) {
            turn(halfTurns, startPitch, dir);
        } else if (data == rGliss) {
            gliss(halfTurns, startPitch, endPitch, dir);
        } else if (data == rTimedTurn) {
            timedturn(halfTurns, duration, dir);
        } else if (data == rDurationTurn) {
            durationturn(duration, startPitch, dir, recentre);
        } else if (data == rDurationGliss) {
            durationgliss(duration, startPitch, endPitch, dir, recentre);
        } else if (data == rForwards) {
            dir = true;
        } else if (data == rBackwards) {
            dir = false;
        } else if (data == rRecentre) {
            recentre = true;
        } else if (data == rNoRecentre) {
            recentre = false;
        } else if (data == rSetDuration) {
            for (byte d=0; d<rDurlength; d++) {
                newDuration[d] = serialIncoming[++i];
            }
            duration = atoi(newDuration);
        } else if (data == rReset) {
            defaults();
        } else if (data < 21) {
            true;
        } else if (data < 40) {
            halfTurns = data - 20;
        } else if (data < 113) {
            startPitch = pitchbyteToMidi(data - 40);
        } else if (data < 120) {
            true;
        } else if (data < 193) {
            endPitch = pitchbyteToMidi(data - 120);
        } else if (data < 203) {
            true;
        } else if (data < 210) {
            test(data - 203);
            flashled();
        }
    }
}
