30 lines
734 B
Markdown
Raw Normal View History

2016-03-25 16:47:20 -07:00
# If
2016-04-01 16:22:47 -07:00
Run code based on a condition.
2016-03-25 16:47:20 -07:00
### @parent blocks/language
2016-04-13 08:27:45 -07:00
Conditionally run code depending on whether a [Boolean](/reference/types/boolean) condition is true or false.
2016-03-25 16:47:20 -07:00
### Block Editor
![](/static/mb/hourofcode-0.png)
In the Block Editor, click on the dark blue gear icon (see above) to add an *else* or *if* to the current block.
### Example: adjusting screen brightness
![](/static/mb/blocks/game-library/pic0.png)
2016-04-13 08:27:45 -07:00
If the screen [brightness](/reference/led/brightness) is `< 100`, this code sets the brightness to `255`:
2016-03-25 16:47:20 -07:00
### Lessons
2016-04-13 08:27:45 -07:00
[love meter](/lessons/love-meter), [zoomer](/lessons/zoomer)
2016-03-25 16:47:20 -07:00
### See also
2016-04-13 08:27:45 -07:00
[while loop](/reference/loops/while), [for](/reference/loops/for), [boolean](/reference/types/boolean)
2016-03-25 16:47:20 -07:00