{"id":24521110,"url":"https://github.com/matthijskamstra/hx-node-bbc-microbit","last_synced_at":"2026-03-02T13:13:24.048Z","repository":{"id":141666792,"uuid":"86105410","full_name":"MatthijsKamstra/hx-node-bbc-microbit","owner":"MatthijsKamstra","description":"Control a BBC micro:bit from Node.js using BLE and Haxe","archived":false,"fork":false,"pushed_at":"2017-04-04T13:35:13.000Z","size":1397,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-14T11:14:05.576Z","etag":null,"topics":["bbc-microbit","haxe","microbit","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MatthijsKamstra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-24T19:51:04.000Z","updated_at":"2019-03-17T10:46:59.000Z","dependencies_parsed_at":"2024-01-07T18:07:24.984Z","dependency_job_id":null,"html_url":"https://github.com/MatthijsKamstra/hx-node-bbc-microbit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MatthijsKamstra/hx-node-bbc-microbit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthijsKamstra%2Fhx-node-bbc-microbit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthijsKamstra%2Fhx-node-bbc-microbit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthijsKamstra%2Fhx-node-bbc-microbit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthijsKamstra%2Fhx-node-bbc-microbit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MatthijsKamstra","download_url":"https://codeload.github.com/MatthijsKamstra/hx-node-bbc-microbit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MatthijsKamstra%2Fhx-node-bbc-microbit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30003760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T12:19:43.414Z","status":"ssl_error","status_checked_at":"2026-03-02T12:19:02.215Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bbc-microbit","haxe","microbit","nodejs"],"created_at":"2025-01-22T02:48:58.871Z","updated_at":"2026-03-02T13:13:24.032Z","avatar_url":"https://github.com/MatthijsKamstra.png","language":"Haxe","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n- [Micro:bit](#hx-node-bbc-microbit)\n- [Haxe](#haxe)\n- [Installation](#installation-haxenpm)\n- [Haxelib](#haxelib)\n- [Visual Studio Code](#visual-studio-code)\n- [Haxe niceties](#haxe-niceties)\n- [Difference](#difference)\n- [Examples](#examples)\n\n\n# hx-node-bbc-microbit\n\nControl a [BBC micro:bit](http://microbit.org/) from [Node.js](https://nodejs.org/) using [BLE](https://en.wikipedia.org/wiki/Bluetooth_low_energy) and [Haxe](http://haxe.org/)\n\nThese are the Haxe node.js externs from \u003chttps://github.com/sandeepmistry/node-bbc-microbit\u003e and follows the [api](https://github.com/sandeepmistry/node-bbc-microbit/blob/master/API.md)\n\n\n![](icon.jpg)\n\n\u003e The Micro Bit (also referred to as BBC Micro Bit, stylised as micro:bit) is an ARM-based embedded system designed by the BBC for use in computer education in the UK.\n\u003e\n\u003e The board is 4 cm × 5 cm and has an ARM Cortex-M0 processor, accelerometer and magnetometer sensors, Bluetooth and USB connectivity, a display consisting of 25 LEDs, two programmable buttons, and can be powered by either USB or an external battery pack.[2] The device inputs and outputs are through five ring connectors that are part of the 23-pin edge connector.\n\u003e\n\u003e [wikipedia](https://en.wikipedia.org/wiki/Micro_Bit)\n\n\n![](img/microbit.png)\n\n## Haxe?\n\nRead more about [Haxe](README_HAXE.MD)\n\n\n## Installation Haxe/NPM\n\n#### 1. [follow instructions to install `bbc-microbit`](https://github.com/sandeepmistry/node-bbc-microbit#prerequisites)\n\u003e Make sure to follow the instructions for `noble` too.\n\n#### 2. install dependencies with npm\n```\nnpm install\n```\n\n#### 3. install haxelib\n\n```\nhaxelib git bbc-microbit https://github.com/MatthijsKamstra/hx-node-bbc-microbit\n```\n\n\n\n## Haxelib\n\nuse this repo locally\n\n```\nhaxelib dev bbc-microbit path/to/folder/src\n```\n\nor this git repo\n\n```\nhaxelib git bbc-microbit https://github.com/MatthijsKamstra/hx-node-bbc-microbit\n```\n\ndon't forget to add it to your build file\n\n```\n-lib bbc-microbit\n```\n\n## Visual Studio Code\n\nI would suggest to us Visual Studio Code, it's a very nice editor and lets you set breakpoints in your `js` file\n\n![](img/vscode.png)\n\nBut [other code-editors](http://matthijskamstra.github.io/haxejs/haxe/choosing-a-code-editor.html) may work as well!\n\n\n## Haxe niceties\n\ncreate a (LED)pattern from an array\n\n```haxe\nvar X = [\n\t1, 0, 0, 0, 1,\n\t0, 1, 0, 1, 0,\n\t0, 0, 1, 0, 0,\n\t0, 1, 0, 1, 0,\n\t1, 0, 0, 0, 1,\n];\nvar buffer = new Buffer(new Pattern().createLedMatrixBuffer(X));\n\n// follow example \"LedPatternHx\"\n// or use a default Pattern\nvar buffer = new Buffer(new Pattern().createLedMatrixBuffer(Pattern.HEART));\n\n\n```\n\nUse string to listen to or `EventName`\n\n```haxe\nimport BBCMicrobit;\n\n// strings will work\nmicrobit.on('buttonAChange', function(value) {\n\tconsole.log('\\ton -\u003e button A change');\n});\n\n// prevent spelling mistakes with EventName\nmicrobit.on(EventName.BUTTON_A_CHANGE, function(value) {\n\tconsole.log('\\ton -\u003e button A change');\n});\n```\n\nUse the fixed values for AccelerometerPeriod `Period`\n\n```haxe\nimport BBCMicrobit;\n\n// numbers will work\nmicrobit.writeAccelerometerPeriod(160, function(err) {\n\tconsole.log('\\taccelerometer period set');\n});\n\n// prevent using wrong value use Period\nmicrobit.writeAccelerometerPeriod(Period.NR_160, function(err) {\n\tconsole.log('\\taccelerometer period set');\n});\n```\n\n## Difference\n\n- UART doesn't work: [check api](https://github.com/sandeepmistry/node-bbc-microbit/blob/master/API.md#uart)\n- Light sensor doesn't work: it works with a trick [read more](https://lancaster-university.github.io/microbit-docs/extras/light-sensing/) but with this node.js code unable to access.\n- The code is not written on the micro:bit, remove power (switch off) and the code is gone\n- EventListeners examples doesn't work: the code is not uploaded to NPM yet (but if you want to use it read [this](#fix-eventlistener))\n\n## Fix EventListener\n\nAfter installing the dependencies via `npm install`.   \nYou need to update the `node_modules/bbc-microbit` folder with two files:\n\n- [bbc-microbit.js](https://raw.githubusercontent.com/sandeepmistry/node-bbc-microbit/master/lib/bbc-microbit.js)\n- [event-service.js](https://github.com/sandeepmistry/node-bbc-microbit/blob/master/lib/event-service.js)\n\nAnd that will make that work.\n\nI have created an issue \"[microbit.subscribeEvents](https://github.com/sandeepmistry/node-bbc-microbit/issues/14)\" but it's not fixed yet.\n\n\n## Examples\n\nmost examples from \u003chttps://github.com/sandeepmistry/node-bbc-microbit\u003e are \"redone\" in Haxe\n\n- [AccelerometerListener.hx](/src/examples/AccelerometerListener.hx)\n- [ButtonListener.hx](/src/examples/ButtonListener.hx)\n- [Compass.hx](/src/examples/Compass.hx)\n- [Discoverer.hx](/src/examples/Discoverer.hx)\n- [EventListener.hx](/src/examples/EventListener.hx) // doesn't work out of the box (check [this](#fix-eventlistener))\n- [LedPattern.hx](/src/examples/LedPattern.hx)\n- [LedPatternHx.hx](/src/examples/LedPatternHx.hx)\n- [LedPatternTest.hx](/src/examples/LedPatternTest.hx)\n- [LedText.hx](/src/examples/LedText.hx)\n- [MagnetometerBearingListener.hx](/src/examples/MagnetometerBearingListener.hx)\n- [MagnetometerListener.hx](/src/examples/MagnetometerListener.hx)\n- [PinBlink.hx](/src/examples/PinBlink.hx)\n- [PinListener.hx](/src/examples/PinListener.hx)\n- [TemperatureListener.hx](/src/examples/TemperatureListener.hx)\n\n## Blink\n\n![](img/pins.png)\n\n\n## Source\n\n- \u003chttps://microbit-playground.co.uk/howto/microbit-blink-led-example\u003e\n- \u003chttp://www.microbitlearning.com/page/5\u003e\n- \u003chttp://www.makerspace-uk.co.uk/a-selection-of-microbit-projects/\u003e\n- \u003chttps://learn.adafruit.com/adafruit-arduino-lesson-2-leds/resistors\u003e\n- \u003chttps://www.kitronik.co.uk/blog/bbc-microbit-kitronik-university/\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthijskamstra%2Fhx-node-bbc-microbit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatthijskamstra%2Fhx-node-bbc-microbit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatthijskamstra%2Fhx-node-bbc-microbit/lists"}