Close-up of a bee pollinating a yellow flower.
Side view of a female researcher examining an outdoor garden.

Bees play a big role in our ecosystem, helping plants reproduce and ensuring we have food to eat. However, pollinator populations are declining due to things like habitat loss and climate change. By monitoring their activity, we can learn to better protect these essential creatures.

Let’s build a bee counter that helps us track the number of bee visits to a garden!

The bee counter in this project will:

  • Count bee visits (simulated by touch)
  • Light up an LED when a bee lands
Forward Education's bee counter build next to a CodeCTRL device.

Prepare

You’ll need the following items to complete this project:

Build

First, let’s build your bee counter with the Climate Action Kit:

Code

  1. Plug your micro:bit into the top of the CodeCTRL device.
  2. Connect your CodeCTRL to a sensor port on breakout board.
  3. Turn on the breakout board.
  4. Turn on the CodeCTRL.
Visual representation of the instructions:
1. Plug your micro:bit into the top of the CodeCTRL device.
2. Connect your CodeCTRL to a sensor port on breakout board.
3. Turn on the breakout board.
4. Turn on the CodeCTRL.

Recreate the following program in MicroCode:

MicroCode program. 

With this code, when the button is not being pressed, the LEDs will show Yellow. 
When the button is pressed, the LEDs will show Blue. The variable X will also show on the micro:bit 
LEDs and add one to the variable count.

Improve

Think about additional features you could add to your smart bee counter! How would you modify the sample code provided, or create your own code that includes the following features?

  • Add Sound: Can you make the micro:bit play a sound when a bee lands?
  • Display Temperature: The outside temperature can impact bee pollination habits. Can you display the temperature on the micro:bit’s LED display?

Feeling Stuck? Explore the Knowledge Base for common questions and troubleshooting tips.