diff options
Diffstat (limited to 'code')
-rw-r--r-- | code/001-blink.js | 4 | ||||
-rw-r--r-- | code/002-button.js | 4 | ||||
-rw-r--r-- | code/003-dht22.js | 5 | ||||
-rw-r--r-- | code/004-display.js | 11 |
4 files changed, 20 insertions, 4 deletions
diff --git a/code/001-blink.js b/code/001-blink.js index 408aeb4..7e4926d 100644 --- a/code/001-blink.js +++ b/code/001-blink.js @@ -1,5 +1,5 @@ -var on = false; +var on = false; setInterval(function() { on = !on; LED1.write(on); -}, 500);
\ No newline at end of file +}, 500); diff --git a/code/002-button.js b/code/002-button.js index e98ace2..7fff372 100644 --- a/code/002-button.js +++ b/code/002-button.js @@ -1,7 +1,7 @@ -var on = false; +var on = false; var change = function() { on = !on; LED1.write(on); }; -setWatch(change, BTN1, {repeat:true, edge:"rising"});
\ No newline at end of file +setWatch(change, BTN1, {repeat:true, edge:"rising"}); diff --git a/code/003-dht22.js b/code/003-dht22.js new file mode 100644 index 0000000..c925120 --- /dev/null +++ b/code/003-dht22.js @@ -0,0 +1,5 @@ +var dht = require("DHT22").connect(C11); + +dht.read(function (data) { + console.log("Temp is "+data.temp.toString()+" and RH is "+data.rh.toString()); +});
\ No newline at end of file diff --git a/code/004-display.js b/code/004-display.js new file mode 100644 index 0000000..e7b4cd1 --- /dev/null +++ b/code/004-display.js @@ -0,0 +1,11 @@ +var dht = require("DHT22").connect(C11); + +I2C1.setup({scl:B6,sda:B7}); +var g = require("SH1106").connect(I2C1, start); + +dht.read(function (data) { + console.log("Read DHT22"); + g.drawString("Temp: "+data.temp.toString(),2,2); + g.drawString(" RH: "+data.rh.toString(),2,10); + g.flip(); +});
\ No newline at end of file |