Creating and reading files
Micro:bit has a persistent filesystem. This means that the files remain intact even when we power it off. Micro:bit stores all the files in the flash memory. We can use approximately 30 KB of flash memory to store our own files. One of the constraints of the Micro:bit filesystem is that it provides a flat filesystem. This means that we cannot create directories (folders) and subdirectories. It won’t allow us to create a hierarchy of directories and files as commonly found in operating systems such as Windows, Unix, FreeBSD, and Linux. The stored files will remain intact until we delete them either manually or programmatically. Also, re-flashing the Micro:bit deletes a file(s).
We can create and store files with any extension on Micro:bit. We can use the built-in open()
function to create a file in various modes. We have to specify whether we wish to read or write the file in the arguments. The 'w'
argument stands for write mode. Here is...