There are two ways to run MicroPython code on the sino:bit. The first method is using a web-based editor to enter code and download a firmware file with both MicroPython and the desired code to run. The second method is by loading MicroPython firmware onto the sino:bit and then separately loading code onto it using a tool called ampy. This page explores using the web editor to write and run MicroPython code for the sino:bit. The next page explores using ampy to load and run code on the sino:bit.
The web editor for the sino:bit MicroPython port is available at the following address: https://tdicola.github.io/sinobit-micropython/editor/editor.html
If you navigate to the editor you'll see it's very similar to the BBC micro:bit web editor. In fact the sino:bit MicroPython web editor is based on the code for the BBC micro:bit web editor!
At the top you'll find a toolbar of buttons with basic commands for downloading the firmware & code, saving, loading, and other code operations. Below the toolbar you'll see a text editor where you can enter your MicroPython code that will run immediately on power-up. That's all there is to using the web editor--just write code, download the firmware, and drag to the sino:bit drive to program and run the code. No installation of any other tool or plugin is necessary!
Notice the example code the editor loads with to start:
# Add your Python code here. E.g. from microbit import * while True: display.scroll('Hello, World!') display.show(Image.HEART) sleep(2000)
This code is compatible with the micro:bit MicroPython port and will also run on the sino:bit. You can see it calls a scroll function to scroll the message "Hello, World!" across the display. Let's try running the code as-is on the sino:bit!
First plug in the sino:bit to your computer using its USB port. Be sure you're using a USB data cable and NOT a USB power-only cable. You should see a USB drive appear called MICROBIT (remember the sino:bit inherits much of the software and design from the micro:bit, including how it exposes its USB drive). Just like with the micro:bit you can drag a special .hex file to the MICROBIT drive and it will program the board with the firmware inside the file.
Click the download button in the upper left corner of the web editor. After a moment a sino_bit.hex file should be downloaded to your computer (note on the Safari web browser it will download as an 'Unnamed' file and you must change the name to end in .hex--the editor will warn you when this happens). In your file explorer find the sino_bit.hex file and drag it onto the MICROBIT drive. You should see the blue light on the sino:bit flash as it programs the firmware!
After a few moments the blue light will stop flashing and your code will be running on the sino:bit! You should see the message scroll across the display.
Try changing the code, like modifying the message to say your name. Download the hex file again and drag to the sino:bit to see it run.
That's all there is to the basic web editor usage of sino:bit MicroPython! The web editor makes it very easy to get started programming the sino:bit without any tools or complex setup. You can run almost any Python program from the web editor, including any of the tutorials and examples of micro:bit MicroPython code (notice the sino:bit display will increase the size of the displayed pixels to fill the entire matrix).
The one limitation to be aware of with the web editor is that it only supports downloading 8 kilobytes of program code. To run slightly larger or more complex programs you can use a tool called ampy to copy the code manually to the board--continue to the next page to learn more!
Text editor powered by tinymce.