pxt-calliope/docs/blocks/logic/if.md

16 lines
367 B
Markdown
Raw Permalink Normal View History

# @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.onButtonEvent(Button.A, input.buttonEventValue(ButtonEvent.Down), () => {
if(input.lightLevel()<100){
led.setBrightness(255);
}
})
```