The invention provides a method for controlling a sliding door, which comprises the following steps: S1, judging the state of the sliding door by a limit switch; entering step S11 when the door is completely closed; entering step S2 when the sliding door is completely opened or semi-closed; S11, maintaining complete close of the sliding door; S2, judging whether a start-up command exists or not after the initial state of the sliding door is maintained in first preset time, entering step S21 if no start-up command exists, and entering step S22 if the start-up command exists; S21,entering S211 after the sliding door is driven to be completely closed; S211, stopping operation of a driving device, after a complete closed limit switch is closed in second preset time; S22, judging whether the sliding door is completely opened or not, if so, operating an air conditioner, if not, entering step S222; S222, driving the sliding door to be completely opened, then closing a complete opening limit switch in third preset time, and stopping operation of the driving device. Therefore, the opening or closing state of the sliding door can be judged accurately to ensure that the sliding door can be normally opened and closed.