6. Lighthouse

The lighthouse is another great project for young children for the same reasons as the traffic light. They are all familiar with a lighthouse and fully under stand what it needs do.

Half the battle with any project you teach in school is finding a context that is relevant to the children's lives and that they fully understand. Even better if that context serves a useful function.

Task:

Create a lighthouse model that can sense light and dark and automatically operate a light to flash on for 1 second and off for three seconds when it is dark.

It must also have a buzzer for a fog horn that will sound for 2 seconds then switch off for 2 seconds when a button is pressed.


Algorithm:

Repeat forever

if input is high

switch the LED on

pause for 1 second

switch the LED off

pause for 3 seconds

else switch the LED off

if the push switch is closed

switch the buzzer on

pause for 2 seconds

switch the buzzer off

pause for 2 seconds

Model:

There is no need to buy a fairground ride kit. In fact the children will learn much more if they design and build the ride themselves. making this an ideal STEM project.

Follow this link for model making ideas

To make this model, all you need is an LED, an LDR, the tube from a kitchen roll and a plastic shot glass, to make the lighthouse. For the rocks you will need some paper and PVA glue, a buzzer and a push switch.

You will need to add about 40 cm of wire to the legs of the LED and the LDR and 20 cm of wire to the buzzer and push switch.

The connector blocks are to make the connection between the lighthouse model and the gpiO interface.


MakeCode editor script:

Micro Python script:

from microbit import *


while True:

if pin2.read_analog() > 950:

pin1.write_digital(1)

else:

pin1.write_digital(0)


if button_a.was_ pressed():

pin0.write_digital(1)

else:

pin0.write_digital(0)