Sunday, 23 July 2017

Blog 1: Getting Started with BitIO




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:

http://warksjammy.blogspot.co.uk/2017/04/cpc-ucreate-microbit-resources-all-in.html

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:
https://github.com/whaleygeek/bitio

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:

scanning...
found 67 device(s)
plug in device, then press ENTER 

11. Now press enter and the following text will display:

scanning...
found 68 device(s)
found 1 new device
selected:/dev/ttyACM0
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.


You can now download a pdf version of these tutorials as part of the updated #hackpack resource booklet here:
https://github.com/ncscomputing/HpAnthologyV2/raw/master/Hackpack%20Anthology%20V2%200.3.pdf



3 comments:

  1. i do have a problem in the pi step, i downloaded the file on SD but the pi is not opening on the computer shall i install the raspberian on it

    ReplyDelete
  2. did you download the zip file onto your pi and extract?

    ReplyDelete