Created
June 27, 2017 17:57
-
-
Save jhonata-menezes/1efd76409e9c91b9c188d0b351d8f9a0 to your computer and use it in GitHub Desktop.
Utilizando a API de sensor de luz com chrome e android
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title></title> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link href="css/style.css" rel="stylesheet"> | |
</head> | |
<body> | |
Sensor de Luz | |
<br> | |
<div id="out"></div> | |
<script> | |
let sensor = new AmbientLightSensor(); | |
let out = document.getElementById('out') | |
sensor.start(); | |
sensor.onchange = function(event) { | |
out.innerHTML=sensor.illuminance; | |
}; | |
sensor.onerror = function(event) { | |
alert(event.error.name + event.error.message); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment