raspberrypi使用nodejs應用IoT - Linux

By Caroline
at 2016-11-23T11:52
at 2016-11-23T11:52
Table of Contents
各位高手們,小弟剛接觸樹梅派沒多久,如有問蠢問題請原諒
小弟之前有使用過WebIOPi
但是WebIOPi不太穩定,
有時會有奇怪現象產生所以打算用
http://www.instructables.com/id/JavaScript-for-IoT-Blinking-LED-on-Raspberry-P
i-Wi/
這篇文章的教學
他的範例檔中有led.js
我有照他步驟一切都很順利
(執行指令: sudo nodejs led.js)
Led有正常閃爍
但是小弟想要把javascript放在html中 ,
使其他人都可以抓樹梅派所傳的一些感測值
所以小弟就寫了一個簡單測試程式如下:
然後在樹莓派架apache2 的server
使用chrome 瀏覽器打開
window.alert是有正常跳出,
但是LED無法閃爍,
請問各位高手們
小弟是錯在哪或者是哪裡觀念有錯請指導一下,
小弟感激不盡!!
<!DOCTYPE html><html><body>
<h1>test nodjs led blink</h1><p>test nodjs led blink </p>
<script>
window.alert(5 + 6);
var wpi = require('wiring-pi');
// GPIO pin of the ledvar configPin = 7;
// Blinking interval in usec
var configTimeout = 1000;
wpi.setup('wpi');
wpi.pinMode(configPin, wpi.OUTPUT);
var isLedOn = 0;
setInterval(function() {
isLedOn = +!isLedOn;
//isLedOn = !isLedOn;
wpi.digitalWrite(configPin, isLedOn );
}, configTimeout);
</script>
</body></html>
--
小弟之前有使用過WebIOPi
但是WebIOPi不太穩定,
有時會有奇怪現象產生所以打算用
http://www.instructables.com/id/JavaScript-for-IoT-Blinking-LED-on-Raspberry-P
i-Wi/
這篇文章的教學
他的範例檔中有led.js
我有照他步驟一切都很順利
(執行指令: sudo nodejs led.js)
Led有正常閃爍
但是小弟想要把javascript放在html中 ,
使其他人都可以抓樹梅派所傳的一些感測值
所以小弟就寫了一個簡單測試程式如下:
然後在樹莓派架apache2 的server
使用chrome 瀏覽器打開
window.alert是有正常跳出,
但是LED無法閃爍,
請問各位高手們
小弟是錯在哪或者是哪裡觀念有錯請指導一下,
小弟感激不盡!!
<!DOCTYPE html><html><body>
<h1>test nodjs led blink</h1><p>test nodjs led blink </p>
<script>
window.alert(5 + 6);
var wpi = require('wiring-pi');
// GPIO pin of the ledvar configPin = 7;
// Blinking interval in usec
var configTimeout = 1000;
wpi.setup('wpi');
wpi.pinMode(configPin, wpi.OUTPUT);
var isLedOn = 0;
setInterval(function() {
isLedOn = +!isLedOn;
//isLedOn = !isLedOn;
wpi.digitalWrite(configPin, isLedOn );
}, configTimeout);
</script>
</body></html>
--
Tags:
Linux
All Comments

By Queena
at 2016-11-26T01:19
at 2016-11-26T01:19

By Anthony
at 2016-11-29T13:58
at 2016-11-29T13:58

By Puput
at 2016-12-02T01:55
at 2016-12-02T01:55

By Daniel
at 2016-12-04T02:28
at 2016-12-04T02:28

By Puput
at 2016-12-07T19:49
at 2016-12-07T19:49
Related Posts
PING值與網站瀏覽速度的問題請教

By Joseph
at 2016-11-22T21:39
at 2016-11-22T21:39
有辦法在linux mint 18上安裝win7@docker

By Dinah
at 2016-11-22T19:35
at 2016-11-22T19:35
debian找不到miro這個package

By Ingrid
at 2016-11-22T12:56
at 2016-11-22T12:56
Apache

By Poppy
at 2016-11-21T16:45
at 2016-11-21T16:45
灌ubuntu server中mirror設定

By Hedda
at 2016-11-20T23:36
at 2016-11-20T23:36