   // read byte from LIDAR and relay to USB
   if (Serial1.available() > 0) {
     inByte = Serial1.read();  // get incoming byte:
-    if (relay) {
+    if (xv_config.relay) {
       Serial.print(inByte, BYTE);  // relay
     }
     decodeData(inByte);
   }
 
-  if (motor_enable) {  
+  if (xv_config.motor_enable) {  
     rpmPID.Compute();
     if (pwm_val != pwm_last) {
       Timer3.pwm(xv_config.motor_pwm_pin, pwm_val);

}

void motorOff() {
  motor_enable = false;
  Timer3.pwm(xv_config.motor_pwm_pin, 0);
  Serial.println("Motor off");
}

void motorOn() {
  motor_enable = true;
  Timer3.pwm(xv_config.motor_pwm_pin, xv_config.pwm_min);
  Serial.println("Motor on");
}

void relayOff() {
  relay = false;
  Serial.println("Lidar data disabled");
}

void relayOn() {
  relay = true;
  Serial.println("Lidar data enabled");
}


  Serial.println(xv_config.Ki);
  Serial.print("PID Kd: ");
  Serial.println(xv_config.Kd);

  Serial.print("Motor Enable: ");
  Serial.println(xv_config.motor_enable);
  Serial.print("Realy: ");
  Serial.println(xv_config.relay);
}

void saveConfig() {
