This commit is contained in:
Juri
2020-08-19 22:03:58 +02:00
parent 4ef7b9318f
commit 3152215415
291 changed files with 9511 additions and 2966 deletions

View File

@ -0,0 +1,30 @@
# @extends
## #examples
## Example: ``AND`` operator
This example turns on LED `3 , 3`, if LEDs `1 , 1` and `2 , 2` are both on:
```blocks
if (led.point(1,1) && led.point(2,2)) {
led.plot(3,3)
}
```
## Example: Comparisons of numbers and strings
When you compare two Numbers, you get a Boolean value, such as the comparison `x < 5` in the code below:
```blocks
input.onButtonPressed(Button.A, () => {
let x = randint(0, 5)
if(x < 5) {
basic.showString("low");
} else {
basic.showString("high");
}
})
```
See the documentation on [Numbers](/types/number) for more information on comparing two Numbers.

15
docs/blocks/logic/if.md Normal file
View File

@ -0,0 +1,15 @@
# @extends
## #examples
## Example: adjusting screen brightness
If the [light level](/reference/input/light-level) is `< 100`, this code sets the brightness to `255` when the button A is pressed:
```blocks
input.onButtonPressed(Button.A, () => {
if(input.lightLevel()<100){
led.setBrightness(255);
}
})
```