{"id":18484209,"url":"https://github.com/nathankleyn/lego-nxt","last_synced_at":"2025-04-08T18:33:12.733Z","repository":{"id":2870401,"uuid":"3876012","full_name":"nathankleyn/lego-nxt","owner":"nathankleyn","description":"Ruby LEGO Mindstorms NXT 2.0 control via Bluetooth and USB.","archived":false,"fork":false,"pushed_at":"2023-03-17T03:51:28.000Z","size":109,"stargazers_count":25,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T17:22:42.145Z","etag":null,"topics":["lego","nxt","nxt-brick","ruby","ruby-nxt"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathankleyn.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}},"created_at":"2012-03-30T11:38:11.000Z","updated_at":"2022-09-04T15:14:08.000Z","dependencies_parsed_at":"2023-07-05T20:32:02.235Z","dependency_job_id":null,"html_url":"https://github.com/nathankleyn/lego-nxt","commit_stats":{"total_commits":42,"total_committers":3,"mean_commits":14.0,"dds":"0.30952380952380953","last_synced_commit":"85731757e668bb1f6b569059fe1685f3abc31742"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Flego-nxt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Flego-nxt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Flego-nxt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathankleyn%2Flego-nxt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathankleyn","download_url":"https://codeload.github.com/nathankleyn/lego-nxt/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247902771,"owners_count":21015512,"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","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":["lego","nxt","nxt-brick","ruby","ruby-nxt"],"created_at":"2024-11-06T12:38:54.139Z","updated_at":"2025-04-08T18:33:07.724Z","avatar_url":"https://github.com/nathankleyn.png","language":"Ruby","funding_links":[],"categories":["NXT"],"sub_categories":[],"readme":"# Lego NXT [![Build Status](https://github.com/nathankleyn/lego-nxt/workflows/Tests/badge.svg)](https://github.com/nathankleyn/lego-nxt/actions?query=workflow%3ATests) [![Coverage Status](https://coveralls.io/repos/github/nathankleyn/attr_combined_accessor/badge.svg?branch=master)](https://coveralls.io/github/nathankleyn/lego-nxt?branch=master) [![RubyGems Version](https://img.shields.io/gem/v/lego-nxt.svg)](https://rubygems.org/gems/lego-nxt)\n\n\u003e **This gem is under heavy development!** A lot of the below code may not work, and is certainly not guranteed to be reliable if it does! If you need to base a working project on this, I recommend [going back to the `ruby-nxt` gem this work is inspired by](https://github.com/zuk/ruby-nxt) for the time being.\n\nControl a Lego NXT 2.0 brick using Ruby code. This library works by piping commands over a Bluetooth or USB connection to the brick, allowing you to write Ruby scripts to control your NXT brick.\n\nThis project used to be based on \"ruby-nxt\", and Tony Buser's subsequent rewrite \"nxt\". It is now a complete rewrite, based heavily in some parts on the aforesaid projects internally, but with a brand new external API that should prove cleaner and easier to work with.\n\nThis code implements direct command, as outlined in \"Appendix 2-LEGO MINDSTORMS NXT Direct Commands.pdf\". Not all functionality is implemented yet!\n\n## Getting Started\n\n### Installing This Library\n\nInstall the gem:\n\n```sh\ngem install lego-nxt\n```\n\nAdd it as a Bundler dependency as you see fit!\n\n### Connect to Your NXT Brick\n\nIn order to start coding with your NXT, you'll need to set up either a USB or Bluetooth connection to it. Follow one of the below sets of steps; if you go for a Bluetooth connection, you'll need to remember the `/dev/*` address you end up using, as you'll need to provide it when making a connection with this library.\n\n#### Connecting Via USB\n\nSimply plug in the NXT, and that's it! This library will take care of enumerating the USB host devices to find the NXT device for you, no effort required on your behalf!\n\n#### Connecting Via Bluetooth\n\n##### Linux\n\nMake sure you have the `bluez` package installed, which should include the `rfcomm` and `hcitool` commands. We start by searching for the MAC address of our NXT:\n\n```sh\n$ hcitool scan\n  Scanning ...\n      90-8E-E0-C1-2A-7B       NXT\n```\n\nThen open the `/etc/bluetooth/rfcomm.conf` file and add an entry as follows:\n\n```\nrfcomm0 {\n  bind yes;\n  # Bluetooth address of the device\n  device 90-8E-E0-C1-2A-7B;\n  # RFCOMM channel for the connection\n  channel 1;\n  # Description of the connection\n  comment \"NXT\";\n}\n```\n\nIf you're on a distro which has a Bluetoth daemon running automatically, you can simply restart it. For Ubuntu, that will look something like:\n\n```sh\n$ sudo /etc/init.d/bluez-utils\n```\n\nOn other distros where you manage the Bluetooth daemon yourself, you'll need to do the bind calls yourself:\n\n```sh\n$ sudo rfcomm bind /dev/rfcomm0 '90-8E-E0-C1-2A-7B'\n```\n\nAfter that, the Bluetooth connection should be established. Check that by running the `rfcomm` command with no arguments:\n\n```sh\n$ rfcomm\nrfcomm0: 90-8E-E0-C1-2A-7B channel 1 clean\n```\n\nThe NXT should now be accessible from `/dev/rfcomm0`!\n\n##### Mac OS X\n\nTurn on the NXT and make sure Bluetooth is turned on. Click the bluetooth icon in the menubar of your Mac and select \"Setup bluetooth device\". It will prompt you for a device type; choose \"Any device\". Select the NXT from the list and click continue.\n\nThe NXT will beep and ask for a passkey. Choose `1234` and press orange button. Enter the `1234` passcode on your Mac when promted. The NXT will beep again; press the orange button to use `1234` again.\n\nYour Mac will then alert you that \"There were no supported services found on your device\". Ignore and click \"Continue\", followed by \"Quit\".\n\nNow click the Bluetooth icon and select \"Open bluetooth preferences\"; you should see the NXT listed. Select it, then click \"Edit Serial Ports\".\nIt should show `NXT-DevB-1`; if not, click \"Add\", and use:\n\n```\nPort Name: NXT-DevB-1\nDevice Service: Dev B\nPort type: RS-232\n```\n\nClick \"Apply\". The NXT should now be accessible from `/dev/tty.NXT-DevB-1`!\n\n## Documentation and Examples\n\nThe NXT project has been heavily documented using nice, clean, human readable markdown. YARD is used to generated the docs, and the options have been included in our `.yardopts` file, so simply run a YARD server to read them:\n\n```sh\n$ yard server\n```\n\nThis documents the API, both internal and external. For bite-sized chunks of NXT code that is much more appropriate for beginners, [have a look at the examples](https://github.com/nathankleyn/nxt/tree/master/examples).\n\nIn addition to this, you might find the tests quite helpful. There are currently only RSpec unit tests, which can be found in the [`spec`](spec) directory; the plan is to add some decent feature tests soon.\n\n## License\n\nThis project is licensed [via MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathankleyn%2Flego-nxt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathankleyn%2Flego-nxt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathankleyn%2Flego-nxt/lists"}