tino / pyFirmata

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.
MIT License
575 stars 193 forks source link

Why does the pyfirmata closes after a certain amount of time running? #113

Open leo-smi opened 2 years ago

leo-smi commented 2 years ago

I don't know the right time, but the loop just closes and no error.

I'm using arduino uno R3 (chinese clone CH340).

I think there's a problem with the threading or something like that...

The code:

from pyfirmata import Arduino, util
import time

Uno = Arduino('COM3')
pin3 = Uno.get_pin('d:3:p')

dt = 0.005
N = 255

while True:

    for i in range(1, N+1, 1):
        # print(i/100)
        pin3.write(i/N)
        time.sleep(dt)

    for i in range(N, 0, -1):
        # print(i/100)
        pin3.write(i/N)
        time.sleep(dt)