扩展 1:让我们尝试不同的 micro:bit输入

micro:bit 的光检测器返回一个数字,其中 0 表示,255 表示

  • 在您的间隔事件中,找到这样的行: data · = · microbitget_temp()
  • .get_temp()的文本替换为.get_light()
  • 然后,找到您设置散点图标题的行。将标题更改为"Time vs. Light"

To navigate the page using the TAB key, first press ESC to exit the code editor.

microbit = codesters.Microbit() microbit.show_string("hello") data = microbit.get_temp() microbit.show_number(data) data_list = [] time_list = [] my_display = codesters.ScatterPlot(time_list, data_list) time = 0 def interval(): data = microbit.get_temp() data_list.append(data) global time time_list.append(time) my_display.update(time_list, data_list) time += 1 my_display.set_title("Time vs. Temperature") stage.event_interval(interval, 1)
  • Run Code
  • 提交作品
  • 下个活动
  • Show Console
  • Reset Code Editor
  • Codesters How To (opens in a new tab)