{"id":14437164,"url":"https://github.com/antefact/microBit.js","last_synced_at":"2025-08-26T20:31:08.751Z","repository":{"id":150618757,"uuid":"97963633","full_name":"antefact/microBit.js","owner":"antefact","description":"A javascript library to interact with BBC micro:bit using web bluetooth API","archived":false,"fork":false,"pushed_at":"2017-07-24T12:30:28.000Z","size":6357,"stargazers_count":44,"open_issues_count":4,"forks_count":15,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-24T09:36:28.330Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://antefact.github.io/microBit.js/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antefact.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-21T15:43:38.000Z","updated_at":"2024-10-19T09:55:12.000Z","dependencies_parsed_at":"2023-05-26T13:15:24.396Z","dependency_job_id":null,"html_url":"https://github.com/antefact/microBit.js","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/antefact/microBit.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antefact%2FmicroBit.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antefact%2FmicroBit.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antefact%2FmicroBit.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antefact%2FmicroBit.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antefact","download_url":"https://codeload.github.com/antefact/microBit.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antefact%2FmicroBit.js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272254027,"owners_count":24901036,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-31T08:00:24.665Z","updated_at":"2025-08-26T20:31:08.743Z","avatar_url":"https://github.com/antefact.png","language":"JavaScript","funding_links":[],"categories":["编程","🗿 JavaScript and MakeCode"],"sub_categories":["JavaScript 和 MakeCode","🗿 Node.js and Browser"],"readme":"# microBit.js\nA javascript library to interact with [BBC micro:bit](http://microbit.org/) using web bluetooth API.\n![lars the iceberg](assets/lars.gif)\n\n## Usage\n\nTo use the library, download and upload [this firmware](https://drive.google.com/uc?id=0B2Ud_NaMFsQSdm1BMVMtN3F4a3c\u0026export=download) on your BBC micro:bit board.\n\nThe firmware was produced by [bittysoftware](http://www.bittysoftware.com/downloads.html).\n\nKeep in mind that web bluetooth API are still experimental and your OS and browser might not support the feature. Read more about this [here](https://developers.google.com/web/updates/2015/07/interact-with-ble-devices-on-the-web).\n\nThis Library allows you to read and write the values of all the BLEcharacteristic exposed by the microBit board using simplified API's.\n\nFor more info about all micro:bit ble services please refer to the [official documentation](https://lancaster-university.github.io/microbit-docs/ble/profile/).\n\nThe example folder provided contains several examples for interacting with the device.\n\n## Constructor\n\n- `microBit=new uBit()`\n\n## Properties\n\n- `microBit.connected`\n\n## Functions\n\n\n- `microBit.searchDevice()`\n\n  Search for ble devices in range.\n\n\n- `microBit.setButtonACallback(callbackFunction)`\n\n  Register a callback function to be invoked when Button A is pressed.\n\n  example:\n  ```\n  microBit.setButtonACallback(function(){\n    console.log(\"buttonA pressed\");\n  });\n  ```\n\n- `microBit.setButtonBCallback(callbackFunction)`\n\n  Register a callback function to be invoked when Button B is pressed.\n\n  example:\n  ```\n  microBit.setButtonBCallback(function(){\n    console.log(\"buttonB pressed\");\n  });\n  ```\n\n- `microBit.onConnect(callbackFunction)`\n\n  Register a callback function invoked when the microBit connects\n\n  example:\n  ```\n  microBit.onConnect(function(){\n    console.log(\"connected\");\n  });\n  ```\n\n- `microBit.onDisconnect(callbackFunction)`\n\n  Register a callback function invoked when the microBit disconnects\n\n  example:\n  ```\n  microBit.onDisconnect(function(){\n    console.log(\"disconnected\");\n  });\n  ```\n\n- `microBit.onBleNotify(callbackFunction)`\n\n  Register a callback function invoked every time the value of characteristic changes and it is notified by the device.\n\n  example:\n  ```\n  microBit.onBleNotify(function(){\n    document.getElementById(\"buttonA\").innerHTML=microBit.getButtonA();\n  }\n  ```\n\n- `microBit.writeMatrixIcon(icon)`\n\n  Updates the led matrix on the microbit.\n  The `icon` passed to the function must be 5x5 matrix.\n  0=led off;\n  1=led on;\n\n  example:\n  ```\n  var ledMatrix = [\n    ['0', '0', '0', '0', '0'],\n    ['0', '1', '0', '1', '0'],\n    ['0', '0', '0', '0', '0'],\n    ['1', '0', '0', '0', '1'],\n    ['0', '1', '1', '1', '0']\n  ]\n\n  microBit.writeMatrixIcon(ledMatrix);\n\n  ```\n\n- `microBit.writeMatrixText(text)`\n\n  Updates the led matrix of the microbit with a scrolling text.\n\n  example:\n  ```\n  microBit.writeMatrixText(\"ciao microBit\")\n  ```\n\n- `writeMatrixTextSpeed(speed)`\n\n  set the speed of the scrolling text on the matrix\n  example:\n  ```\n  microBit.writeMatrixTextSpeed(10)\n  ```\n\n- `microBit.getAccelerometer()`\n\n  Returns the value of the accelerometer as a object.\n\n  example:\n  ```\n  acceleration=microBit.getAccelerometer();\n  acc_x=acceleration.x;\n  acc_y=acceleration.y;\n  acc_z=acceleration.z;\n\n  ```\n\n- `microBit.getTemperature()`\n\n  Returns the value of the temperature measured on the processor in celsius.\n\n  example:\n  ```\n  temperature=microBit.getTemperature();\n\n  ```\n\n\n- `microBit.getBearing()`\n\n  Returns the value of magnetometer bearing from 0 to 360.\n  0= pointing nord\n\n  example:\n  ```\n  bearing=microBit.getBearing();\n\n  ```\n\n## Examples\nCheck the examples folder for working examples.\n\n### Basic example\nConnect your microbit to a webpage, visualize the data and change the animations on the led matrix.\n\n[Try it here](https://antefact.github.io/microBit.js/examples/basic/)\n\n![web ble demo](assets/html.gif)\n\n\n### basic p5.js example\nLearn how to interact with the microbit from a [p5.js](https://p5js.org/) sketch, rotate a cube on the canva reading the accelerometer.\n\n[Try it here](https://antefact.github.io/microBit.js/examples/p5js_example/)\n\n### Lars the iceberg\nUse the microBit to control Lars the iceberg. Don't let it melt!\nDeveloped using [p5.js](https://p5js.org/) and [p5.play](http://p5play.molleindustria.org/) library.\n\n[Try it here](https://antefact.github.io/microBit.js/examples/p5play_Lars_example/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantefact%2FmicroBit.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantefact%2FmicroBit.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantefact%2FmicroBit.js/lists"}