• Micropython Counter

    LoPy lopy4 data counting sd card
    2
    0 Votes
    2 Posts
    579 Views
    S
    Python code without proper indentation is not very useful. You should try to put it inside a code block like this: import time import machine from machine import Pin tip_num = 0 tip = (Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP)) tip([1]) while tip !="": tip_num += 1 tip_value = (tip) total += tip_value tip = (Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP)) print("Counter", tip_num) print("Done") Apart from that there are a lot of mistakes (e.g. tip([1])) and redundancies (e.g. wrapping everything in parenthesis) in your code. You should probably read the the MicroPython and Pin documentation first.
  • Counting raising edges per second

    WiPy 2&3 pwm interrupt counting
    2
    0 Votes
    2 Posts
    1k Views
    robert-hhR
    @cts WiPy supports a Pin interrupt, which can be triggered with the rising edge. Look in the documentation for "Pin". And is has a timer module, which could be used for setting the gate time. Look in the documentation at "Timer". However, the precision and speed is very limited. Without testing, I would assume that it works reliably only for frequencies below 1 kHz, with a uncertainty of the gate time of about 1 ms. I