Christmas Information: Kitronik will be closing 24th Dec December 2024, reopening on 2nd of January 2025. See our delivery schedule for more information.

Guide For Coding Indicators On The :MOVE mini
A neat little trick we have been working on here at Kitronik HQ is to code a :MOVE mini to indicate when it is turning. A little nod to road safety. Once again we are controlling our :MOVE mini with radio signals. This time we are using “flags” in the code for even better functionality. Guide For Coding Indicators On The :MOVE mini You may have noticed that some of the more recent cars utilise LEDs for their lights and indicators. Some, in particular, have 'animated' indicators that roll the lights in the direction of the upcoming manoeuvre. That is the effect we were going for here. As always, you can grab the code at the foot of this resource.  

What you will need:

 

Coding Indicators On The :MOVE mini:

This code is again split into three parts an on start. An on radio received and a forever loop. The on start is pretty simple just setting up the location of the ZIP LEDs on the :MOVE mini. The brightness and radio group. The more interesting blocks are the other two… coding indicators The on radio receive code interprets the instructions from another micro:bit, clears all the ZIP LEDs and creates flags with the true/false statements. Flags in coding are like signals. They indicate to the rest of the code that something is in a particular state, in this case that the :MOVE mini is turning. When we are changing direction we change our flags. For example when we tell the MOVE: mini to turn left we set turn_left_indicator_on to true while leaving turn_right_indicator_on as false.  When we stop or begin driving forwards we set both statements to false. This ensures that our indicators will turn off and that at most only one of our indicators will be on at a time. This final set of code uses the flags established in the radio receive to answer if statements. In this case the if statement asks is turn_left_indicator_on true? If it is then it switches on a defined range of LEDs where the LED that is switched on is equal to the led_1 variable, the other if statement works precisely the same using led_2. The code then uses the pause and the change function to increase the value of the variables. This allows a sequence of LEDs to be switched on. Once this variable has reached a set number the code resets the variable back to 0 and the indicator can begin again. The pause function changes the speed of the indicators and increasing the value in the pause will make the indicator slower. In contrast, decreasing will speed up the indicators. Feel free to play around with those values to change your indicators!  

Downloads:

You can either produce the code yourself, using the screengrabs above as a guide or download the zip file below. This contains the code for the indicators, one hex file for the :MOVE mini and one for the controller microbit. Once you unzip the file you can either drop it straight onto micro:bit in file explorer or drop it into the MakeCode Editor.
  • You can download the receiver file here.
  • Download the transmitter filer here.
 

6 comments

Mark Donnison

Mark Donnison

Hi Danniel, Try here: https://www.kitronik.co.uk/blog/micropython-kitronik-bbc-microbit/

Mark Donnison

Mark Donnison

Hi Julian, Try here: https://www.kitronik.co.uk/blog/micropython-kitronik-bbc-microbit/

Mark Donnison

Mark Donnison

Hi Julian, Try here: https://www.kitronik.co.uk/blog/micropython-kitronik-bbc-microbit/

julian tatuan

julian tatuan

necesita código python

julian tatuan

julian tatuan

espanol need script pthon

danniel

danniel

were python at

Leave a comment

All comments are moderated before being published