2019年11月17日

python arduino 記事

https://pypi.org/project/pyFirmata/
韌體要燒入範例檔standfirmata

install pyfirmata

git clone https://github.com/tino/pyFirmata
cd pyFirmata
sudo python3 setup.py install
 
sudo pip3 install pyfirmata


python3
//載入
from pyfirmata import Arduino, util

board = Arduino('/dev/ttyUSB0')
//讀取類比信號A0
it = util.Iterator(board)
it.start()
board.analog[0].enable_reporting()
board.analog[0].read()
 
//寫入數位信號D13
board.digital[13].write(1)
 
 

沒有留言: