I am using a PC (Windows10) to send data to Arduino over USB (serial port) and it runs correctly. So I wrote a powershell script like below:
$serial = new-Object System.IO.Ports.SerialPort COM8,9600,None,8,one
$serial.open()
$serial.WriteLine("1")
$serial.close()
The problem is when I restart my PC because after restarting a few times the Arduino gets a new serial port and my script is set to COM8, then it does not work!
So using powershell, how can I know which serial port the Arduino is connected after restarting the PC?
How to change this powershell script to automatically identify the serial port that the Arduino is connected? Thanks