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
#If you save this as code.py and the run it on boot or soft boot, it will only show 0 and hitting control C will end with 0 (no pulses received)importboard,pulseio,digitalio,timesense=digitalio.DigitalInOut(board.D14)
sense.direction=digitalio.Direction.INPUTinput("PRESS RETURN TO START\n")
sense.direction=digitalio.Direction.OUTPUTp=pulseio.PulseIn(board.D13,1024,0)
print('0',len(p))
time.sleep(1)
print('1',len(p))
p=pulseio.PulseIn(board.D13,1024,1)
time.sleep(1)
print('2',len(p))
try:
whileTrue:
whilep:
print(p.popleft())
p=pulseio.PulseIn(board.D13,1024,0)
time.sleep(0.01)
exceptKeyboardInterrupt:
sense.direction=digitalio.Direction.INPUTprint(len(p))
p.deinit()
sense.deinit()
print("program ended.")
passexceptExceptionase:
sense.direction=digitalio.Direction.INPUTp.deinit()
sense.deinit()
print("program ended because of ",e)
# but if you run this in the REPL, it gets pulses (a hundred in my case, even if the source is continuously sending pulses for test)>>>p=pulseio.PulseIn(board.D13,1024,0)
>>>len(p)
100afterthatpdoesnot"grow"Ihavetorunagainp=pulseio.PulseIn(board.D13,1024,0) intheREPLandevenifIwaitalongtime, Iget100-120pulses.
(thesourceiscontinuouslysendingpulseswithvariablelengthsbetween40and520microseconds!)
Behavior
explained above.
Description
No response
Additional information
No response
The text was updated successfully, but these errors were encountered:
CircuitPython version
Code/REPL
Behavior
explained above.
Description
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: