0

I have a BBC Micro:Bit. It's plugged into the Adeept board, which has an I2c 1602 LCD display, Adeept joystick, and Adeept button module. I have to supply power to the board's USB port to run the LCD display. I made a website and want to be able to sync data from the Micro:Bit to the website (your selected name and other data I add later). I set the name to something. Then I plug in my USB to the computer and Micro:Bit. But when I backup and restore, the name is the first name on the list.
I backed it up without restoring and the page said that the name is the first name (even though I changed it). Then when I navigate to the names "app" on the Micro:Bit, it also shows the first name. I don't know if this is a problem with supplying power or the code. My script is here: https://repl.it/@awesomecrater/smartmicrobit#script.js
I am using this library https://github.com/bsiever/microbit-webusb/blob/master/ubitwebusb.js from GitHub and the code on the Micro:Bit to receive the backup signal looks something like this in pseudocode:

When serial received with New Line {
   Split the data at "|||||||" and store it in serialthing
   If the first item in serialthing is "backup" {
      write the variable name to the serial output
   } Else if the first item in serialthing is "name" {
      convert the second item in serialthing to a number and store it in name.
   }
}

Does anyone know why it is setting it back to the first item in the list?
name stores the current item of the list as an index.

1 Answers1

0

Do you mean that you connect the USB cable after setting the name? (Or that the power goes off/on after setting the name?)

I can think of two different sorts of concerns that could cause the behavior you describe:

  • The Micro:bit retains code, but data (values set in variables) are reset every time the micro:bit power goes off/on or it resets.
  • When the USB cable connects the micro:bit resets, so it'll run the startup code and reset any variable values to defaults. If that startup code puts the name back to some initial value, that's the value you'll get. (I've checked with the micro:bit team and I don't think there's a way to avoid the reset when connecting problem with WebUSB).