greeting kind heated person. I have a trouble with my source code it couldn't process the fuzzy and then the code won't loop anymore every time I use the LCD library and output it on LCD. note I'm using LCD 16x2 with i2c, I've been using a simple program to output it on LCD without any sensor and fuzzy and it can. please help me kind-hearted person
#include <Fuzzy.h>
#include <Adafruit_Sensor.h>
#include <DHT.h>
#include <DHT_U.h>
//#include <LiquidCrystal_I2C.h>
//
//LiquidCrystal_I2C lcd(0x27, 16, 2);
#define analogInPin A0 // Analog input pin
#define DHTPIN 2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
const int capteur_D = 4;
const int RELAY_PIN = 7;
int val_analogique;
//variable sensor garam
int sensorValue; //adc value
float outputValueConductivity; //conductivity value
float outputValueTDS; //TDS value
//------------- FUZZY DAN SET NILAI TIAP VARIABEL -------------
#include <Fuzzy.h>
Fuzzy *fuzzy = new Fuzzy();
// FuzzyInput thermal
FuzzySet *dingin = new FuzzySet(0, 9, 9, 18);
FuzzySet *normal = new FuzzySet(18, 21, 21, 28);
FuzzySet *panas = new FuzzySet(28, 39, 39, 50);
// FuzzyInput humid
FuzzySet *kering = new FuzzySet(20, 40, 40, 60);
FuzzySet *lembab = new FuzzySet(60, 75, 75, 89);
FuzzySet *basah = new FuzzySet(89, 95, 95, 100);
// FuzzyInput rain sensor
FuzzySet *kena = new FuzzySet(0, 0, 0, 0);
FuzzySet *tidak_kena = new FuzzySet(1, 1, 1, 1);
// FuzzyOutput turn on off pump
FuzzySet *hidup = new FuzzySet(1, 1, 1, 1);
FuzzySet *mati = new FuzzySet(0, 0, 0, 0);
//------------- PANGGIL TAB LAIN -------------
#include "2_fuzzy_set.h"
#include "3_fuzzy_rule.h"
//------------------------------------------------------------
// VOID SETUP
//------------------------------------------------------------
void setup()
{
// Set the Serial output
Serial.begin(9600);
// lcd.begin();
dht.begin();
pinMode(RELAY_PIN, OUTPUT);
pinMode(capteur_D, INPUT);
// Set a random seed
randomSeed(analogRead(0));
//--------- PANGGIL FUNGSI / FUNCTION FUZY DI TAB 2 DAN 3 ---------
fuzzySet ();
fuzzyRule ();
}
//------------------------------------------------------------
// VOID LOOP
//------------------------------------------------------------
void loop()
{
// Getting a random value
float t = dht.readTemperature();
float k = dht.readHumidity();
//read the analog in value:
sensorValue = analogRead(analogInPin);
// int inputsuhu = random(15, 50);
String katasuhu = "Suhu :";
String stringsuhu = katasuhu+t;
// int inputlembab = random(20, 70);
String katalembab = "Kelembaban :";
String stringlembab = katalembab+k;
int inputkena = 1;
//Mathematical Conversion from ADC to conductivity (uSiemens)
//rumus berdasarkan datasheet
outputValueConductivity = (0.2142*sensorValue)+494.93;
//Mathematical Conversion from ADC to TDS (ppm)
//rumus berdasarkan datasheet
outputValueTDS = (0.3417*sensorValue)+281.08;
// Set the random value as an input
fuzzy->setInput(1, t);
fuzzy->setInput(2, k);
fuzzy->setInput(3, inputkena);
// Running the Fuzzification
fuzzy->fuzzify();
// Running the Defuzzification
float output = fuzzy->defuzzify(1);
// Printing something
// lcd.setCursor(0,0);
// lcd.print(stringsuhu);
// lcd.setCursor(0,1);
// lcd.print(stringlembab);
// delay(1000);
// lcd.clear();
// lcd.setCursor(0,0);
// lcd.print("Salinitas (ppt) :");
// lcd.setCursor(0,1);
// lcd.print(outputValueTDS);
// delay(1000);
// lcd.clear();
Serial.println("\n\n\nEntrance: ");
Serial.print("\t\t\tSuhu: ");
Serial.println(t);
Serial.print("\t\t\tKelembaban: ");
Serial.println(k);
Serial.print("\t\t\tDigital value sensor hujan= : ");
Serial.println(inputkena);
// print the results to the serial monitor:
Serial.print("\t\t\tsensor ADC = ");
Serial.println(sensorValue);
// Serial.print("\t\t\tconductivity (uSiemens)= ");
// Serial.println(outputValueConductivity);
Serial.print("\t\t\tTDS(ppm)= ");
Serial.println(outputValueTDS);
// Printing something
Serial.println("Result: ");
Serial.print("\t\t\tPompa: ");
Serial.println(output);
if(output==1){
digitalWrite(RELAY_PIN, HIGH);
}
else if(output==0)
{ digitalWrite(RELAY_PIN, LOW);}
// wait 12 seconds
delay(2000);
}