What you will need:
- :MOVE mini Buggy. x 1
- BBC micro:bit. x 1
- USB A to micro USB B Cable. x 1
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… 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.©Kitronik Ltd – You may print this page & link to it, but must not copy the page or part thereof without Kitronik's prior written consent.
6 comments
Mark Donnison
Hi Danniel, Try here: https://www.kitronik.co.uk/blog/micropython-kitronik-bbc-microbit/
Mark Donnison
Hi Julian, Try here: https://www.kitronik.co.uk/blog/micropython-kitronik-bbc-microbit/
Mark Donnison
Hi Julian, Try here: https://www.kitronik.co.uk/blog/micropython-kitronik-bbc-microbit/
julian tatuan
necesita código python
julian tatuan
espanol need script pthon
danniel
were python at