-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpractica.html
executable file
·47 lines (39 loc) · 1.04 KB
/
practica.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>LED RGB</title>
<style>
#led{
width:250px;
height: 250px;
border-radius: 100%;
background: black;
display: block;
}
</style>
</head>
<body>
<div>
<h1>RGB desde Arduino</h1>
<div id="led"></div>
<div id="datos_led"></div>
</div>
<!-- FIREBASE -->
<script src="https://cdn.firebase.com/js/client/2.4.1/firebase.js"></script>
<script>
(function() {
var ref = new Firebase("https://experimentos.firebaseio.com/iot");
ref.on("value", function(snapshot) {
var datos = snapshot.val();
console.log(datos);
document.getElementById("led").style.backgroundColor = 'rgb(' + datos.rojo + ',' + datos.verde + ',' + datos.azul + ')';
document.getElementById("datos_led").innerHTML = "<h3>RGB (" + datos.rojo + ", " + datos.verde + ", " + datos.azul + ")</h3>"
}, function(errorObject) {
document.body.style.display = "";
console.log("ERROR de lectura: " + errorObject.code);
});
})();
</script>
</body>
</html>