Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Dieser micro:bit wird Teil einer "Nachrichten-Kette": Nachrichten werden
- # auf einem Kanal empfangen, angezeigt und im nächsten Kanal weiter gesendet.
- # Diese Version verwendet einen scroll:bit; dazu muss scrollbit.py am micro:bit
- # installiert sein, siehe https://github.com/pimoroni/micropython-scrollbit
- # Copyright 2023, 2024 Roland Richter [Mu: BBC micro:bit]
- import microbit
- import scrollbit
- import radio
- def set_my_channel():
- global my_channel
- microbit.display.show(str(my_channel))
- radio.config(channel=my_channel)
- my_channel = 0
- radio.on()
- set_my_channel()
- while True:
- if microbit.button_a.is_pressed():
- my_channel = 0
- set_my_channel()
- while microbit.button_a.is_pressed():
- pass
- elif microbit.button_b.is_pressed():
- my_channel += 1
- set_my_channel()
- while microbit.button_b.is_pressed():
- pass
- incoming = radio.receive()
- if incoming is not None:
- scrollbit.scroll(str(incoming))
- neighbour = my_channel + 1
- radio.config(channel=neighbour)
- radio.config(power=3)
- radio.send(str(incoming))
- radio.config(channel=my_channel)
- # ----------------------------------------------------------------------
- # 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
Advertisement