首页 > 解决方案 > 如何在“处理”python模式下写入串口

问题描述

我正在使用“处理”,在 java 模式下,我可以通过以下方式写入串行端口:

import processing.serial.*; 
port = new Serial(this,Serial.list()[0] , 9600); 
port.write('3')

在python处理中:

add_library('serial')
port = Serial(this,Serial.list()[0] , 9600) 
port.write('3')

在 Java 中一切正常,但在 python 中,语句出现错误

'port.write('3'):
"processing.app.SketchException: TypeError: write(): expected 2 args; got 1"

标签: pythonprocessing

解决方案


推荐阅读