入力範囲: 0 - 1023(ADC値)
出力範囲: 0 - 100(パーセント)
入力: 0 → 出力: 0
入力: 512 → 出力: 50.05
入力: 1023 → 出力: 100
📥 サンプルフローJSON(クリックで展開)
[
{
"id": "range_sample_tab",
"type": "tab",
"label": "Range サンプル",
"disabled": false,
"info": ""
},
{
"id": "range_comment",
"type": "comment",
"z": "range_sample_tab",
"name": "📏 Range ノード サンプル",
"info": "様々なRange変換のデモンストレーション",
"x": 160,
"y": 40,
"wires": []
},
{
"id": "inject_50",
"type": "inject",
"z": "range_sample_tab",
"name": "50を送信",
"props": [{"p": "payload"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "50",
"payloadType": "num",
"x": 140,
"y": 100,
"wires": [["range_basic"]]
},
{
"id": "range_basic",
"type": "range",
"z": "range_sample_tab",
"minin": "0",
"maxin": "100",
"minout": "0",
"maxout": "255",
"action": "scale",
"round": true,
"property": "payload",
"name": "0-100 → 0-255",
"x": 340,
"y": 100,
"wires": [["debug_basic"]]
},
{
"id": "debug_basic",
"type": "debug",
"z": "range_sample_tab",
"name": "基本変換結果",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 560,
"y": 100,
"wires": []
},
{
"id": "comment_limit",
"type": "comment",
"z": "range_sample_tab",
"name": "━━━ 範囲制限デモ ━━━",
"info": "",
"x": 160,
"y": 160,
"wires": []
},
{
"id": "inject_150",
"type": "inject",
"z": "range_sample_tab",
"name": "150を送信(範囲外)",
"props": [{"p": "payload"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "150",
"payloadType": "num",
"x": 170,
"y": 220,
"wires": [["range_limit", "range_scale", "range_wrap"]]
},
{
"id": "range_limit",
"type": "range",
"z": "range_sample_tab",
"minin": "0",
"maxin": "100",
"minout": "0",
"maxout": "255",
"action": "clamp",
"round": true,
"property": "payload",
"name": "Scale & Limit",
"x": 410,
"y": 180,
"wires": [["debug_limit"]]
},
{
"id": "debug_limit",
"type": "debug",
"z": "range_sample_tab",
"name": "Limit: 255",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 590,
"y": 180,
"wires": []
},
{
"id": "range_scale",
"type": "range",
"z": "range_sample_tab",
"minin": "0",
"maxin": "100",
"minout": "0",
"maxout": "255",
"action": "scale",
"round": true,
"property": "payload",
"name": "Scale Only",
"x": 410,
"y": 220,
"wires": [["debug_scale"]]
},
{
"id": "debug_scale",
"type": "debug",
"z": "range_sample_tab",
"name": "Scale: 382",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 590,
"y": 220,
"wires": []
},
{
"id": "range_wrap",
"type": "range",
"z": "range_sample_tab",
"minin": "0",
"maxin": "100",
"minout": "0",
"maxout": "255",
"action": "roll",
"round": true,
"property": "payload",
"name": "Scale & Wrap",
"x": 410,
"y": 260,
"wires": [["debug_wrap"]]
},
{
"id": "debug_wrap",
"type": "debug",
"z": "range_sample_tab",
"name": "Wrap: 127",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 590,
"y": 260,
"wires": []
},
{
"id": "comment_temp",
"type": "comment",
"z": "range_sample_tab",
"name": "━━━ 温度変換デモ ━━━",
"info": "",
"x": 160,
"y": 320,
"wires": []
},
{
"id": "inject_25c",
"type": "inject",
"z": "range_sample_tab",
"name": "25°C",
"props": [{"p": "payload"}],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "25",
"payloadType": "num",
"x": 130,
"y": 380,
"wires": [["range_temp"]]
},
{
"id": "range_temp",
"type": "range",
"z": "range_sample_tab",
"minin": "0",
"maxin": "100",
"minout": "32",
"maxout": "212",
"action": "scale",
"round": false,
"property": "payload",
"name": "摂氏→華氏",
"x": 310,
"y": 380,
"wires": [["debug_temp"]]
},
{
"id": "debug_temp",
"type": "debug",
"z": "range_sample_tab",
"name": "77°F",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 490,
"y": 380,
"wires": []
}
]
演習3: 範囲制限の活用 中級
📋 課題: モーター制御で、入力が範囲外でも安全な値に制限するフローを作成してください。
🎯 要求仕様:
- 入力: -100〜100(速度指令)
- 出力: 0〜255(PWM出力)
- 範囲外の値は上限/下限で制限
✅ 成功の条件:
- 50を入力すると
191(-100〜100の中間よりやや上)が表示される
- 150(範囲外)を入力しても
255(上限値)が表示され、255を超えない
- -50(負の値)を入力すると
64(-100〜100の下半分に対応)が表示される
- 範囲外の値を入力してもエラーにならず、安全な値に制限されて出力される
💡 ヒント
Action を「Scale and limit」に設定すると、範囲外の値は自動的に制限されます。
✅ 解答例フロー
[
{"id": "ex3_tab", "type": "tab", "label": "演習3"},
{"id": "ex3_inject1", "type": "inject", "z": "ex3_tab", "name": "50(正常)", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "50", "payloadType": "num", "x": 150, "y": 80, "wires": [["ex3_range"]]},
{"id": "ex3_inject2", "type": "inject", "z": "ex3_tab", "name": "150(範囲外)", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "150", "payloadType": "num", "x": 160, "y": 120, "wires": [["ex3_range"]]},
{"id": "ex3_inject3", "type": "inject", "z": "ex3_tab", "name": "-50(負の値)", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "-50", "payloadType": "num", "x": 160, "y": 160, "wires": [["ex3_range"]]},
{"id": "ex3_range", "type": "range", "z": "ex3_tab", "minin": "-100", "maxin": "100", "minout": "0", "maxout": "255", "action": "clamp", "round": true, "property": "payload", "name": "速度→PWM(制限付き)", "x": 400, "y": 120, "wires": [["ex3_debug"]]},
{"id": "ex3_debug", "type": "debug", "z": "ex3_tab", "name": "PWM出力", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "payload", "targetType": "msg", "statusVal": "payload", "statusType": "auto", "x": 620, "y": 120, "wires": []}
]
演習4: 温度スケール変換 中級
📋 課題: 摂氏温度を華氏温度に変換するフローを作成してください。
🎯 要求仕様:
- 摂氏 0°C = 華氏 32°F
- 摂氏 100°C = 華氏 212°F
- 負の温度も対応
✅ 成功の条件:
- 0を入力すると
32(水の凍点)が表示される
- 100を入力すると
212(水の沸点)が表示される
- 25を入力すると
77 が表示される(25°C = 77°F)
- 負の温度(例: -10)を入力しても正しく変換される(-10°C = 14°F)
💡 ヒント
入力範囲を -40〜100(摂氏)、出力範囲を -40〜212(華氏)に設定。-40度は摂氏と華氏で同じ値です。
✅ 解答例フロー
[
{"id": "ex4_tab", "type": "tab", "label": "演習4"},
{"id": "ex4_inject1", "type": "inject", "z": "ex4_tab", "name": "0°C", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "0", "payloadType": "num", "x": 130, "y": 80, "wires": [["ex4_range"]]},
{"id": "ex4_inject2", "type": "inject", "z": "ex4_tab", "name": "25°C", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "25", "payloadType": "num", "x": 130, "y": 120, "wires": [["ex4_range"]]},
{"id": "ex4_inject3", "type": "inject", "z": "ex4_tab", "name": "100°C", "props": [{"p": "payload"}], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "100", "payloadType": "num", "x": 140, "y": 160, "wires": [["ex4_range"]]},
{"id": "ex4_range", "type": "range", "z": "ex4_tab", "minin": "0", "maxin": "100", "minout": "32", "maxout": "212", "action": "scale", "round": false, "property": "payload", "name": "摂氏→華氏", "x": 330, "y": 120, "wires": [["ex4_debug"]]},
{"id": "ex4_debug", "type": "debug", "z": "ex4_tab", "name": "華氏温度", "active": true, "tosidebar": true, "console": false, "tostatus": true, "complete": "payload", "targetType": "msg", "statusVal": "payload", "statusType": "auto", "x": 520, "y": 120, "wires": []}
]