Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
29 views

PoweredUp ProgrammingBlocks

Uploaded by

probephone79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

PoweredUp ProgrammingBlocks

Uploaded by

probephone79
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Guide to LEGO® Powered Up programming blocks

The LEGO® Powered Up app features a simple, easy-to-understand programming language


that fans of all ages will enjoy learning and experimenting with. It’s based around a core
experience any LEGO fan will understand instinctively – stacking blocks next to one another
and watching them snap into place.

Programming blocks come in a range of types and colors to tell you what type of block
you’re using.

Here are some examples of commonly used programming blocks. If you’re not sure what a
block does and it’s not listed here, why not try it out in the app? Part of the fun of LEGO
Powered Up is in the experimentation, play, and learning.

Yellow Flow Blocks


Yellow blocks control the flow of your commands. You can use them to start a program,
stop a program, pause a program or even loop commands.

This block starts the program.

This block will start the program if a True condition is


met.

This block starts the program when the condition


switches from False to True.

This block starts the attached code sequence when


the flag number is triggered.
This block triggers a flag number.

This hourglass block will make the program wait for a


specified number of seconds.

This hourglass block will wait for the condition to be


True.

This block will loop the program section for a set


number of times.

This block will loop the program while a condition is


true.

This block will loop the program forever!

This block will run the top sequence if the condition is


True. If the top sequence isn’t True, it will run the
bottom sequence.

This block runs both sequences at the same time and


waits for both sequences to finish before running the
next block.
This block stops all other program sequences and
continues running the attached code sequence.

This block stops all sequences running on the current


canvas. If it’s used in the top program, this will end the
program. If it’s used in a Model Block and the Model
Block is ended, the program containing the Model
Block will continue running.

Orange Sensor Blocks


Orange blocks work with the Color and Distance Sensor, the Move Hub’s Tilt
Sensor, remote control and WeDo 2.0 sensors. These blocks will trigger an action
when a sensor on your model detects something.

Use the Color sensor to trigger an event when a specific color is


sensed.

This block tells the program to wait for the color sensor to detect the
color chosen in the block.

Get current color measured by the sensor.

Get current ambient light level measured by the sensor.


Triggers when the distance measured by the sensor is less than the
specified distance.

Get current distance measured by the sensor.

Wait for the distance measured by the Sensor to be less than the
specified distance.

Get current force measured by the sensor and affect connected block
functions.

Use internal Gyroscope to trigger an event based on Orientation of the


hub.

Wait for the Hub orientation to be equal to Hub orientation.

Get tilt orientation of the hub.

Get X angle position of the hub.


Get Y angle position of the hub.

Get the angle of the specified axis on a tilt sensor.

Get the specified axis on an internal accelerometer/tilt sensor of a hub.

Sets the tilt orientation.

Just for WeDo sensors - Measure distance

Just for WeDo sensors. Get current WeDo sensor tilt angle on the Y
axis (-90/90).

Just for WeDo sensors. Get current WeDo sensor tilt angle on the X
axis (-90/90).
Uses the X axis tilt position of the smart device (left-right). 0 is the
central position.

Uses the Y axis tilt position of the smart device (forward to backward).
0 is around 30 degrees with the device screen facing you.

Detects the button pressed on the A or B side of the connected


remote.

Green Motor or Movement Blocks


Green blocks get your model moving! You can differentiate between tacho motors
(For controlling speed and position) and basic motors (To drive full speed).

Sets power to the motor. Positive numbers rotate


clockwise, and negative numbers rotate counterclockwise.

Removes power from the motor and will slowly stop the
motors.

Stops the motor.


Reads the speed value of the tacho motor attached to the
specified port.

Makes a tacho motor run at a specified speed on a given


port.

Makes a tacho motor run on a specified port, at a specified


speed for a specified duration (in seconds).

Reads the position of the tacho motor. Position is relative.


0 is the position where the motor was turned on.

Turns the tacho motor on a defined port at a defined


speed with the defined degree.

Turns the tacho motor on a defined port at a defined


speed with the defined degree.

Sets the current position of the tacho motor on a defined


port to the defined value.
Stops and holds the tacho motor on a defined port.

This block is used to set the maximum power that a tacho


motor should reach on a defined port.

Sets the power of a pair of tacho motors on the defined


ports, independently.

Set the speed of a pair of tacho motors on the defined


ports, independently.

Sets the speed of a pair of tacho motors on the defined


ports for duration (in seconds), independently.

Sets the position of a pair of tacho motors on the defined


ports with speed set independently.

Sets the speed of a pair of tacho motors on the defined


ports (AB or CD) with the steering direction defining a tank
steering style behavior. 0 sets equal power to both
outputs, 50 only powers one motor and 100 powers the
motors in opposite directions. Positive-negative value for
steering defines the direction.
Sets the speed of a pair of tacho motors on the defined
ports (AB or CD) with the steering direction defining a tank
steering style behavior. The motors run for the defined
duration (in seconds). 0 sets equal power to both outputs,
50 only powers one motor and 100 powers the motors in
opposite directions. Positive-negative value for steering
defines the direction.

Sets the speed of a pair of tacho motors on the defined


ports with the steering direction defining a tank steering
style behavior. The motors run until the defined rotation
degree is reached. 0 sets equal power to both outputs, 50
only powers one motor and 100 powers the motors in
opposite directions. Positive negative value for steering
defines the direction.

Sets a tacho motor on the defined port to the given


position in degrees.

Sets power to the motor attached to the selected port and


runs until the program runs without the need of a loop.
Positive numbers rotate clockwise, and negative numbers
rotate counterclockwise.

Sets the acceleration duration (in seconds) of the tacho


motor on a defined port.

Sets the deceleration duration (in seconds) of the tacho


motor on a defined port.
Purple Sound and Light Blocks
Purple blocks can play sounds through your device’s speakers, change the color of
the lights on the move hub, color and distance sensors. These blocks also control
the lights on the LED-light.

Sets the mode of the color and distance sensor connected


to the defined port. 8 is the default value when
connected, 7 is the infrared mode.

Sets the color of the sensor LED.

Sets the hub LED to show color.

Sets the light brightness on the connected to the specified


port.

Sets the light brightness on the connected to port (left


parameter) but sets the four LED half-circles on the sensor
individually.

From left to right, they affect

 Right "eye" upper arc


 left "eye" upper arc
 right "eye" lower arc
 left "eye" lower arc

Sends IR commands to the power function’s IR receiver


with the color and distance sensor connected to the
defined port. The first input slot is the port where the
sensor is attached. The second is the IR channel used from
0 to 3 matching IR port 1 to 4. The third defines multiple
things but for basic use, set 4 to control the red port and 5
to control the blue port. The fourth sets the speed, 0 is
float (no speed), 1 to 7 is increasing speed forward, 8 is
stop, and 9 to F is decreasing speed backwards.

Sets the hub LED to show color based on the RGB


intensity defined (red, green, and blue value in %).

Plays the selected sound from the house sound library.

Plays the selected sound from the whistle sound library.

Plays the selected sound from the train sound library.

Plays the selected sound from the car sound library.

Plays the selected sound from the plane sound library.

Plays the selected sound from the dog sound library.


Plays the selected sound from the cat sound library.

Plays the selected sound from the fart sound library.

Plays the selected sound from the horn sound library.

Plays the selected sound from the crowd sound library.

Plays the selected sound from the robot sound library.

Plays the selected sound from the target sound library.

Light Grey Math blocks


Light grey blocks allow for some complex programming using variables.

Select a specific hub in the left slot and output the port used for
that hub in right slot.
Reads the number stored in the local variable.

Update local variable to stored number.

Reads the number stored in the global variable.

Update global variable to stored number.

Outputs a random number between number and number (both


numbers included in range).

Returns whether number is equal to number.

Returns whether number is less than number.

Returns whether number is greater than number.


Returns whether number is not equal to number.

Returns true if both operands are true, and false otherwise

Example: Returns true of both input values (left and right) are true,
and false otherwise.

Returns true if either operand is true, and false otherwise

Returns the result of adding number to number.

Returns the result of number subtracted with number.

Returns the result of number multiplied with number.

Return the result of number divided by number.

Return an adorner with multiple math operations.

Example: Returns a value from math operator (left slot) and


numerical value (right slot).
Returns a numeric value between -π and π representing the angle
of an (left slot, right slot) point.

Return the power of the left input powered with the right.

Return the highest of the values.

Return the lowest of the values.

Divides left with right and gives the remainder from that
operation.

Teal Widget Blocks


Teal blocks let you control your model via widgets.

Reports the state (true/false or 0/1) of the widget canvas' button


widget with Channel-ID (1st parameter).

Reports the state (true/false or 0/1) of the Widget Canvas' toggle


widget with Channel-ID (1st parameter).
Reports the state of the widget canvas' multibuttoned widget with
Channel-ID (1st parameter), as an axis. This means: If the lower button
is pressed, it reports -100. If the upper one is pressed, it reports 100. If
neither is pressed, it reports 0.

Instructs the widget canvas' speedometer, integer-display or any other


display with Channel-ID (1st parameter) to show the value (2nd
parameter).

Reports the position (-100 to 100) of the widget canvas' joystick


widget with Channel-ID (1st parameter). The axis is chosen by (2nd
parameter): If it's 0, the block will report the horizontal axis. If it's 1, the
block will report the vertical axis. Any other value will stop the block
from reporting values.

Reports the position (- 100 to 100) of the widget canvas' slider widget
with Channel-ID (1st parameter).

Reports the amplitude (- 100 to 100) of the widget canvas' joystick


widget with Channel-ID (1st parameter).

The further away the joystick is pulled from the center, the higher the
number will be. In the upper half of the joystick, the numbers reported
will be positive. In the lower half, they’ll be negative.

Reports the angle (normalized to -100 to 100 not in degrees, which


would be -90 to 90!) of the widget canvas' joystick widget with
Channel-ID (1st parameter).

If the joystick points directly up or down (regardless of amplitude), the


block outputs 0. If the joystick's handle is then motioned clockwise,
the number will become negative and decrease until it reaches -100 at
directly left or right. If rotated counterclockwise, the number is
positive and increases towards 100.

You might also like