It was recently BASIC’s 57th birthday, the programming language many of us first used to do any computer programming on computers from the 1970s and 1980s like the Commodore PET, Sinclair ZX Spectrum or Apple 2. Worth remembering too that part of the team that created BASIC was Sister Mary Kenneth Keller, the first woman and one of the first people in the US to get a PhD in computer science.
I’d known for a while that there was a Japanese port of TinyBASIC for the BBC micro:bit. To be honest I thought it was a bit of a novelty as you need a computer to connect to it that will be more powerful than the micro:bit and able itself to run proper BASIC, but it’s actually very, very clever. It will allow you to access features of the micro:bit itself, like the LED display, the buttons, GPIO pins and so on, meaning you can do real physical computing with the micro:bit in BASIC. You don’t need any special hardware, just a micro:bit and some sort of serial terminal on a computer connected to the micro:bit by USB.
To get it running go to https://github.com/Tamakichi/ttbasic_microbit – I used Google translate to help me navigate the page. Download the ZIP file and unpack the hex file and flash it to a V1 micro:bit. (It looks like it’s not yet been updated to work on the newer micro:bit with sound).
You can use terminal software to communicate with it, but it’s simpler to use Chrome and a web-based alternative. You can use the online micro:bit Python editor, but this is probably better as it handles scrolling well: https://googlechromelabs.github.io/serial-terminal/. The video at the top of this page shows how to set it up.
A very cool feature is that you can save files to flash memory, just as you’d save programs to cassette or disk on an 8-bit computer like the ZX Spectrum. There are 16 slots for programs, accessed with the SAVE and LOAD commands. FILES lists everything in the file system.
The program in slot 0 can be made to run automatically at start up – press button B at reset or, if on batteries, Press and hold Button A and Button B for 5 seconds, then release only Button A
You can play music out of piezo speaker attached to pin 8. It also supports NeoPixel 8×8 matrix displays, for example for displaying Japanese characters.
It also has a real time clock, though it’ll lose its time when you power off. Use
SETDATE Year, month, day, hour, minute, second
There’s a lot more you can do with TinyBASIC on the micro:bit. There’s a comprehensive PDF manual in Japanese which you can translate using Google Translate to discover more.
Here are some sample programs featured in the video:
1 'blink 5 MATRIX OFF 10 GPIO 3,OUTPUT 20 OUT 3,LOW 30 GPIO 26,OUTPUT 35 "@loop" 40 OUT 26,HIGH 50 WAIT 300 60 OUT 26,LOW 70 WAIT 300 80 GOTO "@loop"
10 CLS 20 IF !IN(BTNA) ?"Button A" 30 IF !IN(BTNB) ?"Button B" 40 WAIT 200 50 GOTO 20
Fill all the LEDs
10 CLS 1 20 D=1 30 FOR Y=0 TO 4 40 FOR X=0 TO 4 50 PSET X,Y,D 60 WAIT 100 70 NEXT X 80 NEXT Y 90 IF D D=0 ELSE D=1 100 GOTO 30
LED matrix message display
10 CLS 1 20 MSG LEFT,200,"Hello world! " 30 FOR I=O TO 30 40 MSG DOWN,50,I/10 50 WAIT 50 60 MSG LEFT,100,I%10 70 NEXT I 80 WAIT 500 90 GOTO 20