Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Verwandelt den micro:bit in einen "Klicker", um Tasten-Klicks zu zählen
- # Copyright 2023, 2024 Roland Richter [Mu: BBC micro:bit]
- import microbit
- count = 0
- while True:
- microbit.display.show("?")
- # Warte, bis Taste A gedrückt wird ...
- while not microbit.button_a.is_pressed():
- pass
- # "+=" bedeutet "addiere die rechte Seite zur Variablen auf der linken Seite"
- count += 1
- # "%" ist der modulo-Operator und berechnet den Rest einer Division.
- # micro:bits können nur eine Ziffer anzeigen; zeige daher hier die Einer-Stelle an.
- microbit.display.show(str(count % 10))
- # Warte, bis Taste A nicht mehr gedrückt ist ...
- while microbit.button_a.is_pressed():
- pass
- # PROBIERE den Zähler anzuzeigen, wenn die Taste B gedrückt wird.
- # ----------------------------------------------------------------------
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation, either version 3 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <https://www.gnu.org/licenses/>.
Advertisement
Add Comment
Please, Sign In to add comment