通过编程访问USB电缆引脚

时间:2021-10-18 14:55:35

I have a usb cable and I would like to connect it to my computer, then connect it to my circuit and then a program that I made will run and somehow control the circuit. I have done some research about USB pinouts but I don't know how can I make a program that is installed in my computer and control my circuit that is connected to my computer using a USB cable.

我有一个usb电缆,我想将它连接到我的电脑,然后将它连接到我的电路,然后我制作的程序将运行,并以某种方式控制电路。我已经对USB引脚排列做了一些研究,但我不知道如何制作一个安装在我的电脑上的程序,并使用USB线控制我的电路连接到我的电脑。

NOTE: I know basic programming and basic electronics :)

注意:我知道基本编程和基本电子学:)

EDIT IN THE QUESTION: The program on my computer will send bytes through the circuit using a USB cable. Then my circuit will interpret this bytes and do something.

编辑问题:我的计算机上的程序将使用USB电缆通过电路发送字节。然后我的电路将解释这些字节并做一些事情。

1 个解决方案

#1


You cannot just connect a USB cable to your circuit like it's a GPIO pin. You must have some sort of USB device at the end of the cable. Anything else and you risk frying your computer.

您不能将USB电缆连接到电路,就像它是GPIO引脚一样。您必须在电缆末端安装某种USB设备。还有别的东西,你冒着煎炸电脑的风险。

If you have an Arduino, for example, you connect the cable to the arduino USB port, and the Arduino appears on your computer as a COM port (Windows) or a serial port (Linux etc). You set the serial port speed and options, and then you can communicate with the Arduino.

例如,如果您有Arduino,则将电缆连接到arduino USB端口,Arduino在计算机上显示为COM端口(Windows)或串行端口(Linux等)。您可以设置串口速度和选项,然后就可以与Arduino进行通信。

http://www.arduino.cc/en/Reference/Serial

#1


You cannot just connect a USB cable to your circuit like it's a GPIO pin. You must have some sort of USB device at the end of the cable. Anything else and you risk frying your computer.

您不能将USB电缆连接到电路,就像它是GPIO引脚一样。您必须在电缆末端安装某种USB设备。还有别的东西,你冒着煎炸电脑的风险。

If you have an Arduino, for example, you connect the cable to the arduino USB port, and the Arduino appears on your computer as a COM port (Windows) or a serial port (Linux etc). You set the serial port speed and options, and then you can communicate with the Arduino.

例如,如果您有Arduino,则将电缆连接到arduino USB端口,Arduino在计算机上显示为COM端口(Windows)或串行端口(Linux等)。您可以设置串口速度和选项,然后就可以与Arduino进行通信。

http://www.arduino.cc/en/Reference/Serial