   lcd.print("                ");
 
 }
+
+// Sensors
+
+void motorSwitchLeftActivated() {
+  state = MOTOR_SWITCH_DETECTED;
+  motorSwitchDetected = MOTOR_SWITCH_LEFT;
+}
+
+void motorSwitchRightActivted() {
+  state = MOTOR_SWITCH_DETECTED;
+  motorSwitchDetected = MOTOR_SWITCH_RIGHT;
+}
+
+void motorSwitchActivated() {
+  state = PUBLISHING_ENVIRONMENT_EVENT;
+  if (motorSwitchDetected == MOTOR_SWITCH_LEFT) {
+    lcdStatus("Switch Left");
+    publishDebug("Left Motor Switch Detected");
+  } else {
+    lcdStatus("Switch Right");
+    publishDebug("Right Motor Switch Detected");
+  }
+  delay(1000);
+  digitalWrite(BUILTIN_LED, LOW);
+  state = IDLE;
+}

  os_timer_setfn(&trayTiltTimer, trayTiltTimerFinished, NULL);
  os_timer_arm(&trayTiltTimer,15000, true);
}
// Initialisation

void setup() {
  // Configure serial port

  Serial.begin(115200);
  Serial.println();

  init_lcd();
  lcd.print("Init v3");

  init_wifi();
  // Start the DHT22
  publishDebug("WiFi On");
  publishDebug("Initialising Sensors");
  dht.begin();
  Serial.println("sensor is starting..");
  Serial.print("Reading Analog...");
  Serial.println(analogRead(0));
  publishDebug("Initialising Timers");
  initTimers();
//----------------- wifi_set_sleep_type(LIGHT_SLEEP_T);

// void publishPayload();
// void displayLCD();
// void debugDisplayPayload();
void callback(char* topic, byte* payload, unsigned int length);

// Configure 2 line LCD display with I2C interface

