You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
# 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()
except:
print("error")
finally:
board.exit()
The text was updated successfully, but these errors were encountered:
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
board = ArduinoMega('COM8')
it = util.Iterator(board)
it.start()
except:
print("error")
finally:
board.exit()
The text was updated successfully, but these errors were encountered: