pxt-calliope/docs/reference/input/light-level.md

31 lines
778 B
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Light Level
Gets the light level from ``0`` (dark) to ``255`` (bright). The light is measured by using various LEDs from the screen.
This function will return ``0`` on the first call to this method, a light reading will be available after the display has activated the light sensor for the first time.
```sig
input.lightLevel();
```
### Returns
2016-04-13 17:27:45 +02:00
* [Number](/reference/types/number) - light level from ``0`` (dark) to ``255`` (bright).
2016-03-26 00:47:20 +01:00
### Example: chart light level
Use `plot bar chart` to visual the influence of various light source on the light level.
```blocks
basic.forever(() => {
led.plotBarGraph(input.lightLevel(), 255)
})
```
### Lessons
### See also
2016-04-18 18:47:34 +02:00
[acceleration](/reference/input/acceleration), [compass-heading](/reference/input/compass-heading)
2016-03-26 00:47:20 +01:00