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.

Touches

from microbit import *
touches = 0

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

I think you need to set the “touch mode” to capacitive. See: https://support.microbit.org/support/solutions/articles/19000116318-touch-sensing-on-the-micro-bit .

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.

Bill