Skip to content

Activity

Saving sea turtles

Beginner | MakeCode, Python | LED display, Light sensor | 14 Life below water, Input/output, Selection

Step 1: Make it

What is it?

Newly-hatched sea turtles use moonlight to find their way to the sea. Tall, bright lights can confuse them. Build a prototype of beach lighting for paths that guides humans safely but doesn't distract turtles.

This project is part of a series created to offer problem-solving and prototyping activities designed to explore technology as a solution to the challenges of the Global Goals for Sustainable Development.

Introduction

Coding guide

What you'll learn

  • How to make a prototype for a larger project
  • How computers take readings from inputs, process the data to make different outputs depending on the value of sensor readings

How it works

  • This project uses the micro:bit’s LEDs as a light sensor input. Cover the display with your hand and it should light up with the turtle picture.
  • It could be used at ground level to guide humans along a beach path at night, without confusing sea turtle hatchlings with tall, bright lights that they may mistake for the moon.
  • The program uses selection to sense if the light falling on the micro:bit falls below a certain level, if it is less than (<) 100. If it is dark, it lights up the micro:bit display, else it clears the screen so the LEDs are dark.
  • You may need to adjust the threshold number 100 depending on the lighting conditions where you are. If you're in a very bright place, you may need a smaller number.

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

Step 2: Code it

1from microbit import *
2
3while True:
4    if display.read_light_level() < 100:
5        display.show(Image(
6        "00000:"
7        "09900:"
8        "99999:"
9        "99999:"
10        "90090"))
11    else:
12        display.clear()
13    sleep(2000)

Step 3: Improve it

  • Create your own picture to show on the LED display
  • Add an animation
  • Change the display to show arrows to make sure people walk on the correct side of the path