Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

For motors / actuators the port has to be one of A, B, C.

Snippet Name and ParametersDescriptionUse onVariable typeRemark

Defined in File

(only relevant for developers)
Example
Clock, millisecondsSets a variable to true for one tick if the time in milliseconds passed since the last time it was set to true.inputboolSee also ResetClock.
timing.ftl
input bool @macro "Clock", "1000" second
ResetClock, clockVariableName, autoFalse

Resets a clock, such that the full time interval 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.

outputboolautoFalse is true per default.
timing.ftl
output bool @macro "ResetClock", "second",  "true" reset
TimeReads the elapsed time since program start (milliseconds)inputint
timing.ftl

input int @macro "Time" timeInMs
TickLoopDuration, 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.

inputint

Should be used on the very first input variable in the model, such that waiting is the last action in the tick loop.

In case the actual tick loop duration is longer than the target duration, the modeler can provide some error handling.

timing.ftl
input int @macro "TickLoopDuration", "1000000" duration
TickWakeUp

Sets the input variable to the current system time (milliseconds). The model can add to this variable to get a new value. This is the next system time the tick function will be called.

In other words, the next tick function call is delayed until the wake up time has been reached.

For instance the statement nextTickWakeUp += 500 could be used to call the tick function again in 500 milliseconds, if nextTickWakeUp is an input with the corresponding annotation.

inputint

Should be used on the very last input variable in the model, such that waiting and settings the system time is the last action done, before the tick function call.

timing.ftl
input int @macro "TickWakeUp" nextTickWakeUp
TickCountCounts the ticks. First tick is 0, the following are 1, 2, 3, ...inputint
timing.ftl

input int @macro "TickCount" ticks
SleepLets the current thread sleep the time in milliseconds of the variable value.outputint
timing.ftl

output int @macro "Sleep" sleep
Print, autoResetPrints 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 printedoutputstringautoReset is true per default.
print.ftlButton
output string @macro "Print", "true" text
DrawString, x, yPrints a string to the given x and y coordinate on the LCD.outputstring
print.ftl

output string @macro "DrawString", "1", "1" text
Button, buttonIdSets a variable to true iff the button on the Mindstorms device is pressed.inputboolThe buttonId has to be one of ENTER, LEFT, RIGHT
touch_and_buttons.ftl
input bool @macro "Button", "ENTER" enterButtonDown
TouchSensor, portSets a variable to true iff the touch sensor on the given port is pressed.inputbool
touch_and_buttons.ftl

input bool @macro "TouchSensor", "S4" touch
LightSensor, port, percentValue

Reads  the value of a light sensor.

If percentValue is true, the a percent value is returned, based on the light sensor calibration.

inputintpercentValue is not available on EV3
light.ftl
input int @macro "LightSensor", "S1" lightLevel
CalibrateLightSensor, port, signalCalibrates 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.outputboolsignal has to be one of High, Lowoutput bool @macro "CalibrateLightSensor", "S1", "Low"
Floodlight, portSets the state of the red lamp of the light sensor.
ftlFloodlight,

output

bool
output bool @macro "Floodlight", "S1" setFloodlight
GetFloodlight, portReads
/ Sets
the state of the red lamp of the light sensor.input
outputlight.ftl
bool
bool

input bool @macro "GetFloodlight", "S1" getFloodlight
RCXLamp, portTurns an RCX lamp on (variable is true) or off (variable is false)outputbool
light.ftl

output bool @macro "RXCLamp", "S2" lamp
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

intbrake is true per default.
motor.ftl
output int @macro "MotorSpeed", "A"
GetMotorSpeed, portAllows to get the current motor speed in degrees.inputint
motor.ftl
MotorIsMoving, portSets a variable to true iff the motor on the given port is moving.inputbool
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.

outputint
motor.ftl
GetMotorRotation, portAllows to get the current motor rotation in degress.inputint
motor.ftl
Beep, volumePlays a beep sound as long as the variable is true.outputbooldefault volume is 10sound.ftl
Buzz, volumePlays a buzz sound as long as the variable is true.outputbooldefault volume is 10sound.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.

outputbool

direction has to be one of Up, Down

default volume is 10

sound.ftl
UltrasonicSensor, portReads the distance that an ultrasonic sensor measures.inputint
ultrasonic.ftl
Gyro, port, modeReads the value of a gyroscope.inputint

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.

outputboolautoReset is true per defaultgyro.ftl


...

Using the Remote Console (RConsole)

...