Example #1
0
    void Update()
    {
        var = arduinoConnector.ReadByteFromArduino(1); //read from Arduino

        if (var == 1)                                  //If 1 is being sent from Arduino - button is being pressed!
        {
            Debug.Log("Button Pressed!");
            rend.material.SetColor("_Color", Color.red); //turn the cube RED
            timeLeft = .50f;                             //start the timer
        }

        timeLeft -= Time.deltaTime;                       //counting down
        if (timeLeft < 0)                                 //if time has run out
        {
            rend.material.SetColor("_Color", Color.blue); //change the cube back to BLUE
        }
    }