• 已解决 73482 个问题
  • 已帮助 5993 位优秀工程师

arduino怎么设置虚拟串口

3054308fe38f48cd 2019-03-08 浏览量:2219
用c语言编写arduino虚拟串口的驱动程序
0 0 收起

我来回答

上传资料:
选择文件 文件大小不超过15M(格式支持:doc、ppt、xls、pdf、zip、rar、txt)
所有亮答 数量:6
  • 网上有专门的虚拟串口软件,不需要自己写的

  • 虚拟串口一般是针对上位机说的,一般没人用c开发,再说大多数情况,用现成的虚拟串口软件就行。

  • 举个例子,定义一个软串口在10和11引脚

    其中10是rx,11是tx

    波特率9600

    // include the SoftwareSerial library so you can use its functions:
    #include <SoftwareSerial.h>
    
    #define rxPin 10
    #define txPin 11
    
    // set up a new serial port
    SoftwareSerial mySerial =  SoftwareSerial(rxPin txPin);
    
    void setup()  {
      // define pin modes for tx rx:
      pinMode(rxPin INPUT);
      pinMode(txPin OUTPUT);
      // set the data rate for the SoftwareSerial port
      mySerial.begin(9600);
    }
    
    void loop() {
      // ...
    }


  • 选择管脚,再使用
    SoftwareSerial函数来初始化管脚
    并确定对应管脚的输入、输出模式即可。

  • Arduino自带一个USB-CDC接口,这个是自带的驱动,要看这个驱动实现需要找到Arduino的底层源码

  • Arduino只有硬件USB可以实现CDC通信,还不如外接一个USB串口模块来得方便。

相关问题

问题达人换一批

arduino怎么设置虚拟串口