Touch input
Touch sensors¶
The Micro:bit includes 3 pins that can be used as touch sensors.
This test is done by measuring how much resistance there is between the pin and ground. A low resistance gives a reading of True. To get a reliable reading using a finger you may need to touch the ground pin with another part of your body, for example your other hand.
Pin0-Pin2 are touch pins.
from microbit import *
while True:
if pin0.is_touched():
display.show(Image.HAPPY)
else:
display.show(Image.SAD)