|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pt.citar.diablu.processing.nxt.LegoNXT
public class LegoNXT
The LegoNXT class allows you to control the Mindstorms NXT robotic system. The NXT must have been paired using Bluetooth and you must know the name of the virtual COM port assigned (COM1, COM2, or something like that).
Field Summary | |
---|---|
static int |
ACTIVE
The active light sensor type. |
static int |
BLUE
The blue color sensor type. |
static int |
FULL
The full color sensor type. |
static int |
GREEN
The green color sensor type. |
static int |
INACTIVE
The inactive light sensor type. |
static int |
MOTOR_A
The motor port A. |
static int |
MOTOR_B
The motor port B. |
static int |
MOTOR_C
The motor port C. |
static int |
NONE
The none color sensor type. |
static int |
PORT_1
The sensor port 1. |
static int |
PORT_2
The sensor port 2. |
static int |
PORT_3
The sensor port 3. |
static int |
PORT_4
The sensor port 4. |
static int |
RED
The red color sensor type. |
Constructor Summary | |
---|---|
LegoNXT(PApplet parent,
String commPort)
Creates a new instance of LegoNXT |
Method Summary | |
---|---|
void |
dispose()
|
int |
getBatteryLevel()
Returns the battery level. |
boolean |
getButtonState(int portNumber)
Returns the state of the pressure sensor at the specifiec port. |
int |
getColor(int portNumber)
Returns the color level from the color sensor attached to the specified port. |
int |
getDB(int portNumber)
Gets the DB level of the sound sensor on the specified port. |
int |
getDistance(int portNumber)
Returns the proximity to an obstacle, measured by the ultrasonic sensor. |
int |
getLight(int portNumber)
Returns the light level from the light sensor attached to the specified port. |
long |
getMotorBlockTachoCount(int motorNumber)
Returns the current position realative to the last programmed movement. |
long |
getMotorRotationCount(int motorNumber)
The current position relative to the last reset of the rotation sensor for this motor. |
long |
getMotorTachoCount(int motorNumber)
Returns number of counts since last reset of the motor counter. |
long |
getMotorTachoLimit(int motorNumber)
Returns the current limit on a movement in progress. |
boolean |
motorForward(int motorNumber,
int power)
Sets the power to the specified motor. |
boolean |
motorForwardLimit(int motorNumber,
int power,
int tachoLimit)
Make the motor run for a specifiec amount of time. |
boolean |
motorHandBrake(int motorNumber)
Stops the motor abruptely. |
boolean |
motorStop(int motorNumber)
Stops the motor smoothely. |
boolean |
playTone(int frequency,
int duration)
Plays a tone on the NXT. |
String |
receiveMsg(int mailbox,
boolean remove)
Reads a BT message to the NXT. |
void |
resetMotorPosition(int motorNumber,
boolean relative)
Resets the motor position. |
boolean |
sendMsg(int mailbox,
String message)
Sends a BT message to the NXT. |
void |
setColorSensorType(int type,
int portNumber)
Sets the type of color sensor to be used on the specifiec port. |
void |
setLightSensorType(int type,
int portNumber)
Sets the type of light sensor to be used on the specifiec port. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MOTOR_A
public static final int MOTOR_B
public static final int MOTOR_C
public static final int PORT_1
public static final int PORT_2
public static final int PORT_3
public static final int PORT_4
public static final int ACTIVE
public static final int INACTIVE
public static final int FULL
public static final int RED
public static final int GREEN
public static final int BLUE
public static final int NONE
Constructor Detail |
---|
public LegoNXT(PApplet parent, String commPort)
parent
- The PApplet. Use this
.commPort
- The COM port where you connected the NXT. This is the name
of the virtual COM port that was assigned to the NXT.Method Detail |
---|
public boolean playTone(int frequency, int duration)
frequency
- The frequency of the tone.duration
- The duration, in milliseconds, of the tone.
public boolean sendMsg(int mailbox, String message)
mailbox
- numbermessage
- The message string
public String receiveMsg(int mailbox, boolean remove)
mailbox
- Int mailbox numberremove
- Boolean; true clears message from remote inbox
public boolean motorForward(int motorNumber, int power)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.power
- The power of the motor (-100, 100). Positive values make
the motor fo forward, negative values make it go backwards.
public boolean motorForwardLimit(int motorNumber, int power, int tachoLimit)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.power
- The power of the motor (-100, 100). Positive values make
the motor fo forward, negative values make it go backwards.tachoLimit
- The tacho limit on the motor. Haven't figured this out completely...
public boolean motorHandBrake(int motorNumber)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.
public boolean motorStop(int motorNumber)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.
public long getMotorTachoLimit(int motorNumber)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.
public long getMotorTachoCount(int motorNumber)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.
public long getMotorBlockTachoCount(int motorNumber)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.
public long getMotorRotationCount(int motorNumber)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.
public void resetMotorPosition(int motorNumber, boolean relative)
motorNumber
- The motor port (0, 1 or 2). The constants MOTOR_A,
MOTOR_B and MOTOR_C should be used.motorNumber
- public boolean getButtonState(int portNumber)
portNumber
- The port number on which the pressure sensor is
connected (the constants PORT_1, PORT_2, PORT_3 or PORT_4 should be used).
public int getDB(int portNumber)
portNumber
- The port number on which the pressure sensor is
connected (the constants PORT_1, PORT_2, PORT_3 or PORT_4 should be used).
public int getLight(int portNumber)
portNumber
- The port number on which the pressure sensor is
connected (the constants PORT_1, PORT_2, PORT_3 or PORT_4 should be used).
public void setLightSensorType(int type, int portNumber)
type
- The type of light sensor (ACTIVE or INACTIVE).portNumber
- The port number on which the pressure sensor is
connected (the constants PORT_1, PORT_2, PORT_3 or PORT_4 should be used).public int getColor(int portNumber)
portNumber
- The port number on which the pressure sensor is
connected (the constants PORT_1, PORT_2, PORT_3 or PORT_4 should be used).
public void setColorSensorType(int type, int portNumber)
type
- The type of color sensor (FULL or RED or GREEN or BLUE or NONE or RGB).portNumber
- The port number on which the pressure sensor is
connected (the constants PORT_1, PORT_2, PORT_3 or PORT_4 should be used).public int getDistance(int portNumber)
portNumber
- The port number on which the pressure sensor is
connected (the constants PORT_1, PORT_2, PORT_3 or PORT_4 should be used).
public int getBatteryLevel()
public void dispose()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |