❔ Serial Communication

Hi. Nothing is being printed to the console and I have no idea why.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO.Ports;

public class ArduinoController : MonoBehaviour
{
    SerialPort serial;

    void Start() //called once when the program is run
    {
        serial = new SerialPort("COM3", 9600);
        serial.Open();
    }

    void Update() //called once every frame
    {
        string data = serial.ReadLine();
        Debug.Log(data);
    }
}
Was this page helpful?