File tree Expand file tree Collapse file tree
micropython/drivers/imu/lsm6dsox Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2525lsm .pedometer_config (debounce = 5 , int1_enable = True , int2_enable = True )
2626
2727# Register interrupt handler on a Pin. e.g. D8
28- # The interrupt pins are open-drain, so they will be pulled low when a step is detected.
29- # We configure the host pin with a pull-up resistor to ensure it stays high when not active.
30- interrupt_pin = Pin ("D8" , Pin .IN , Pin .PULL_UP )
28+ # The interrupt pins are push-pull outputs by default that go low when a step is detected.
29+ # You can connect either INT1 or INT2 to the interrupt pin.
30+ interrupt_pin = Pin ("D8" , Pin .IN ) # Change this to your desired interrupt pin.
31+ interrupt_fired = False # Flag to indicate if the interrupt has been fired.
3132
3233
3334def on_step_detected (pin ):
34- print ("Steps detected!" )
35+ global interrupt_fired
36+ interrupt_fired = True
3537
3638
3739# Configure the interrupt pin to trigger on falling edge (active low) when a step is detected.
@@ -40,6 +42,10 @@ def on_step_detected(pin):
4042last_steps = None # Keep track of the last step count to detect changes.
4143
4244while True :
45+ if interrupt_fired :
46+ print ("Step detected!" )
47+ interrupt_fired = False # Reset the flag after handling the interrupt.
48+
4349 steps = lsm .steps ()
4450
4551 if steps != last_steps :
You can’t perform that action at this time.
0 commit comments