BBC micro:bit – Lightning Distance Calculator

Lightning FlashHave you ever seen a lightning flash or heard the thunder of lightning and wondered how close you were from the ligthning strike? Have you noticed that there often was a delay between the flash of light and the clap of thunder when a lightning occurs?

It is possible to calculate the distance to a ligthning strike by counting the seconds between the lightning flash and the sound of thunder.

When lightning strikes, the first thing you see is the flash of light which you can see instantly. This is because light travels at a very high speed (Speed of light = 300,000 km/s). At the same time a clap of thunder is created. However, in the air a sound wave does not travel as fast as light, so it may take a few seconds for this clap of thunder to reach you. This depends on how far you are from the lightning.

Look at the following diagram and check the formula of speed. Bear in mind that the speed of a sound wave in the air is 340 m/s.
lightning-distance
speed-distance-formula

Your Challenge


Write a program for the BBC micro:bit that will allow the user to:

  1. Press the A button of the micro:bit when they spot a lightning flash.
  2. Press the B button of the micro:bit when they hear the thunderstorm.
  3. Display the distance (in meters) from the lightning strike using the LED screen.
Share Button
Posted in BBC micro:bit, Computer Science Tagged with:

Our Latest Book

Follow this blog