Page 1 of 1

### Is Light Level operational in mu

Posted: Thu Jun 20, 2019 9:12 pm
I am a newbie both to python mu and microbit (although a long time ago I used to program in ALGOL and FORTRAN before basic came along).

I believe that I have made a stupid mistake.

In the https://microbit-micropython.readthedocs.io/en/latest/ a search for light_level
gave an entry entry microbit.display.read_light_level()

I have written a simple program
\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$
from microbit import *
import microbit

temp = microbit.temperature()
print(temp)
microbit.display.scroll(str(temp))
print(llevel)
\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$\$

When run this gives the output (when no torch shone on the microbit)
>>> 20
0
MicroPython v1.9.2-34-gd64154c73 on 2017-09-01; micro:bit v1.0.1 with nRF51822
When run again this gives the output (when a torch shone on the microbit)
>>> 20
230
MicroPython v1.9.2-34-gd64154c73 on 2017-09-01; micro:bit v1.0.1 with nRF51822
>>>

obviously
1 The temperature (20) is output correctly on both REPL and the display
2 The value 0 or 230 printed are the light levels.
3 Nothing is output to the display after 20 is printed out

Now does anyone know how to get the value light-level into a variable?

### Re: Is Light Level operational in mu

Posted: Fri Jun 21, 2019 12:00 am
It looks like your code does put the light level into a variable "llevel", but the code never actually puts that on the screen? Sounds like you're missing

Code: Select all

``````microbit.display.scroll(str(llevel))
``````
(btw, I think you don't need the "str" anymore, i believe they made it so display.scroll/show convert automatically)