Skip to content

Commit

Permalink
Add pin touches sample
Browse files Browse the repository at this point in the history
  • Loading branch information
microbit-grace committed Mar 21, 2024
1 parent 202c7fd commit 41ff6b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ <h1>MicroPython-micro:bit simulator example embedding</h1>
<option value="microphone">Microphone</option>
<option value="music">Music</option>
<option value="pin_logo">Pin logo</option>
<option value="pin_touches">Pin touches</option>
<option value="radio">Radio</option>
<option value="random">Random</option>
<option value="sensors">Sensors</option>
Expand Down
12 changes: 12 additions & 0 deletions src/examples/pin_touches.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from microbit import *

def report_pin_touches(pin, p_num):
if pin.was_touched():
print('pin', p_num, 'was touched', pin.get_touches(), 'time(s)')

while True:
if pin_logo.is_touched():
report_pin_touches(pin0, "0")
report_pin_touches(pin1, "1")
report_pin_touches(pin2, "2")
break

0 comments on commit 41ff6b0

Please sign in to comment.