Skip to content

活動

Species counter

初學者 | MakeCode, Python | LED 螢幕, 按鈕 | 動物, 數字和位置值, 植物, 生態系統, 變數

步驟1:製作

它是什麼?

Use your BBC micro:bit to help you count two different species of plants or animals in your school playground, garden or local park. You will learn about variables, and using the micro:bit's buttons and LED display.

這兩支影片為您示範了製作內容和編碼方法:

運作方式

  • The program uses variables called “A” and “B” to store the number of animals or plants counted.
  • Variables store numbers or values that can change in a computer program.
  • At the beginning of the program, “A” and “B” are set to zero and zero is shown on the LED display. You should always give variables an initial value in a computer program like this.
  • Press button A each time you see a particular animal or plant, for example, a duck, and each time one will be added to “A”.
  • Press button B each time you see another plant or animal of interest, for example, a goose, and each time one will be added to “B”.
  • Shake your micro:bit to show the totals on the LED display.

你需要的東西

  • micro:bit (或,MakeCode simulator)
  • MakeCode編輯器
  • battery pack (optional but recommended)
  • our set-up guide may be useful

步驟2:編碼

步驟3:進階

  • Find a way of resetting the counter, for example, by pressing buttons A and B together.
  • Make a graphical representation of the number of animals or plants counted, for example, by using dots.
  • Show icons representing the animals or plants, or play sound effects, when you have reached a target number.