Module Commands
In: lib/commands.rb

Command object based interface that implements the "blocks" in NXT-G. This should be easy to understand if you are familiar with the NXT-G graphical programming system. This is automatically included in NXTComm.

Example

  require 'nxt_comm'

  @nxt = NXTComm.new('/dev/tty.NXT-DevB-1')

  # more examples can be found in examples/commands.rb

  us = Commands::UltrasonicSensor.new(@nxt)
  us.mode = :centimeters
  puts "Distance: #{us.distance}cm"
  us.mode = :inches
  puts "Distance: #{us.distance}in"

  us.comparison = "<"
  us.trigger_point = 5

  while us.logic == false
    sleep(0.5)
    puts "Move #{us.comparison} #{us.trigger_point} #{us.mode} from the sensor..."
    puts "Distance: #{us.distance}in"
  end

  puts "Got it!"

Classes and Modules

Class Commands::LightSensor
Class Commands::Motor
Class Commands::Move
Class Commands::RotationSensor
Class Commands::Sound
Class Commands::SoundSensor
Class Commands::TouchSensor
Class Commands::UltrasonicSensor

[Validate]