Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

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

For sensors, the port has to be on of S1, S2, S3, S4.

Snippet Name and ParametersDescriptionUse onVariable typeRemarkExample
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.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.output bool @macro "ResetClock", "second",  "true" reset
TimeReads the elapsed time since program start (milliseconds)inputint
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.

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.

input int @macro "TickWakeUp" nextTickWakeUp
TickCountCounts the ticks. First tick is 0, the following are 1, 2, 3, ...inputint
input int @macro "TickCount" ticks
SleepLets the current thread sleep the time in milliseconds of the variable value.outputint
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.output string @macro "Print", "true" text
DrawString, x, yPrints a string to the given x and y coordinate on the LCD.outputstring
output string @macro "DrawString", "1", "1" text
DrawInt, x, yPrints a interger to the given x and y coordinate on the LCD.outptuint
output int @macro "DrawInt", "1", "1" number
Button, buttonIdSets a variable to true iff the button on the Mindstorms device is pressed.inputboolThe buttonId has to be one of ENTER, LEFT, RIGHTinput bool @macro "Button", "ENTER" enterButtonDown
TouchSensor, portSets a variable to true iff the touch sensor on the given port is pressed.inputbool
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 EV3input 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" calibrateLow
Floodlight, portSets the state of the red lamp of the light sensor.

output

bool
output bool @macro "Floodlight", "S1" setFloodlight
GetFloodlight, portReads the state of the red lamp of the light sensor.inputbool
input bool @macro "GetFloodlight", "S1" getFloodlight
RCXLamp, portTurns an RCX lamp on (variable is true) or off (variable is false)outputbool
output bool @macro "RCXLamp", "A" lamp
MotorSpeed, port, brakeSets the speed of the motor in degrees per second. Maximum is 900. 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).

output

intbrake is true per default.output int @macro "MotorSpeed", "A", "false" motorA
GetMotorSpeed, portAllows to get the current motor speed in degrees.inputint
input int @macro "GetMotorSpeed", "A" getMotorA
MotorIsMoving, portSets a variable to true iff the motor on the given port is moving.inputbool
input bool @macro "MotorIsMoving", "A" isMotorAMoving
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
output int @macro "MotorRotation", "A" rotateInDegrees
GetMotorRotation, portAllows to get the current motor rotation in degress.inputint
input int @macro "GetMotorRotation", "A" rotationA
MotorRotationSpeed, portSets the speed of a motor without rotation it. This speed will be used by MotorRotation.outputint
output int  @macro "MotorRotationSpeed", "A" rotationSpeed
Beep, volumePlays a beep sound as long as the variable is true.outputbooldefault volume is 10output bool @macro "Beep", "10" beep
Buzz, volumePlays a buzz sound as long as the variable is true.outputbooldefault volume is 10output bool @macro "Buzz", "10" buzz
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

output bool @macro "BeepSequence", "10" beepSequence
PlayTone, frequency, duration, volumePlays the tone specified by frequency (e.g. 440 is an A), duration and volume. Duration and volume are optional and will be set to 100 if not defined.outputboolDefault duration and volume is 100

ouput bool @macro "PlayTone", "440", "100", "10" A4

PlayFrequency, duration, volumePlays the tone specified by frequency (the value of the varibale e.g. 440 is an A), duration and volume. Duration and volume are optional and will be set to 100 if not defined. Used frequency will be used as default frequency for next toneoutputintDefault duration and volume is 100ouput int @macro "PlayFrequency", "100" A4
VolumeSets the volume for sound output.outputint
ouput int @macro "Volume" volume
UltrasonicSensor, portReads the distance that an ultrasonic sensor measures.inputint
input int @macro "UltrasonicSensor", "S3" ultraSonic
Gyro, port, modeReads the value of a gyroscope.inputint

Not available on NXT

mode hat to be one of Angle, Rate

input int @macro "Gyro", "S3", "Angle" gyro
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 defaultoutput bool @macro "CalibrateGyro", "S3", "true" calibrateGyro
  • No labels