参考文章:html
https://blog.csdn.net/dgut_guangdian/article/details/78391270python
https://www.cnblogs.com/lanceyu/p/10201236.htmlbootstrap
https://blog.csdn.net/absinjun/article/details/81407790windows
首先安装pipless
你能够经过如下命令来判断是否已安装:curl
pip --version
若是你还未安装,则可使用如下方法来安装:ui
$ curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # 下载安装脚本 $ sudo python get-pip.py # 运行安装脚本
显示版本和路径url
pip --version
安装serial、easygui模块,spa
windows下须要安装pyserial,安装步骤见:.net
https://learn.adafruit.com/arduino-lesson-17-email-sending-movement-detector/installing-python-and-pyserial
帮助文档见:
https://pyserial.readthedocs.io/en/latest/shortintro.html
代码:
import serial import time ser = serial.Serial() ser.baudrate = 9600 ser.port = 'COM3' print(ser) ser.open() print(ser.is_open) i=1 while(1): demo=b"1" ser.write(demo) s = ser.read(1) print(s) time.sleep(0.1) demo = b"2" ser.write(demo) s = ser.read(1) print(s) time.sleep(0.1)
继续。。