David Whale has developed the BitIO library. It essentially lets you code your Microbit in normal Python 3.
Last summer I created these resources for Micro:bit:
These were a mostly micro python using MU IDE. Some involved using the serial connection from Micro:bit and a Raspberry Pi. This again built on top of the technical feats of David Whale.
Each program involved a Micro python program which sat on the Micro:bit and then a separate Python program that then interpreted the data sent by the Micro:bit. This was technically possible but elongated.
David has essentially stripped out much of the complexity. Now there is a generic hex file which sits on the Micro:bit. The only coding that you do is in Python 3.
Here are the steps to get a simple demo working:
1. Go to Davids github:
2. Look on the far right of the webpage for a green box which says 'clone or download'. Then click 'Download Zip'. Then save the zip file to your Pi.
3. Using the file manager find the downloaded Zip file and extract it.
4. Now plug in your Micro:bit to the Pi. Go into the Bitio master folder and you will find a hex file called 'bitio.hex'. Copy this and paste it onto the Micro:bit. This should now be flashed.
5. Go to the Bitio master folder and find the src folder. You will see several examples. The one that we will test uses the accelerometer to control the position of the player in Minecraft.
6. The file is called 'tilt_mc.py' open this in Python 3.
7. Open Minecraft and create a new world. Press f5 to run it the Python script.
8. The following dialogue will display in the Python shell window:
No micro:bit has previously been detected
Scanning for serial ports
remove device, then press ENTER
9. So unplug the Micro:bit and press enter.
10. Next the following text will display:
found 67 device(s)
plug in device, then press ENTER
11. Now press enter and the following text will display:
found 68 device(s)
found 1 new device
Do you want this device to be remembered? (Y/N)
12. Press enter to confirm and the following text will display:
Your micro:bit has been detected
Now running your program
13. If you pick up your Micro:bit then and open Minecraft you should see the player move according to the direction you are tilting the Micro:bit.