microbit 无线模块 python测试代码-01

# Add your Python code here. E.g.
from microbit import *
import radio

#.代表1
#-代表0

radio.on()
radio.config(power=7,group=127,channel=29)
hello=0

def radion(dis):
    if dis == '1':
        display.show(Image("00900:""09090:""09990:""90009:""90009:"))
    elif dis == "2":
        display.show(Image("99990:""90009:""99990:""90009:""99990:"))
    elif dis == '3':
        display.show(Image("09990:""90009:""90000:""90009:""09990:"))
    elif dis == "4":
        display.show(Image("99990:""90009:""90009:""90009:""99990:"))
    elif dis == '5':
        display.show(Image("99999:""90000:""99999:""90000:""99999:"))
    elif dis == '6':
        display.show(Image("99999:""90000:""99999:""90000:""90000:"))
    elif dis == "7":
        display.show(Image("99999:""90000:""90999:""90009:""99999:"))
    elif dis == "8":
        display.show(Image("90009:""90009:""99999:""90009:""90009:"))
    elif dis == "9":
        display.show(Image("09990:""00900:""00900:""00900:""09990:"))
    elif dis == "10":
        display.show(Image("99999:""00900:""00900:""90900:""99900:"))
    elif dis == "11":
        display.show(Image("90009:""90090:""99900:""90090:""90009:"))
    elif dis == "12":
        display.show(Image("90000:""90000:""90000:""90000:""99999:"))
    elif dis == "13":
        display.show(Image("90009:""99099:""90909:""90009:""90009:"))
    elif dis == "14":
        display.show(Image("90009:""99009:""90909:""90099:""90009:"))
    elif dis == "15":
        display.show(Image("09990:""90009:""90009:""90009:""09990:"))
    elif dis == "16":
        display.show(Image("99990:""90009:""99990:""90000:""90000:"))
    elif dis == "17":
        display.show(Image("99990:""90090:""90990:""99990:""00009:"))
    elif dis == "18":
        display.show(Image("99990:""90009:""99990:""90090:""90009:"))
    elif dis == "19":
        display.show(Image("99999:""90000:""99999:""00009:""99999:"))
    elif dis == "20":
        display.show(Image("99999:""00900:""00900:""00900:""00900:"))
    elif dis == "21":
        display.show(Image("90009:""90009:""90009:""90009:""09990:"))
    elif dis == "22":
        display.show(Image("90009:""90009:""09090:""09090:""00900:"))
    elif dis == "23":
        display.show(Image("90909:""90909:""90909:""09090:""09090:"))
    elif dis == "24":
        display.show(Image("90009:""09090:""00900:""09090:""90009:"))
    elif dis == "25":
        display.show(Image("90009:""09090:""00900:""00900:""00900:"))
    elif dis == "26":
        display.show(Image("99999:""00090:""00900:""09000:""99999:"))
    elif dis == "27":
        display.show(Image("00900:""09900:""00900:""00900:""09990:"))
    elif dis == "28":
        display.show(Image("00990:""09009:""00090:""00900:""09999:"))
    elif dis == "29":
        display.show(Image("09990:""90009:""00990:""90009:""09990:"))
    elif dis == "30":
        display.show(Image("09090:""09090:""09090:""09999:""00090:"))
    elif dis == "31":
        display.show(Image("99999:""90000:""99990:""00009:""99990:"))
    elif dis == "32":
        display.show(Image("00900:""09000:""99999:""90009:""09990:"))
    elif dis == "33":
        display.show(Image("99999:""00090:""00900:""09000:""90000:"))
    elif dis == "34":
        display.show(Image("09990:""90009:""09990:""90009:""09990:"))
    elif dis == "35":
        display.show(Image("09990:""90009:""99999:""00090:""00900:"))
    elif dis == "36":
        display.show(Image("09990:""90009:""90009:""90009:""09990:"))
    elif dis == "37":
        display.show(Image("00000:""09990:""09090:""09990:""00000:"))
    elif dis == "38":
        display.show(Image("09990:""00090:""00900:""00000:""00900:"))
    
while True:
    if button_a.was_pressed():
        hello+=1
    elif button_b.was_pressed():
        radion(str(hello))
        while True:
            if button_a.was_pressed():
                hello=0
                break
            elif button_b.was_pressed():
                radio.send(str(hello))
                radion(str(hello))
                hello=0
                break
        
    incoming = radio.receive()
    radion(incoming)
    

 

你可能感兴趣的:(5.,技术杂项,10.,For,Child)