LoginSignup
1
0

More than 3 years have passed since last update.

部屋に置いてあるワインをそのまま飲んでよいか調べるために今の室温を測る。

Posted at

ワインの飲み頃の温度に応じた色で光る

白に光った。
ピンクにも変わったりするので大体9℃前後です。
obniz.jpg

冬だから、部屋にお酒を置いておくだけでちょうどよい?

夏だったらキリっと冷やした白ワインを飲むときに冷えた状態に必要があって、いつも飲む直前にお店で買ってきていました。(そもそも保存の温度に気を使う必要があるので)

冬だったら室温でもちょうどよい温度になるのでは?と思い、
今の室温がどのワインの温度ぐらいかわかるようにLEDを光らせてみました。

ソースのなかに温度帯を細かく書いてますが、
大体でやってみてます。

ソース

const Obniz = require('obniz');
const obniz = new Obniz('obniz_id');  // Obniz_IDに自分のIDを入れてください

obniz.onconnect = async function () {
    //温度センサーの設定
    const tempsens = obniz.wired('LM60', { gnd: 9, output: 10, vcc: 11 });
    var led = obniz.wired("WS2811", {gnd:0, vcc: 1, din: 2});
    //温度センサーの値が変わったら実行される
    tempsens.onchange = function (temp) {

        //スパークリングワイン       6~8度
        // 白ワイン(甘口)         6~8度
        // 白ワイン(辛口)         10度前後
        // 赤ワイン(ライトボディ)     12~14度
        // 赤ワイン(フルボディ)      16~20度
        if(temp >= 6 && temp < 9){
            led.rgb(255, 0, 255); // Pink

        }else if (temp >= 9 && temp < 12){
            led.rgb(255, 255, 255); // White

        }else if (temp >= 12 && temp < 20){
            led.rgb(255, 0, 0); // Red

        }else if (temp < 6){
            led.rgb(0, 255, 255); // Blue
        }else{
            led.rgb(0, 0, 0); // Black
        }
        console.log(temp);
    };
}
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0