-
Notifications
You must be signed in to change notification settings - Fork 0
/
week9_web_interface.html
57 lines (45 loc) · 1.64 KB
/
week9_web_interface.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
47
48
49
50
51
52
53
54
55
56
57
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>PHYS S-12: Introduction to Digital Fabrication</title>
</head>
<body>
<button id="turn-on" name="turnon">Turn On</button>
<button id="turn-off" name="turnoff">Turn Off</button>
<!-- The core Firebase JS SDK is always required and must be listed first -->
<script src="https://www.gstatic.com/firebasejs/8.7.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.7.1/firebase-database.js"></script>
<script>
// Your web app's Firebase configuration
var firebaseConfig = {
apiKey: "AIzaSyCSU4eqfmjl8ct1_muq15jY_HvgewOl5hc",
authDomain: "acontroller-aadb8.firebaseapp.com",
databaseURL: "https://acontroller-aadb8-default-rtdb.europe-west1.firebasedatabase.app",
projectId: "acontroller-aadb8",
storageBucket: "acontroller-aadb8.appspot.com",
messagingSenderId: "294278776633",
appId: "1:294278776633:web:86f36875c9717fda658ae8"
};
// Initialize Firebase
firebase.initializeApp(firebaseConfig);
// Get a database reference to our blog
var ref = firebase.database().ref("/");
// make the buttons call the function below
document.getElementById('turn-on').addEventListener('click', turnOn, false);
document.getElementById('turn-off').addEventListener('click', turnOff, false);
function turnOn(){
console.log("turning on");
ref.update({
"LED_STATUS": "ON"
});
}
function turnOff(){
console.log("turning off");
ref.update({
"LED_STATUS": "OFF"
});
}
</script>
</body>