Webduino 資料上雲端
Step 01
by jywglady
HTML
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Webduino Lesson 01 - step 01">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<head>
<title>Webduino Lesson 01</title>
<script src="https://blocklypro.webduino.io/components/jquery/dist/jquery.min.js?rev=4a356126b9573eb7bd1e9a7494737410"></script>
<script src="https://blocklypro.webduino.io/dist/lib/webduino-all-0.4.20.min.js?rev=4426739c00d85325cb2d3d701fa50666"></script>
<script src="https://blocklypro.webduino.io/dist/webduino-blockly.min.js?rev=6a9037f813da79372168951bbfeafb49"></script>
<script src="https://blocklypro.webduino.io/dist/lib/firebase.min.js?rev=c0bfd493efd477d098a4ae9e92b13880"></script>
<script src="https://blocklypro.webduino.io/dist/lib/runtime.min.js?rev=683a69503433786202911b4d9f766100"></script>
</head>
<title>Webduino Lesson 01</title>
</head>
<body>
<h1>Webduino 數據上雲端</h1>
您好,設備的亮度值為:<span id="lightvalue">尚未連線</span>
</body>
</html>
CSS
h1 {
background: blue;
color: white;
font-size: 200%;
padding: 12px;
text-align: center;
}
span {
background: orange;
color: blue;
padding: 3px 6px;
margin: 0 2px;
}
body {
text-align: center;
}
JavaScript
var photocell;
boardReady({board: 'Smart', device: 'EjVbk', transport: 'mqtt', multi: true}, function (board) {
board.samplingInterval = 1000;
photocell = getPhotocell(board, 0);
photocell.measure(function (val) {
photocell.detectedVal = val;
document.getElementById('lightvalue').innerHTML = photocell.detectedVal;
});
});