3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

obnizAdvent Calendar 2020

Day 22

Obniz WS2812B をNoodlで動かしてみる

Posted at

Obnizアドベントカレンダー遅れてすみません、、

LEDテープを光らせたい!
ObnizとNoodlを連携して、LED制御したい!という記事です。

#パーツライブラリ
LED(WS2812B)を使います。
https://obniz.com/ja/sdk/parts/WS2812B/README.md

購入したLED
https://www.amazon.co.jp/gp/product/B01MYT6JH9/ref=ppx_yo_dt_b_asin_title_o09_s01?ie=UTF8&psc=1

#構築したNoodlのフロー
noodl.png

#JavaScriptノードに記述したコード

JavaScript
script({
	inputs:{
	    obnizID:'string',
	    h:'number',
	    s:'number',
	    v:'number'
	},
	
	signals:{
		mySignal:function(inputs) {
		    var obniz = new Obniz(inputs.obnizID);
		    var h = inputs.h;
		    var s = inputs.s;
		    var v = inputs.v;
		    obniz.onconnect = async function(){
		        var led = obniz.wired("WS2812B", {din:2});
    		    led.hsvs([
    		            [h,s,v],[h,s,v],[h,s,v],[h,s,v],[h,s,v]
    		    ])
		    }
		}
	}
})

#ひとまず光った!

#おわりに
ちょっと理想通りに実装できていないので、引き続き試してみて、上手くいったら記事を更新しようと思います。

3
1
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
3
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?