summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraltaf-pi <athaalaa@gmail.com>2024-04-08 13:44:22 +0700
committeraltaf-pi <athaalaa@gmail.com>2024-04-08 13:44:22 +0700
commit2b8576914fc9bba9ceae15a7e5254cf7cd6152f7 (patch)
treeb5f705fccc09685f4912e41819573fb170a35e2b
add filesHEADmaster
-rw-r--r--Arduino/ardu/ardu.ino33
-rw-r--r--Arduino/garbage_sorting_machine/garbage_sorting_machine.ino191
-rw-r--r--Arduino/garbage_sorting_machine_good/garbage_sorting_machine_good.ino187
-rw-r--r--Arduino/libraries/readme.txt1
-rw-r--r--Arduino/stepper/stepper.ino115
-rw-r--r--NODERED/garbage-sorting-machine-client.json1
6 files changed, 528 insertions, 0 deletions
diff --git a/Arduino/ardu/ardu.ino b/Arduino/ardu/ardu.ino
new file mode 100644
index 0000000..65e6f52
--- /dev/null
+++ b/Arduino/ardu/ardu.ino
@@ -0,0 +1,33 @@
+#include <Servo.h>
+int relayInput = 27; int moistSensor = A10; Servo servo1; Servo servo2;
+enum Material {
+ dry = 0, wet = 1, metal = 2, none = 4,
+};
+enum Material material = dry; int timer = -1; int wetTick = 0; int
+wetTickThreshold = 7; void setup() {
+ pinMode(relayInput, INPUT); digitalWrite(relayInput, HIGH);
+ pinMode(moistSensor, INPUT); servo1.attach(8); servo2.attach(9);
+ servo1.write(180); servo2.write(90); Serial.begin(9600);
+}
+void loop() { int metalState = digitalRead(relayInput); int moistState =
+ analogRead(moistSensor); if (timer >= 0) {
+ timer--;
+ }
+ if (timer == -1) { if (metalState == LOW) { servo1.write(135);
+ servo2.write(90); material = metal; timer = 120;
+ } else {
+ servo1.write(180); if (moistState <= 800) { wetTick++; if (wetTick
+ >= wetTickThreshold) {
+ servo2.write(70); material = wet; timer = 100;
+ }
+ } else {
+ wetTick = 0; servo2.write(90); material = dry;
+ }
+ }
+ }
+ delay(100); Serial.print("Moisture: "); Serial.print(moistState);
+ Serial.print("; Metal: "); Serial.print(metalState); Serial.print(";
+ Material: "); Serial.print(material); Serial.print("; Timer: ");
+ Serial.print(timer); Serial.print("; wetTick: ");
+ Serial.println(wetTick);
+}
diff --git a/Arduino/garbage_sorting_machine/garbage_sorting_machine.ino b/Arduino/garbage_sorting_machine/garbage_sorting_machine.ino
new file mode 100644
index 0000000..901c64e
--- /dev/null
+++ b/Arduino/garbage_sorting_machine/garbage_sorting_machine.ino
@@ -0,0 +1,191 @@
+// SERVO 44, 45
+// DISTANCE 25
+// METAL 27
+// CONVEYOR 4
+// MOISTURE A10
+
+#include <Servo.h>
+
+bool isNotIdle = false;
+
+// Input
+int distance = 25;
+int metalSensor = 27;
+int moisture = A10;
+
+// Output
+Servo servo1, servo2;
+int conveyor = 7;
+
+// Program
+enum Material {
+ dry = 0, wet = 1, metal = 2, none = 3, unknown = 4,
+};
+Material material = none;
+Material prevMat;
+int wetThreshold = 900;
+
+int tickDuration = 100; // Every clock ticks in ms
+int conveyorTimer;
+int servoTimer;
+int wetThresholdCounter;
+
+// Duration for timer to reset. 1 : 100 ms (1 : 0,1 s)
+int conveyorDuration = 200;
+int servoDuration = 70;
+int wetDuration = 7;
+
+// Counting
+int total;
+int metalPassed;
+int wetPassed;
+int dryPassed;
+
+// Servo positions
+int servo1Init = 40;
+int servo1On = 5;
+int servo2Init = 60;
+int servo2On = 10;
+
+// Turning off conveyor after servoTime == -1
+bool justTurnedOff = true;
+
+void setup() {
+ pinMode(metalSensor, INPUT_PULLUP); digitalWrite(metal, HIGH);
+ pinMode(moisture, INPUT);
+ pinMode(distance, INPUT);
+
+ pinMode(conveyor, OUTPUT);
+ servo1.attach(44); servo2.attach(45);
+ servo1.write(servo1Init); servo2.write(servo2Init);
+
+ Serial.begin(9600);
+}
+
+void loop() {
+ int distanceState = !digitalRead(distance);
+ int metalState = !digitalRead(metalSensor);
+ int moistureState = analogRead(moisture);
+
+ // Checking Logic
+ if (distanceState) {
+ conveyorTimer = conveyorDuration;
+ }
+
+ if (metalState) {
+ servoTimer = servoDuration;
+ material = metal;
+ }
+
+ if (moistureState <= wetThreshold && material != wet) {
+ wetThresholdCounter++;
+ if (wetThresholdCounter >= wetDuration) {
+ servoTimer = servoDuration;
+ material = wet;
+ }
+ //servoTimer = servoDuration;
+ //material = wet;
+ }
+
+ // Timer & Logics
+ if (conveyorTimer >= 0) {
+ conveyorTimer--;
+ if (conveyorTimer == conveyorDuration - 1) {
+ justTurnedOff = false;
+ }
+ if (conveyorTimer == 0) {
+ if (material == none || material == unknown || prevMat == none) {
+ material = dry;
+ }
+ }
+ } else {
+ material = none;
+ }
+
+ if (servoTimer >= 0) {
+ servoTimer--;
+ if (servoTimer == servoDuration) {
+ servo1.write(servo1Init);
+ servo2.write(servo2Init);
+ }
+ if (material == metal) {
+ servo1.write(servo1On);
+ } else if (material == wet) {
+ servo2.write(servo2On);
+ }
+ } else {
+ servo1.write(servo1Init);
+ servo2.write(servo2Init);
+ if (!justTurnedOff && material != none) {
+ conveyorTimer = -1;
+ wetThresholdCounter = 0;
+ justTurnedOff = true;
+ }
+ }
+
+ digitalWrite(conveyor, conveyorTimer >= 0);
+
+ // Counting
+ if (prevMat != material) {
+ if (material == metal) {
+ metalPassed++;
+ } else if (material == wet) {
+ wetPassed++;
+ } else if (material == dry) {
+ dryPassed++;
+ }
+
+ total = metalPassed + wetPassed + dryPassed;
+
+ prevMat = material;
+ }
+
+ // On or off?
+ if (conveyorTimer >= 0) {
+ isNotIdle = true;
+ } else {
+ isNotIdle = false;
+ }
+
+ // Debugging
+
+ Serial.print("{\"running\":");
+ Serial.print(isNotIdle);
+ Serial.print(",\"material\":");
+ Serial.print(material);
+ Serial.print(",\"countTotal\":");
+ Serial.print(total);
+ Serial.print(",\"countMetal\":");
+ Serial.print(metalPassed);
+ Serial.print(",\"countWet\":");
+ Serial.print(wetPassed);
+ Serial.print(",\"countDry\":");
+ Serial.print(dryPassed);
+ Serial.print(",\"conveyorTimer\":");
+ Serial.print(conveyorTimer);
+ Serial.print(",\"servoTimer\":");
+ Serial.print(servoTimer);
+ Serial.print(",\"wetTimer\":");
+ Serial.print(wetThresholdCounter);
+ Serial.print(",\"distance\":");
+ Serial.print(distanceState);
+ Serial.print(",\"moisture\":");
+ Serial.print(moistureState);
+ Serial.print(",\"metal\":");
+ Serial.print(metalState);
+ Serial.println("}");/*
+ Serial.print("Distance ");
+ Serial.print(distanceState);
+ Serial.print(" Metal ");
+ Serial.print(digitalRead(27));
+ Serial.print(" Moist ");
+ Serial.print(moistureState);
+ Serial.print(" | Conveyor Timer ");
+ Serial.print(conveyorTimer);
+ Serial.print(" Servo Timer ");
+ Serial.print(servoTimer);
+ Serial.print(" Wet Timer ");
+ Serial.println(wetThresholdTimer);*/
+
+ delay(tickDuration);
+}
diff --git a/Arduino/garbage_sorting_machine_good/garbage_sorting_machine_good.ino b/Arduino/garbage_sorting_machine_good/garbage_sorting_machine_good.ino
new file mode 100644
index 0000000..302e74d
--- /dev/null
+++ b/Arduino/garbage_sorting_machine_good/garbage_sorting_machine_good.ino
@@ -0,0 +1,187 @@
+// SERVO 44, 45
+// DISTANCE 25
+// METAL 27
+// CONVEYOR 4
+// MOISTURE A10
+
+#include <Servo.h>
+
+bool isNotIdle = false;
+
+// Input
+int distance = 25;
+int metalSensor = 27;
+int moisture = A10;
+
+// Output
+Servo servo1, servo2;
+int conveyor = 7;
+
+// Program
+enum Material {
+ dry = 0, wet = 1, metal = 2, none = 3, unknown = 4,
+};
+Material material = none;
+Material prevMat;
+int wetThreshold = 915;
+
+int tickDuration = 100; // Every clock ticks in ms
+int conveyorTimer;
+int servoTimer;
+int wetThresholdCounter;
+
+// Duration for timer to reset. 1 : 100 ms (1 : 0,1 s)
+int conveyorDuration = 150;
+int servoDuration = 70;
+int wetDuration = 5;
+
+// Counting
+int total;
+int metalPassed;
+int wetPassed;
+int dryPassed;
+
+// Servo positions
+int servo1Init = 45;
+int servo1On = 5;
+int servo2Init = 60;
+int servo2On = 10;
+
+// Turning off conveyor after servoTime == -1
+bool justTurnedOff = true;
+
+void setup() {
+ pinMode(metalSensor, INPUT_PULLUP); digitalWrite(metal, HIGH);
+ pinMode(moisture, INPUT);
+ pinMode(distance, INPUT);
+
+ pinMode(conveyor, OUTPUT);
+ servo1.attach(44); servo2.attach(45);
+ servo1.write(servo1Init); servo2.write(servo2Init);
+
+ Serial.begin(9600);
+}
+
+void loop() {
+ int distanceState = !digitalRead(distance);
+ int metalState = !digitalRead(metalSensor);
+ int moistureState = analogRead(moisture);
+
+ // Checking Logic
+ if (distanceState) {
+ conveyorTimer = conveyorDuration;
+ }
+
+ if (metalState) {
+ servoTimer = servoDuration;
+ material = metal;
+ }
+
+ if (moistureState <= wetThreshold && material != wet) {
+ wetThresholdCounter++;
+ if (wetThresholdCounter >= wetDuration) {
+ servoTimer = servoDuration;
+ material = wet;
+ }
+ //servoTimer = servoDuration;
+ //material = wet;
+ }
+
+ // Timer & Logics
+ if (conveyorTimer >= 0) {
+ conveyorTimer--;
+ if (conveyorTimer == conveyorDuration - 1) {
+ justTurnedOff = false;
+ }
+ if (conveyorTimer == 0) {
+ if (material == none || material == unknown || prevMat == none) {
+ material = dry;
+ }
+ }
+ } else {
+ material = none;
+ }
+
+ if (servoTimer >= 0) {
+ servoTimer--;
+ if (material == metal) {
+ servo1.write(servo1On);
+ } else if (material == wet) {
+ servo2.write(servo2On);
+ }
+ } else {
+ servo1.write(servo1Init);
+ servo2.write(servo2Init);
+ if (!justTurnedOff && material != none) {
+ conveyorTimer = -1;
+ wetThresholdCounter = 0;
+ justTurnedOff = true;
+ }
+ }
+
+ digitalWrite(conveyor, conveyorTimer >= 0);
+
+ // Counting
+ if (prevMat != material) {
+ if (material == metal) {
+ metalPassed++;
+ } else if (material == wet) {
+ wetPassed++;
+ } else if (material == dry) {
+ dryPassed++;
+ }
+
+ total = metalPassed + wetPassed + dryPassed;
+
+ prevMat = material;
+ }
+
+ // On or off?
+ if (conveyorTimer >= 0) {
+ isNotIdle = true;
+ } else {
+ isNotIdle = false;
+ }
+
+ // Debugging
+
+ Serial.print("{\"running\":");
+ Serial.print(isNotIdle);
+ Serial.print(",\"material\":");
+ Serial.print(material);
+ Serial.print(",\"countTotal\":");
+ Serial.print(total);
+ Serial.print(",\"countMetal\":");
+ Serial.print(metalPassed);
+ Serial.print(",\"countWet\":");
+ Serial.print(wetPassed);
+ Serial.print(",\"countDry\":");
+ Serial.print(dryPassed);
+ Serial.print(",\"conveyorTimer\":");
+ Serial.print(conveyorTimer);
+ Serial.print(",\"servoTimer\":");
+ Serial.print(servoTimer);
+ Serial.print(",\"wetTimer\":");
+ Serial.print(wetThresholdCounter);
+ Serial.print(",\"distance\":");
+ Serial.print(distanceState);
+ Serial.print(",\"moisture\":");
+ Serial.print(moistureState);
+ Serial.print(",\"metal\":");
+ Serial.print(metalState);
+ Serial.println("}");/*
+ Serial.print("Distance ");
+ Serial.print(distanceState);
+ Serial.print(" Metal ");
+ Serial.print(digitalRead(27));
+ Serial.print(" Moist ");
+ Serial.print(moistureState);
+ Serial.print(" | Conveyor Timer ");
+ Serial.print(conveyorTimer);
+ Serial.print(" Servo Timer ");
+ Serial.print(servoTimer);
+ Serial.print(" Wet Timer ");
+ Serial.println(wetThresholdTimer);*/
+
+ delay(tickDuration);
+}
diff --git a/Arduino/libraries/readme.txt b/Arduino/libraries/readme.txt
new file mode 100644
index 0000000..96ce674
--- /dev/null
+++ b/Arduino/libraries/readme.txt
@@ -0,0 +1 @@
+For information on installing libraries, see: http://www.arduino.cc/en/Guide/Libraries
diff --git a/Arduino/stepper/stepper.ino b/Arduino/stepper/stepper.ino
new file mode 100644
index 0000000..26786f4
--- /dev/null
+++ b/Arduino/stepper/stepper.ino
@@ -0,0 +1,115 @@
+// sesuaikan dengan PIN yang dipasang
+int INA1=14;
+int INA2=15;
+int INA3=16;
+int INA4=17;
+
+int INB1=18;
+int INB2=19;
+int INB3=20;
+int INB4=21;
+//int step = 100;
+int delaytime=2; //makin kecil delay, makin cepat motor berputar
+
+int pinStatus = 13;
+
+void setup(){
+ pinMode(INA1,OUTPUT);
+ pinMode(INA2,OUTPUT);
+ pinMode(INA3,OUTPUT);
+ pinMode(INA4,OUTPUT);
+
+ pinMode(INB1,OUTPUT);
+ pinMode(INB2,OUTPUT);
+ pinMode(INB3,OUTPUT);
+ pinMode(INB4,OUTPUT);
+
+ pinMode(pinStatus, INPUT);
+
+ Serial.begin(9600);
+}
+
+void loop(){
+ //maju 60;
+ //for (int i=0; i<1000; i++){
+ if (!digitalRead(pinStatus)) {
+ maju();
+ }
+ //}
+ Serial.println(digitalRead(pinStatus));
+}
+
+void maju(){
+//step 4
+step1();
+delay(delaytime);
+//step 3
+step2();
+delay(delaytime);
+//step 2
+step3();
+delay(delaytime);
+//step 1
+step4();
+delay(delaytime);
+}
+
+void mundur(){
+//step 4
+step4();
+delay(delaytime);
+//step 3
+step3();
+delay(delaytime);
+//step 2
+step2();
+delay(delaytime);
+//step 1
+step1();
+delay(delaytime);
+}
+
+void step1(){
+digitalWrite(INA1,LOW);
+digitalWrite(INB1,LOW);
+digitalWrite(INA2,LOW);
+digitalWrite(INB2,HIGH);
+digitalWrite(INA3,HIGH);
+digitalWrite(INB3,HIGH);
+digitalWrite(INA4,HIGH);
+digitalWrite(INB4,LOW);
+}
+void step2(){
+digitalWrite(INA1,HIGH);
+digitalWrite(INB1,HIGH);
+digitalWrite(INA2,LOW);
+digitalWrite(INB2,HIGH);
+digitalWrite(INA3,LOW);
+digitalWrite(INB3,LOW);
+digitalWrite(INA4,HIGH);
+digitalWrite(INB4,LOW);
+}
+void step3(){
+digitalWrite(INA1,HIGH);
+digitalWrite(INB1,HIGH);
+digitalWrite(INA2,HIGH);
+digitalWrite(INB2,LOW);
+digitalWrite(INA3,LOW);
+digitalWrite(INB3,LOW);
+digitalWrite(INA4,LOW);
+digitalWrite(INB4,HIGH);
+
+
+}
+void step4(){
+digitalWrite(INA1,LOW);
+digitalWrite(INB1,LOW);
+digitalWrite(INA2,HIGH);
+digitalWrite(INB2,LOW);
+digitalWrite(INA3,HIGH);
+digitalWrite(INB3,HIGH);
+digitalWrite(INA4,LOW);
+
+digitalWrite(INB4,HIGH);
+
+}
diff --git a/NODERED/garbage-sorting-machine-client.json b/NODERED/garbage-sorting-machine-client.json
new file mode 100644
index 0000000..5c1383d
--- /dev/null
+++ b/NODERED/garbage-sorting-machine-client.json
@@ -0,0 +1 @@
+[{"id":"6b8a1dc6.8f8fd4","type":"tab","label":"Main Flow","disabled":false,"info":""},{"id":"c4f7b9e6.7b2448","type":"json","z":"6b8a1dc6.8f8fd4","name":"","property":"payload","action":"obj","pretty":false,"x":570,"y":360,"wires":[["ecfc31e4.13119"]]},{"id":"ecfc31e4.13119","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"var b = JSON.parse(JSON.stringify(msg.payload)); \nb=msg;\nreturn msg;","outputs":1,"noerr":0,"x":830,"y":460,"wires":[["cd471dca.cbbcc","1c10287c.3a1948","f6449c0c.80fb2","ba9ca32e.6e2ef","4578b6f3.e4108","c33104ed.20b2a","3d597f64.693478","dda6ef7f.75f6","bc393b7d.51be38","e56fed75.406938","1f6ef25b.dfa3fe","a9083db4.d26208","27a539b1.90f5c6"]]},{"id":"cd471dca.cbbcc","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"if (msg.payload.running === 0) {\n msg.payload = \"<span class=\\\"text-stop\\\">Stop</span>\";\n return msg;\n} else {\n msg.payload = \"<span class=\\\"text-run\\\">Running</span>\";\n return msg;\n}","outputs":1,"noerr":0,"x":1130,"y":60,"wires":[["ccf58f15.9dc6a8"]]},{"id":"1c10287c.3a1948","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"if (msg.payload.material == 0) {\n msg.payload = \"Dry\";\n return msg;\n} else if (msg.payload.material == 1) {\n msg.payload = \"Wet\";\n return msg;\n} else if (msg.payload.material == 2) {\n msg.payload = \"Metal\";\n return msg;\n} else {\n msg.payload = \"None\";\n return msg;\n}","outputs":1,"noerr":0,"x":1130,"y":160,"wires":[["a76bc292.67253"]]},{"id":"f6449c0c.80fb2","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.countTotal;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":240,"wires":[["aad83c6e.79dbc"]]},{"id":"ba9ca32e.6e2ef","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.countMetal;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":320,"wires":[["4d346132.77f84"]]},{"id":"37a6505b.c7aab","type":"debug","z":"6b8a1dc6.8f8fd4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":590,"y":580,"wires":[]},{"id":"ccf58f15.9dc6a8","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/running","qos":"","retain":"","broker":"4e914494.745dc4","x":1340,"y":60,"wires":[]},{"id":"a76bc292.67253","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/material","qos":"","retain":"","broker":"4e914494.745dc4","x":1340,"y":160,"wires":[]},{"id":"aad83c6e.79dbc","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/countTotal","qos":"","retain":"","broker":"4e914494.745dc4","x":1350,"y":240,"wires":[]},{"id":"4d346132.77f84","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/countMetal","qos":"","retain":"","broker":"4e914494.745dc4","x":1350,"y":320,"wires":[]},{"id":"4578b6f3.e4108","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.countWet;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":400,"wires":[["1f3986ca.064909"]]},{"id":"1f3986ca.064909","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/countWet","qos":"","retain":"","broker":"4e914494.745dc4","x":1350,"y":400,"wires":[]},{"id":"c33104ed.20b2a","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.countDry;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":480,"wires":[["f7ddccde.581fa8"]]},{"id":"f7ddccde.581fa8","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/countDry","qos":"","retain":"","broker":"4e914494.745dc4","x":1340,"y":480,"wires":[]},{"id":"3d597f64.693478","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.conveyorTimer;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":580,"wires":[["280063c6.f67a0c"]]},{"id":"280063c6.f67a0c","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/timer","qos":"","retain":"","broker":"4e914494.745dc4","x":1330,"y":580,"wires":[]},{"id":"dda6ef7f.75f6","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.distance;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":680,"wires":[["6d114bc4.b3309c"]]},{"id":"6d114bc4.b3309c","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/distance","qos":"","retain":"","broker":"4e914494.745dc4","x":1340,"y":680,"wires":[]},{"id":"bc393b7d.51be38","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.moisture;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":780,"wires":[["e1d366f4.9d17f"]]},{"id":"e1d366f4.9d17f","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/moisture","qos":"","retain":"","broker":"4e914494.745dc4","x":1340,"y":780,"wires":[]},{"id":"e56fed75.406938","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.metal;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":880,"wires":[["9892cec1.0aff48"]]},{"id":"9892cec1.0aff48","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/metal","qos":"","retain":"","broker":"4e914494.745dc4","x":1330,"y":880,"wires":[]},{"id":"1f6ef25b.dfa3fe","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.servoTimer;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":960,"wires":[["c8d5f0eb.f4ce7"]]},{"id":"c8d5f0eb.f4ce7","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/servoTimer","qos":"","retain":"","broker":"4e914494.745dc4","x":1350,"y":960,"wires":[]},{"id":"62bbdd42.0e3a14","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/wetTimer","qos":"","retain":"","broker":"4e914494.745dc4","x":1340,"y":1040,"wires":[]},{"id":"a9083db4.d26208","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"msg.payload=msg.payload.wetTimer;\nreturn msg;","outputs":1,"noerr":0,"x":1130,"y":1040,"wires":[["62bbdd42.0e3a14"]]},{"id":"40ad2c87.481d6c","type":"mqtt out","z":"6b8a1dc6.8f8fd4","name":"","topic":"/processedTimer","qos":"","retain":"","broker":"4e914494.745dc4","x":1370,"y":1120,"wires":[]},{"id":"27a539b1.90f5c6","type":"function","z":"6b8a1dc6.8f8fd4","name":"","func":"const clamp = (num, min, max) => Math.min(Math.max(num, min), max);\nif (msg.payload.servoTimer == -1) {\n msg.payload = clamp(msg.payload.conveyorTimer, 0, 200);\n return msg;\n} else {\n msg.payload = clamp(msg.payload.servoTimer, 0, 70);\n return msg;\n}","outputs":1,"noerr":0,"x":1130,"y":1120,"wires":[["40ad2c87.481d6c"]]},{"id":"1dc06c7e.c40304","type":"serial in","z":"6b8a1dc6.8f8fd4","name":"","serial":"2a28de2.be99322","x":260,"y":480,"wires":[["c4f7b9e6.7b2448","37a6505b.c7aab"]]},{"id":"4e914494.745dc4","type":"mqtt-broker","z":null,"name":"cloud thing","broker":"45.76.160.37","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"2a28de2.be99322","type":"serial-port","z":"","serialport":"/dev/ttyACM1","serialbaud":"9600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"}] \ No newline at end of file