CS 444 - Week 2 Lab - 2015-01-30
* note that the lejos.nxt package has a class
NXTRegulatedMotor,
with void, no-argument methods
forward()
backward()
and stop()
(which you can read about in the lejos NXJ API
which now has a convenient link from the public
course web page)
* ...there's also a Motor class...
it is 3 named constants and a method (!!)
* Java aside:
for a named constant, you declare it as final
(its first value is its FINAL value -- get it?)
and since you usually (always?) want JUST one copy
of a named constant that's always the same,
a named constant is usually declared as static
as well...
public static final double PI = 3.14159265;
* SO -- NOW you should be able to see (on the leJOS NXJ
API) that Motor declares 3 named constants,
A, B, and C,
...each an NXTRegulatedMotor instance:
public static final NXTRegulatedMotor A;
public static final NXTRegulatedMotor B;
public static final NXTRegulatedMotor C;
...public named constants (that are properly static)
can be used in another class by preceding them with
the class name (as for static methods):
Motor.A
Motor.B
Motor.C
* SO, if I want Motor.A to rotate in a forward
direction, I could write:
Motor.A.forward();
* what are A, B, and C?
...these instances provide access to the motors
connected to the NXT motor ports
(the 3 USB ports labeled A, B, and C on the top
of the brick)
* When you write Motor.A,
you are then referring to whatever motor
you have connected TO the motor port
labeled A on the top of the NXT brick.
* if you have a wheel connected to a motor
connected to motor port A on the top of the
NXT brick,
if you call the forward() method on Motor.A,
then that motor will rotate in a forward direction,
and the wheel connected to that motor will roll
in a forward direction
* on to Project 1 - Stages 3 and 4;