Thursday, 1 October 2026

Microbit Express: Tilting remote Control subtle upgrades




I've been playing around with the LEGO train again and have made a few changes to the way I control it.

The original version used the buttons on a Micro:bit to control the train, but I wanted something that felt a bit more natural to use. I've therefore changed the controller so that the train is controlled by tilting the Micro:bit. The previous version used forward movement of the Micro:bit to move the train forward and back tilt move backwards, but to be honest it's annoying and not intuitive. Also the lights were connected directly to the motor connectors which means as you increase the power they flicker which is also rubbish.   

So I've given a bit of an upgrade..................  

Upgrade 1: Tilt the Micro:bit to the left and the train moves forwards. Tilt it to the right and it moves backwards. Keep it roughly level and the train stops.

The Micro:bit's accelerometer gives a reading depending on how far it is tilted. I've mapped this to a speed range of -100 to 100, so the further I tilt it, the faster the train goes.

Upgrade 2: I also added a small dead zone around the middle. This stops the train creeping along when the Micro:bit is almost level.

The other change was adding an emergency stop. Pressing A+B sends a special value, 999, to the train. The train recognises this as an emergency stop and cuts the motors. Pressing A releases the emergency stop and allows the controller to be used again.

Upgrade / slight bodge: I also decided to keep the train lights simple for now. Rather than trying to control them from the Micro:bit, I've connected them directly to the battery terminals. They therefore have constant power whenever the train is switched on. The only bind with this is that I need to remove the battery or else its constantly on/ its better but with a small inconvenience. I never declared myself and electrician just and enthusiastic bodger.  

I'm gradually building towards the idea of a modular LEGO city(micro scale) due to now where to host where different parts can be connected to Micro:bits and eventually become part of an IoT system.

The train is effectively becoming the first module.

There is still plenty I'd like to improve, but that's part of the fun of these projects. I'm trying to build it gradually rather than attempting to create the whole thing in one go. Have a look below for the updated coding card. Let me know if you have ago yourself. 




If you like this blog check out all the others here