Created
June 17, 2016 08:19
-
-
Save gishi-yama/ea578d85d47367a0693d42c6741de92a to your computer and use it in GitHub Desktop.
OpenCampus_201606
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//心拍センサーモジュールを用意し、D2ピンの心拍センサーをeehr2という名前で操作できるようにする | |
var groveehr = require('jsupm_groveehr'); | |
var ehr2 = new groveehr.GroveEHR(2); | |
//心拍センサーの動作を開始する | |
ehr2.clearBeatCounter(); | |
ehr2.initClock(); | |
ehr2.startBeatCounter(); | |
//心拍センサーから1秒ごとに生体情報を収集する | |
var millis, beats, hr; | |
var myInterval = setInterval(function () { | |
millis = ehr2.getMillis(); | |
beats = ehr2.beatCounter(); | |
hr = ehr2.heartRate(); | |
console.log("Millis: " + millis + " Beats: " + beats + " Heart Rate: " + hr); | |
}, 1000); | |
// 終了時にセンサーとLCDを停止する | |
process.on('SIGINT', function () { | |
clearInterval(myInterval); | |
ehr2.stopBeatCounter(); | |
groveehr.cleanUp(); | |
console.log("Exiting"); | |
process.exit(0); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//心拍センサーモジュールを用意し、D2ピンの心拍センサーをehr2という名前で操作できるようにする | |
var groveehr = require('jsupm_groveehr'); | |
var ehr2 = new groveehr.GroveEHR(2); | |
//LCDモジュールを用意し、I2CピンのLCDをlcdという名前で操作できるようにする | |
var i2clcd = require('jsupm_i2clcd'); | |
var lcd = new i2clcd.Jhd1313m1(6, 0x3E, 0x62); | |
lcd.setColor(0, 255, 0); | |
lcd.clear(); | |
//心拍センサーの開始 | |
ehr2.clearBeatCounter(); | |
ehr2.initClock(); | |
ehr2.startBeatCounter(); | |
//心拍センサーから1秒ごとに生体情報を収集する | |
var millis, beats, heartRate; | |
var myInterval = setInterval(function () { | |
millis = ehr2.getMillis(); | |
beats = ehr2.beatCounter(); | |
heartRate = ehr2.heartRate(); | |
console.log("Millis: " + millis + " Beats: " + beats + " Heart Rate: " + heartRate); | |
writeToLCD("Heart Rate: " + heartRate); | |
}, 1000); | |
// LCDへの表示 | |
function writeToLCD(str) { | |
lcd.clear(); | |
lcd.setCursor(0, 0); | |
lcd.write(str); | |
} | |
// 終了時にセンサーとLCDを停止する | |
process.on('SIGINT', function () { | |
clearInterval(myInterval); | |
ehr2.stopBeatCounter(); | |
groveehr.cleanUp(); | |
lcd.setColor(0, 0, 0); | |
lcd.clear(); | |
i2clcd.cleanUp(); | |
process.exit(0); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment