Page History
...
There are several wrapper code snippets that can be used as annotations on input and output variables in the model file. These snippets are inserted in the main file template as part of the project launch. The available snippets are listed below.
For sensors, the port has to be on of S1, S2, S3, S4.
For motors / actuators the port has to be one of A, B, C, D.
Snippet Name and Parameters | Description | Use on | Variable type | Remark | Defined in File |
---|---|---|---|---|---|
Clock, milliseconds | Sets a variable to true if the time in milliseconds passed | input | bool | See also ResetClock. | timing.ftl |
ResetClock, clockVariableName, autoFalse | Resets a clock, such that the full time intervall of the clock has to elapse, before the clock will be set to true again. If autoFalse is true, the reset variable will be set to false automatically. | output | bool | autoFalse is true per default. | timing.ftl |
Time | Reads the elapsed time since program start | input | int | timing.ftl | |
TickDuration, targetInMilliseconds | Delays the execution until the tick loop takes at least as long as the given target duration. The input variable is set to the actual tick loop duration. | input | int | Should be used on the very first input variable in the model, such that waiting is the last action in the tick loop. | timing.ftl |
Sleep | Lets the current thread sleep the time in milliseconds of the variable value. | output | int | timing.ftl | |
Print, autoReset | Prints a string variable if the string is not empty. If autoReset is true then the string variable is set to the empty string after it has been printed | output | string | autoReset is true per default. | print.ftl |
DrawString, x, y | Prints a string to the given x and y coordinate on the LCD. | output | string | print.ftl | |
Button, buttonId | Sets a variable to true iff the button on the Mindstorms device is pressed. | input | bool | The buttonId has to be one of ENTER, LEFT, RIGHT | touch_and_buttons.ftl |
TouchSensor, port | Sets a variable to true iff the touch sensor on the given port is pressed. | input | bool | touch_and_buttons.ftl | |
LightSensor, port, percentValue | Reads the value of a light sensor. If percentValue is true, the a percent value is retured, based on the light sensor calibration. | input | int | percentValue is not available on EV3 | light.ftl |
CalibrateLightSensor, port, signal | Calibrates a light sensors high or low values. This means if the variable is true, the current value of the light sensor is taken as its reference high / low value. | output | bool | signal has to be one of High, Low | light.ftl |
Floodlight, port | Reads / Sets the state of the red lamp of the light sensor. | input output | bool | light.ftl | |
RCXLamp, port | Turns an RCX lamp on (variable is true) or off (variable is false) | output | bool | light.ftl | |
MotorSpeed, port, brake | Reads / Sets the speed of the motor in degrees per minute. If the speed value is negative, the motor will drive backwards. If the speed is zero, the motor will actively brake until it stops (brake is true) or remove all power and rollout (brake is false). | input output | int | brake is true per default. | motor.ftl |
MotorIsMoving, port | Sets a variable to true iff the motor on the given port is moving. | input | bool | motor.ftl | |
MotorRotation, port | Lets a motor rotate the variable value in degrees. This is only done if the value is unequal zero. If the value is negative, the motor rotates backwards. The variable is set to zero afterwards, such that setting the variable once to a value X, will let the motor rotate X degrees. | output | int | motor.ftl | |
Beep, volume | Plays a beep sound as long as the variable is true. | output | bool | default volume is 10 | sound.ftl |
Buzz, volume | Plays a buzz sound as long as the variable is true. | output | bool | default volume is 10 | sound.ftl |
BeepSequence, direction, volume | Plays a sequence of tones in either ascending or descending tone frequency if the variable is true. The variable is set to false automatically. | output | bool | direction has to be one of Up, Down default volume is 10 | sound.ftl |
UltrasonicSensor, port | Reads the distance that an ultrasonic sensor measures. | input | int | ultrasonic.ftl | |
Gyro, port, mode | Reads the value of a gyroscope. | input | int | Not available on NXT mode hat to be one of Angle, Rate | gyro.ftl |
CalibrateGyro, port, autoReset | Resets a gyroscope if the variable is true. If autoReset is true, the variable is set to false automatically. | output | bool | autoReset is true per default | gyro.ftl |
...
Using the Remote Console (RConsole)
...