> For the complete documentation index, see [llms.txt](https://computational-thinking-in-room11.gitbook.io/room-112-dhs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://computational-thinking-in-room11.gitbook.io/room-112-dhs/software-development/led-screen/light-levels.md).

# Light Levels

#### The micro:bit measures light levels using the LED Grids - these are both INPUT and OUTPUT devices

The micro:bit will measure the light level and produce numeric value where `0` is complete darkness and `255` is bright sunlight.&#x20;

We want to create a variable to store the value returned by the light sensor

![](/files/-M1W7lll1etkkBcGOzse)

```
On Start
   level = lightlevel 
```

#### The first time you use it, this function will say `0`. After that, it will say the real light level. This is because the light sensor (the part that can find the light level) has to be turned on first.

```
when Button B Pressed
    set level = lightlevel
    show number (level)
```

Now using your hand, your book, or anything else - change the light level and discover how the LED works!!

Get your NETWORK Notebook and make a list of 5 light levels that your micro: bit recorded and the conditions. For example, *full light = 255*

We  can also use the LED's to display a bar chart of the light level

![As you walk around - it will plot the light level changes ](/files/-M1W8H0K_aTHv5Hkge9f)

Get with a partner, one person has a notebook and one person has the micro:bit programmed with the bar graph and a working battery pack. Walk around the classroom, outside, to the front door, to the restroom (P**LEASE Stay UPSTAIRS**) and record where you go - in the order you go there. &#x20;

At each location hit the B Button to return the specific light level at that location

![](/files/-M1WCIXaiPCl8H0PikLK)

Final step: on that same  piece of paper - identify at least two real world uses for a light sensor and explain WHY it might be important to have a real time result of a light reading.&#x20;
