EXTEND 1: Let's experiment with different micro:bit inputs!

The micro:bit's light detector returns a number where 0 means dark and 255 means bright.

  • Inside your interval event, find the line that says this: data·=·microbit.get_temp()
  • Replace the text that says .get_temp() with .get_light().
  • Then, find the line in which you set the title of your scatter plot. Change the title to "Time vs. Light".

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)