obnizとFullColorLEDでちょっぴり実験しました。やっぱり簡単ですね。

はてなブックマーク - obnizとFullColorLEDでちょっぴり実験しました。やっぱり簡単ですね。
LINEで送る
Pocket

ウェブエンジニアも一瞬で使える電子工作ボード

しかもデフォルトでインタネット接続で動作する

まさにIoTですね!

手元にある、センサーやモーター、サーボ、LEDなど、全て(今サポートする部品をこちらでご確認ください。https://obniz.io/sdk/parts)がすぐその場で動きを確認できます。

ちょっとした電子工作でしたら、すぐできちゃいます!

今日は、私の手元にあるFull Color LEDを使って、ちょっぴり遊んでみたいと思います。

このLEDはこちらの中にあるものでした。

obnizeとFullColorLEDでちょっぴり実験しました。その後Greenは壊れた。もちろんobnizの問題ではなく、LEDが品質良くなかったかもしれません。

参考したリンクは、本家の

https://obniz.io/sdk/parts/FullcolorLED/README.md?iframe=false

 

<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <script src="https://obniz.io/js/jquery-3.2.1.min.js"></script>
  <script src="https://unpkg.com/[email protected]/obniz.js" crossorigin="anonymous"></script>
</head>
<body>

<div id="obniz-debug"></div>
<h1>obniz instant html</h1>
<button id="green">GREEN</button>
<button id="blue">BLUE</button>
<button id="red">RED</button>
<button id="yellow">YELLOW</button>
<div id="print"></div>

<script>
var obniz = new Obniz("62964371");
obniz.onconnect = async function () {

  var led = obniz.wired("FullColorLED", {r: 3, g:2, b:1,  common:0, commonType:'anode_common'}); 
  //led.hsv(180, 0.5, 1);
  //led.gradation(1000); // 1000 msec loop
  //

  obniz.display.clear();
  obniz.display.print("Full RGB LED");

  obniz.switch.onchange = function(state) {
    $('#print').text(state);
    obniz.display.clear();
    obniz.display.print(state);
  }  

  $('#green').click(function () {
      led.rgb(0, 255, 0); // GREEN
      obniz.display.clear();
      obniz.display.print("青色でしょう?");
  });
  $('#blue').click(function () {
      led.rgb(0, 0, 255); // Blue
      obniz.display.clear();
      obniz.display.print("青色でしょう?");
  });
  $('#red').click(function () {
      led.rgb(255, 0, 0); // Red
      obniz.display.clear();
      obniz.display.print("赤色でしょう?");
  });

}

</script>
</body>
</html>

こんな画面が出てきます。

ボタンを押して、obnizに指示を出して、Fill Color Ledの色を変えます。

最初は、どれも、軽く光っている状態です。

少しは電流が流れているんでしょうね。

その後、画面上のボタンをクリックして

赤色を出してみます。

青色を出してみます。

焦点を光源に合わせると、全体が少し黒めの写真になってしまいました。その辺はご愛嬌、ということで。

その後、青色(Green)を数回出しましたが。

途中から、Greenが出なくなりました。

led.gradation(1000);もやりましたが、やはりGreenがしんだみたいです。

今回は、本当に一瞬のテストだけでした!

お読みいただきありがとうございました。

物足りなかったかたは、こちらの記事をお読みください。自分の中ではなかなか面白い内容だと思っています!笑。

obniz(オブナイズ)+leapmotion+cylon.js連携でマジックハンドでサーボを動かす!本邦初公開!leapmotionとobnizの連携記事

ではまた!

はてなブックマーク - obnizとFullColorLEDでちょっぴり実験しました。やっぱり簡単ですね。
LINEで送る
Pocket

Add a Comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close