Python interface for the Firmata (http://firmata.org/) protocol. It is compliant with Firmata 2.1. Any help with updating to 2.2 is welcome. The Capability Query is implemented, but the Pin State Query feature not yet.
Hi,
I want to read PWM Signal, My hardware is Arduino Mega and I use PyFirmata Library because my code run in python.
When I use pin8.ping() i except error.
The ping() Method really work?
I would happy to any help thanks.
My code:
from pyfirmata import ArduinoMega, util
import threading
import time
def trans_pwm(pin):
while True:
x = int(input("Please enter angle for Servo: "))
angle = int(100 / 90 * x + 45)
pin.write(angle)
board = ArduinoMega('COM8')
it = util.Iterator(board)
it.start()
# set up pin D2 as Servo Output
pin2 = board.get_pin('d:2:s')
# set up pin D8 as PWM Input
pin8 = board.get_pin('d:8:o')
pin8.ping()
# Use Threading to Transmit and receive in the same time
t1 = threading.Thread(target=trans_pwm, args=(pin2,))
t2 = threading.Thread(target=receiv_pwm, args=(pin8,))
t1.start()
t2.start()
t1.join()
t2.join()
Hi, I want to read PWM Signal, My hardware is Arduino Mega and I use PyFirmata Library because my code run in python. When I use pin8.ping() i except error. The ping() Method really work? I would happy to any help thanks.
My code: from pyfirmata import ArduinoMega, util import threading import time
def trans_pwm(pin): while True: x = int(input("Please enter angle for Servo: ")) angle = int(100 / 90 * x + 45) pin.write(angle)
def receiv_pwm(pin): while True: print("Pulse Time= ", pin.ping(), " [Sec]") time.sleep(0.0002)
try:
Initialize Hardware Configuration
except: print("error")
finally: board.exit()