Interactive BASIC for Arduino and STM32

This project was developed in 2018 for classes with schoolchildren – so that during the lesson it was possible to program controllers, including via Bluetooth from a phone – and with an interactive mode (entered a command – the LED lit up). It includes a simple homemade BASIC interpreter with firmware versions for AtMega328 (arduino) and STM32F103, an emulator so you can try/practice online – and a Bluetooth terminal for Android (in case of programming from a phone and not via cable).

The thing is more or less working – we played with it for a semester – but still I’m not very happy with the result (I’ll explain why) – and in the following years I tried other ideas in this direction (also quite wild).

Background

Teaching electronics as a hobby at a local school, I of course strived to include a few microcontroller classes each year. It would seem that there is something there – distribute the arduinos to everyone and let's go – but this option runs into problems:

  • classes are held in a regular classroom, not equipped with computers – and the option “let everyone bring a laptop” is also questionable – so I wanted to use mobile phones

  • the kids are not taught C (some classes study programming in Python, others in Java) – therefore, although they are able to type and modify basic examples, slightly more complex ones will certainly encounter a lot of problems (in lessons, you don’t want to waste time on a thorough presentation of the language)

In general, there are a lot of options for how to arrange the interaction of a phone with a controller, especially now – there are environments for Arduino, and more ornate things (and I’ll tell you about a couple of mine later) – all of them, however, turn out to be somewhat inconvenient when you’re not the only one having fun and you are trying to organize the work of a class of 20 people.

So – the Miskatino project

The name is perhaps a little stupid – I didn’t bother with it, I was just reading Lovecraft’s fairy tales at that moment – well, it was inspired by the name of a fictional university.

Here is the project on Github https://github.com/Miskatino/miskatino-basic – there is a fairly detailed description of the commands – there is also an emulator, so those who are reading this article from a computer can try it right away – open it and enter the command

PIN 2; 1

and, lo and behold, you will see that the LED painted on leg 2 “lit up”. Try typing “program” – to do this, enter commands with line numbers:

10 PIN 2; 1
20 DELAY 300
30 PIN 2; 0
40 DELAY 700
50 GOTO 10
RUN

Please note that the last command does not have a line number. It is not added to the program but starts it for execution. The LED will flash.

If you take an Arduino, you can assemble and upload the project and program it from a regular console via cable (for example, from the same Arduino Serial Monitor – a window included in the Arduino IDE). As a base model, I used those with AtMega328 controllers – but in general, almost any one is suitable, although since the program lives in RAM, the more RAM the better.

For programming via Bluetooth, I purchased a handful of HC-05 type modules and soldered suitable connectors to them and to the Arduinos to plug one into the other. But it turned out that it was not so easy to find a “terminal” for the phone that was convenient for interactive work – so I soon wrote my own (in particular, to send characters immediately and not accumulate them over lines). It is available nearby on Github, but… It hasn't been updated in years, it's unlikely to run on a modern phone – and you'll need to choose something else.

In general, you can admire the video (although I probably recorded the demo in English, for reddit), study the documentation, play with the emulator or flash it into a live controller. The program in the controller is saved (although on Arduinos this was done in EEPROM, which is not very convenient) – and after a restart, if the controller does not receive any commands, it starts on its own. That is, this thing can be used in simple crafts to reprogram and test them on the go.

Conclusion

As stated at the beginning, I was not very pleased with the results of the lessons with schoolchildren. We tried lighting LEDs, getting the voltage value from the variable resistor motor, and working with a seven-segment indicator. Below are the impressions that made me decide to move on and try other options.

  1. Technically – two dozen inferior bluetooth modules in one room, with not very reliable power supply – all this makes the connection not very reliable on a scale for 20 people – every now and then someone's controller will reboot or something else. However, on a scale for a whole class with any crafts, everything is always not smooth, even with ordinary Arduinos (“but my port has disappeared,” etc.)

  2. Technological – in this implementation, only relatively small programs fit into the Arduino memory – and their capabilities are of course limited by those functions that are provided in the interpreter. The performance is sufficient for a temperature controller or, say, a simple robot – but in general it is clear that the interpreter is an order of magnitude slower than the compiled code. On ARM devices, of course, everything is much more fun – but it somehow seemed labor-intensive to me to make and solder 20 boards with STM32 for the class.

  3. Ideological – as I complained above, C is too complicated for guys – and BASIC, of ​​course, on the contrary, is simple. Well, not counting the process of mastering the interactive set of programs. This is not a level for grades 9-11. Over the next few years, I have been trying to torment my kids with assembler for AVR – this makes their brains drain a little, but it seems more useful in terms of broadening their horizons. Still, at this age they are able to learn Arduin C without me (well, I help those who take it up as part of individual projects, it’s not difficult to do it according to the instructions).

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *