如何从 visual studio 读取 arduino 串行监视器数据并保存为数组

how to read arduino serial monitor data from visual studio and save as an array

我在 arduino 串行监视器上获取以下数据。我想从 visual studio 读取这些数据并保存为数组。请任何人帮助我。这对我会有很大的帮助。请

Arduino 串行监视器

我打算使用 winforms。如果没有,那么这不会有帮助。

首先,从工具箱向您的表单添加一个串行端口。然后做这样的事情将数据放入数组中:

            string tempStr;
            int size = serialPort1.BytesToRead;
            //runs as long as there are bytes in the serial buffer to be read,
            //you may need to change the way it runs to get all of your data depending upon
            //how the device is sending data to the serial port
            while (size != 0)
            {
                //store incoming byte
                int b1 = serialPort1.ReadByte();
                //converts byte to character
                char c = Convert.ToChar(b1);
                //puts the character into a string                
                tempStr = c.ToString();
                //append it to Rx (output string)
                Rx += tempStr;
            }
            //you'll may need to do some messing around with the character you use to split
            string[] results = Rx.Split(new Char[] {'\r' });