Modifications

Sauter à la navigation Sauter à la recherche
411 octets ajoutés ,  1 février 2025 à 00:09
Ligne 40 : Ligne 40 :     
<syntaxhighlight lang="python" line highlight="3,7">
 
<syntaxhighlight lang="python" line highlight="3,7">
−
xxx
+
from machine import Pin
 +
 
 +
last_counter = 0
 +
counter = 0
 +
 
 +
p_in = Pin( 10, Pin.IN, Pin.PULL_UP )
 +
last_state = p_in.value()
 +
while True:
 +
    # lecture de l'état
 +
    state = p_in.value()
 +
    if state!=last_state:
 +
        # raising edge
 +
        if state != 0:
 +
            counter += 1
 +
        last_state = state
 +
        continue
 +
   
 +
    if counter != last_counter:
 +
        print( counter )
 +
        last_counter = counter
 
</syntaxhighlight>
 
</syntaxhighlight>
  
32 920

modifications

Menu de navigation