Project

nxt

0.0
No commit activity in last 3 years
No release in over 3 years
Control a Lego Minstorms NXT 2.0 Brick See http://github.com/tchype/ruby-nxt for more information.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 1.0.4
 Project Readme

NXT

A ruby gem for controlling Lego Mindstorms NXT 2.0

Installation

Either install it from the command-line:

$ gem install nxt

or add to your Gemfile and install it:

source "https://rubygems.org"

gem 'nxt'
$ bundle install

Usage

The most basic usage can be done using the NXT class by connecting your NXT 2.0 brick over Bluetooth. In the examples below, the brick is connected at /dev/tty.NXT-DevB:

require 'nxt'

nxt = Nxt.new('/dev/tty.NXT-DevB')

puts "Connecting..."
nxt.connect

puts "Moving what is typically the right wheel one rotation..."
state = OutputState.new :port => :c,
                        :power => 55,
                        :mode_flags => OutputModeFlags.MOTORON | OutputModeFlags.BRAKE,
                        :regulation_mode => :motor_speed,
                        :run_state => :running,
                        :tacho_limit => 360  # degrees = 1 rotation

nxt.set_output_state state
nxt.disconnect