Skip to content

Instantly share code, notes, and snippets.

@leo424y
Created June 11, 2015 05:47
Show Gist options
  • Save leo424y/7216c1e3ba49e62ce474 to your computer and use it in GitHub Desktop.
Save leo424y/7216c1e3ba49e62ce474 to your computer and use it in GitHub Desktop.
溫溼度傳感器 // source http://jsbin.com/zudaso
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>溫溼度傳感器</title>
<script src="http://webduino.io/components/webcomponentsjs/webcomponents.js"></script>
<link rel='import' href='http://webduino.io/components/webduino/web-arduino.html' />
<link rel='import' href='http://webduino.io/components/webduino/wa-dht.html' />
<style id="jsbin-css">
body{
margin-top:100px;
font-size:30px;
}
</style>
</head>
<body>
<div id="show"></div>
<web-arduino id='board' device="MpEB">
<wa-dht id='dht' pin='10'></wa-dht>
</web-arduino>
<script id="jsbin-javascript">
window.addEventListener('WebComponentsReady', function () {
var board = document.getElementById('board');
board.on('ready',function ready() {
var dht = document.getElementById('dht'),
show = document.getElementById('show');
dht.read(function (evt) {
show.innerHTML = new Date().toLocaleString() + "<br>溫度:" + evt.temperature + " ℃<br> 溼度:" + evt.humidity + " %";
}, 10000);
}, false);
}, false);
</script>
<script id="jsbin-source-css" type="text/css">body{
margin-top:100px;
font-size:30px;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">window.addEventListener('WebComponentsReady', function () {
var board = document.getElementById('board');
board.on('ready',function ready() {
var dht = document.getElementById('dht'),
show = document.getElementById('show');
dht.read(function (evt) {
show.innerHTML = new Date().toLocaleString() + "<br>溫度:" + evt.temperature + " ℃<br> 溼度:" + evt.humidity + " %";
}, 10000);
}, false);
}, false);</script></body>
</html>
body{
margin-top:100px;
font-size:30px;
}
window.addEventListener('WebComponentsReady', function () {
var board = document.getElementById('board');
board.on('ready',function ready() {
var dht = document.getElementById('dht'),
show = document.getElementById('show');
dht.read(function (evt) {
show.innerHTML = new Date().toLocaleString() + "<br>溫度:" + evt.temperature + " ℃<br> 溼度:" + evt.humidity + " %";
}, 10000);
}, false);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment