Code works in simulator but not on actual Micro:bit

I have a bit of code that increments a variable each time pin 0 is touched. After incrementing, it scrolls the new value of the variable across the LEDs. Funny thing is, it works great on the simulator, but doesn’t work at all on the Micro:bit controller.


from microbit import *
touches = 0

while True:
if pin0.is_touched():
touches += 1

I think you need to set the “touch mode” to capacitive. See: .

The default “touch mode” for pins is resistive mode. Resistive mode may work ok if you touch the input pin while also touching the ground pin.