1 2 3 4 5 6 7 8 9 10 11
<!DOCTYPE HTML> <meta charset="utf-8"> <input type="text" id="reading" /> <script> let sensor = new AmbientLightSensor(); sensor.start(); document.getElementById("reading").value = String(sensor.reading); sensor.stop(); </script>