树莓派Node-Red例2:手动闪烁LED

 新建网页,在地址栏输入 http://172.16.0.12:1880/ui

var count = context.get('count')||0;
var temp;
count += 1;
if((count%2)===0)
 {
  temp=1;
 }
 else
 {
  temp=0;
 } 
 context.set('count',count);
 msg.payload=temp;
 return msg;

 程序代码,使用"导入"

[{
	"id": "6479b324.c603ac",
	"type": "function",
	"z": "15320658.89a65a",
	"name": "计数取余函数",
	"func": "var count = context.get('count')||0;\nvar temp;\ncount += 1;\nif((count%2)===0)\n {\n  temp=1;\n }\n else\n {\n  temp=0;\n } \n context.set('count',count);\n msg.payload=temp;\n return msg;",
	"outputs": 1,
	"noerr": 0,
	"x": 300,
	"y": 180,
	"wires": [
		["cbdcee7b.1849f", "217dc0f2.f49e8"]
	]
}]
发布了30 篇原创文章 · 获赞 11 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/armcsdn/article/details/104253356
今日推荐