Update. /JL

This commit is contained in:
Jan Lerking
2025-04-09 07:01:36 +02:00
parent 91bc7878f2
commit 41010f169e
2 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
from microbit import *
BINÆR_DATA = {
0: "00000:", 1: "00009:", 2: "00090:", 3: "00099:", 4: "00900:", 5: "00909:",
6: "00990:", 7: "00999:", 8: "09000:", 9: "09009:", 10: "09090:", 11: "09099:",
12: "09900:", 13: "09909", 14: "09990:", 15: "09999:", 16: "90000:", 17: "90009:",
18: "90090:", 19: "90099:", 20: "90900:", 21: "90909:", 22: "90990:", 23: "90999:",
24: "99000:", 25: "99009:", 26: "99090:", 27: "99099:", 28: "99900:", 29: "99909:",
30: "99990:", 31: "99999:"
}
while True:
for b in range(32):
display.show(BINÆR_DATA[b],
"00000:"
"00000:"
"00000:"
"00000")
sleep(100) #sov 0.1 sekund

View File

@@ -0,0 +1,15 @@
from microbit import *
def get_binær(n):
bin_format = format(n, '05b') # Vi starter med at sætte vores binær streng til 5 karakterer (n = max 31)
bin_nummer = bin_format[2:] # Vi fjerner "0b" fra strengen
return bin_nummer.replace("1", "9") + ":" # Vi erstatter "1" med "9", og tilføjer ":" og returnerer den nye streng
while True:
for b in range(32):
display.show(get_binær(b),
"00000:"
"00000:"
"00000:"
"00000")
sleep(100) #sov 0.1 sekund