A button press enables a delightful experience (sound on)


By using serial communication between the Arduino and Unity, I created a mini scene that triggers different parameters once the button is hit.


By receiving the serial communication from the arduino – In the form of a number, I created this logic statement to detect when the button is pressed:

void OnMessageArrived(string msg) 
        float speed = float.Parse(msg) * 100;
        if (float.Parse(msg) == 0) {
            // PLAY AUDIO
            // enable camera animator
            cam.enabled = true;
            // this delays the lighting until the camera animation fineshes

There was also another challenge because I didn't want to have the lighting be enabled until a specific part of a song. In order to solve for that, I used the StartCoroutine() function in order to be able to use the WaitForSeconds() function.

The function is here:

IEnumerator changeLighting() {
      yield return new WaitForSeconds(11.500F);
      lighting.color = Color.white;

Overall this process was very informative because I learned more about the different classes that I can manipulate via a script. I also gained a deeper understanding in how to get components and manipulate them as well.

Some of the principles that I learned from this project can be applied to future projects because I can now time certain triggers according to a delay and manipulate certain components whenever I want to.

Reflecting back to this process, could I have done the same thing without the Arduino and simply use the Unity Play Button? Probably. But why should I?