我必须编写此代码,以便两个 microbits 可以相互交互。但我无法测试它,因为我只有一个。有没有办法通过一些在线网站/插件/东西来测试这段代码?代码: https ://pastebin.com/N0FirrsD (此代码将收到并采取相应措施)
from microbit import *
import radio
#Pin 0 is the left motor
#Pin 1 is the right motor
#Pin 3 is a buzzer
Starten = false
while Starten == false:
if button_a.is_pressed():
Starten = true
else:
microbit.display.scroll('Druk op A')
radio.on()
radio.config(channel=56)
radio.config(power=7)
while Starten == true:
Commando = radio.receive()
if Commando == "vooruit":
pin0.write_digital(1)
pin1.write_digital(1)
if Commando == "remmen":
pin0.write_digital(0)
pin1.write_digital(0)
if Commando == "links":
pin0.write_digital(0)
pin1.write_digital(1)
if Commando == "rechts":
pin0.write_digital(1)
pin1.write_digital(0)
if Commando == "toeter":
pin3.write_digital(1)
sleep(2000)
pin3.write_digital(0)
if button_b.is_pressed():
Starten = false:
https://pastebin.com/SPbLtWGr(此代码将发送命令)
from microbit import *
import radio
Starten = false
while Starten == false:
if button_a.is_pressed():
Starten = true
else:
microbit.display.scroll('Druk op A')
radio.on()
radio.config(channel=56)
radio.config(power=7)
while Starten == true:
if accelerometer.is_gesture("up"):
radio.send("vooruit")
if accelerometer.is_gesture("down"):
radio.send("remmen)
if accelerometer.is_gesture("left"):
radio.send("links")
if accelerometer.is_gesture("right"):
radio.send("rechts)
if button_a.is_pressed():
radio.send("toeter)