// Executed each frame
    void Update()
    {
        //---------------------------------------------------------------------
        // Send data
        //---------------------------------------------------------------------

        // If you press one of these keys send it to the serial device. A
        // sample serial device that accepts this input is given in the README.
        if (Input.GetKeyDown(KeyCode.A))
        {
            Debug.Log("Sending A");
            serialController.SendSerialMessage("A");
        }

        if (Input.GetKeyDown(KeyCode.Z))
        {
            Debug.Log("Sending Z");
            serialController.SendSerialMessage("Z");
        }

        // Sends the string "doot doot" through the COM port. The Arduino should send
        // ("Doot Success") to its USB Serial Port
        if (Input.GetKeyDown(KeyCode.B))
        {
            Debug.Log("Doot Doot");
            serialController.SendSerialMessage("DootDoot");
        }
        // If the bluetooth module disconnects (flashing light) then "E" can be pressed
        // to attempt to reconnect to it
        if (Input.GetKeyDown(KeyCode.E))
        {
            Debug.Log("Reconnecting");
            serialController.Reconnect();
        }

        //---------------------------------------------------------------------
        // Receive data
        //---------------------------------------------------------------------

        string message = serialController.ReadSerialMessage();

        if (message == null)
        {
            return;
        }

        // Check if the message is plain data or a connect/disconnect event.
        if (ReferenceEquals(message, SerialController.SERIAL_DEVICE_CONNECTED))
        {
            Debug.Log("Connection established");
        }
        else if (ReferenceEquals(message, SerialController.SERIAL_DEVICE_DISCONNECTED))
        {
            Debug.Log("Connection attempt failed or disconnection detected");
        }
        else
        {
            Debug.Log("Message arrived: " + message);
        }
    }