i m having a final year project and i m struggling with NOde-red
the project is parking demo using a RASPBERRY +servo as a gate+apprxomity sensor to check the
availability of the LOT
i 'll be glad if you can check my node code and fix it
.................................................................
[
{
"id": "63234a2ef7813cd0",
"type": "tab",
"label": "Flow 3",
"disabled": false,
"info": "",
"env": []
},
{
"id": "bb048f30dbb5dc77",
"type": "ui_toast",
"z": "63234a2ef7813cd0",
"position": "bottom right",
"displayTime": "3",
"highlight": "",
"sendall": true,
"outputs": 0,
"ok": "OK",
"cancel": "",
"raw": false,
"topic": "PLEASE GO TO LOT1",
"name": "",
"x": 590,
"y": 340,
"wires": []
},
{
"id": "850098cb873dbffb",
"type": "rpi-gpio in",
"z": "63234a2ef7813cd0",
"name": "IR sensor",
"pin": "18",
"intype": "tri",
"debounce": "25",
"read": false,
"bcm": true,
"x": 140,
"y": 200,
"wires": [
[
"584b43e28b88ef70",
"e53764faeb06c366"
]
]
},
{
"id": "493b52f2e37fbc2e",
"type": "ui_text",
"z": "63234a2ef7813cd0",
"group": "ef8cbddd17ad1916",
"order": 2,
"width": 0,
"height": 0,
"name": "",
"label": "LOT1",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 590,
"y": 120,
"wires": []
},
{
"id": "584b43e28b88ef70",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "",
"func": "p = msg.payload;\nif (p = 1)\n{msg.payload=true;\nreturn 1;}\nelse\n{msg.payload=false;\n}\nreturn 0;}\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 120,
"wires": [
[
"493b52f2e37fbc2e"
]
]
},
{
"id": "c79468a372a7d095",
"type": "rpi-gpio out",
"z": "63234a2ef7813cd0",
"name": "",
"pin": "23",
"set": "",
"level": "0",
"freq": "50",
"out": "pwm",
"bcm": true,
"x": 1180,
"y": 160,
"wires": []
},
{
"id": "0f26376ad0cbe553",
"type": "delay",
"z": "63234a2ef7813cd0",
"name": "",
"pauseType": "rate",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 690,
"y": 440,
"wires": [
[
"d7d731543223c2a6"
]
]
},
{
"id": "eda57e17da3e255a",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "",
"func": "\nfor (var i=0; i<400; i++){\n node.send({payload:i*0.01 + '$'}); \n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 440,
"wires": [
[
"0f26376ad0cbe553"
]
]
},
{
"id": "c8f5e4b0671473e8",
"type": "ui_text",
"z": "63234a2ef7813cd0",
"group": "ef8cbddd17ad1916",
"order": 0,
"width": 0,
"height": 0,
"name": "",
"label": "Date",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 970,
"y": 40,
"wires": []
},
{
"id": "d7d731543223c2a6",
"type": "ui_text",
"z": "63234a2ef7813cd0",
"group": "ef8cbddd17ad1916",
"order": 1,
"width": 0,
"height": 0,
"name": "",
"label": "fees",
"format": "{{msg.payload}}",
"layout": "row-spread",
"x": 870,
"y": 440,
"wires": []
},
{
"id": "e53764faeb06c366",
"type": "ui_switch",
"z": "63234a2ef7813cd0",
"name": "",
"label": "switch",
"tooltip": "",
"group": "ef8cbddd17ad1916",
"order": 3,
"width": 0,
"height": 0,
"passthru": true,
"decouple": "false",
"topic": "topic",
"topicType": "msg",
"style": "",
"onvalue": "true",
"onvalueType": "bool",
"onicon": "",
"oncolor": "GREEN",
"offvalue": "false",
"offvalueType": "bool",
"officon": "",
"offcolor": "RED",
"animate": false,
"x": 330,
"y": 300,
"wires": [
[
"eda57e17da3e255a",
"bb048f30dbb5dc77",
"7e158778513572bb",
"8a7a1f4a4864a54f"
]
]
},
{
"id": "591f04c638b45cc1",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "Format date",
"func": "const dateNow = {'payload': formatDate()}\n\nfunction formatDate(){\n//29 Aug 2021 06:15:36\n let date = new Date();\n let year = new Intl.DateTimeFormat('en', { year: 'numeric' }).format(date);\n let month = new Intl.DateTimeFormat('en', { month: 'short' }).format(date);\n let day = new Intl.DateTimeFormat('en', { day: '2-digit' }).format(date);\n let time = date.toLocaleTimeString('en-US', { hour12: false });\n return `${day} ${month} ${year} ${time}`;\n}\n\nreturn dateNow",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 750,
"y": 40,
"wires": [
[
"c8f5e4b0671473e8"
]
]
},
{
"id": "8de22bebacecb6d8",
"type": "inject",
"z": "63234a2ef7813cd0",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "true",
"payloadType": "bool",
"x": 608,
"y": 40,
"wires": [
[
"591f04c638b45cc1"
]
]
},
{
"id": "628973c3045204ba",
"type": "ui_led",
"z": "63234a2ef7813cd0",
"order": 5,
"group": "230a64bc7f223e21",
"width": 0,
"height": 0,
"label": "LED blinker",
"labelPlacement": "left",
"labelAlignment": "left",
"colorForValue": [
{
"color": "#008000",
"value": "true",
"valueType": "bool"
},
{
"color": "#808080",
"value": "false",
"valueType": "bool"
}
],
"allowColorForValueInMessage": false,
"shape": "circle",
"showGlow": true,
"name": "",
"x": 1170,
"y": 260,
"wires": []
},
{
"id": "ea2e0dfce4627de8",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "",
"func": "\nmsg.payload = true;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 660,
"y": 260,
"wires": [
[
"135d56fa505275f0",
"628973c3045204ba"
]
]
},
{
"id": "135d56fa505275f0",
"type": "delay",
"z": "63234a2ef7813cd0",
"name": "",
"pauseType": "delay",
"timeout": "150",
"timeoutUnits": "milliseconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 830,
"y": 260,
"wires": [
[
"60abb433d34c7f95"
]
]
},
{
"id": "60abb433d34c7f95",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "",
"func": "\nmsg.payload = false;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1000,
"y": 260,
"wires": [
[
"628973c3045204ba"
]
]
},
{
"id": "7e158778513572bb",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "",
"func": "msgpayload=true;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 460,
"y": 200,
"wires": [
[
"ea2e0dfce4627de8",
"f8002fdf7dc7cb56"
]
]
},
{
"id": "f8002fdf7dc7cb56",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "",
"func": "\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 640,
"y": 160,
"wires": [
[
"c31c90f6611d6634"
]
]
},
{
"id": "c31c90f6611d6634",
"type": "delay",
"z": "63234a2ef7813cd0",
"name": "",
"pauseType": "delay",
"timeout": "5",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 800,
"y": 160,
"wires": [
[
"aa788a0206d0e192"
]
]
},
{
"id": "aa788a0206d0e192",
"type": "function",
"z": "63234a2ef7813cd0",
"name": "",
"func": "\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 960,
"y": 160,
"wires": [
[
"c79468a372a7d095"
]
]
},
{
"id": "8a7a1f4a4864a54f",
"type": "delay",
"z": "63234a2ef7813cd0",
"name": "",
"pauseType": "delay",
"timeout": "8",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"allowrate": false,
"outputs": 1,
"x": 320,
"y": 380,
"wires": [
[
"e53764faeb06c366"
]
]
},
{
"id": "ef8cbddd17ad1916",
"type": "ui_group",
"name": "Time",
"tab": "9825e1db72548c21",
"order": 1,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "230a64bc7f223e21",
"type": "ui_group",
"name": "Rx LED",
"tab": "7da2a54b379a6e07",
"order": 3,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "9825e1db72548c21",
"type": "ui_tab",
"name": "Settings",
"icon": "dashboard",
"disabled": false,
"hidden": false
},
{
"id": "7da2a54b379a6e07",
"type": "ui_tab",
"name": "blinky",
"icon": "fa-bolt",
"order": 2,
"disabled": false,
"hidden": false
}
]