Questions tagged «firmata»

1
使用python和firmata从Arduino端口动态更新Tkinter Widget比例
我在尝试获取Arduino数字端口值并将这些值设置为Python Tkinter Widget Scale时遇到麻烦。 我正在将Python和Arduino与Firmata一起使用。我可以使用python代码访问arduino板。例如在标签小部件中,我可以像以下代码一样实时获取并设置Arduino模拟端口值到标签,而没有任何问题: import Tkinter import pyfirmata def onStartButtonPress(): while True: if flag.get(): analogReadLabel.config(text=str(a0.read())) analogReadLabel.update_idletasks() top.update() else: break board.exit() top.destroy() def onExitButtonPress(): flag.set(False) port = 'COM7' board = pyfirmata.Arduino(port) it = pyfirmata.util.Iterator(board) it.start() a0 = board.get_pin('a:0:i') top = Tkinter.Tk() top.title("Reading Analog pins") descriptionLabel = Tkinter.Label(top, text="Potentiometer input:- ") …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.