Académique Documents
Professionnel Documents
Culture Documents
h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <FuzzyRule.h>
#include <FuzzyComposition.h>
#include <Fuzzy.h>
#include <FuzzyRuleConsequent.h>
#include <FuzzyOutput.h>
#include <FuzzyInput.h>
#include <FuzzyIO.h>
#include <FuzzySet.h>
#include <FuzzyRuleAntecedent.h>
int kelembaban;
int lembabPin = A2;
int relay = 8;
float keluar1;
int keluar;
int keluar2;
//-----------------------------------------Set
Fuzzy---------------------------------------
Fuzzy* fuzzy = new Fuzzy();
// Fuzzy input suhu
FuzzySet* dingin = new FuzzySet(20, 20, 28, 30); // suhu dingin
FuzzySet* normal = new FuzzySet(28, 30, 40, 42); // suhu normal
FuzzySet* panas = new FuzzySet(40, 42, 50, 50); // suhu panas
void setup()
{
pinMode(relay, OUTPUT);
pinMode(durasi, OUTPUT);
Serial.begin(9600);
lcd.begin(16,2); // initialize the lcd for 16 chars 2 lines, turn on backlight
scale.set_scale();
scale.tare(); //Reset the scale to 0
long zero_factor = scale.read_average(); //Get a baseline reading
Serial.print("Zero factor: "); //This can be used to remove the need to tare the
scale. Useful in permanent scale projects.
Serial.println(zero_factor);
//---------------------------------------------------------------------------------
--------
//----------------------------------Penambahan Set
Fuzzy-----------------------------------
//---------------------------------------------------------------------------------
--------
FuzzyInput* suhu = new FuzzyInput(1);// Creating a FuzzyInput suhu
suhu->addFuzzySet(dingin); // Add FuzzySet dingin to FuzzyInput suhu
suhu->addFuzzySet(normal); // Add FuzzySet normal to FuzzyInput suhu
suhu->addFuzzySet(panas); // Add FuzzySet panas to FuzzyInput suhu
fuzzy->addFuzzyInput(suhu); // Add FuzzyInput to Fuzzy suhu
*/
}
void loop()
{
digitalWrite(relay, LOW);
//--------------------------------------INPUTAN
SENSOR--------------------------------------
//====================================== sensor berat
======================================
scale.set_scale(calibration_factor); //Adjust to this calibration factor
beban = scale.get_units(), 10;
if (beban < 0)
{
beban = 0.00;
}
ounces = beban * 0.035274-18.9;
//===================================== sensor suhu
=====================================
suhu = analogRead(suhuPin);//membaca nilai adc sensor
suhu = (suhu/1024.0)*3500;//konversi data analog menjadi milivolt
suhu = suhu/10;//konversi kedalam derajat celsius dengan persamaan 1derajat/10mv
//defuzzification
float output = fuzzy->defuzzify(1);
int output1=output*60000;
//----------------------------------TAMPILAN
OUTPUT-----------------------------------
/* digitalWrite(durasi,HIGH);
delay(output1);*/
Serial.print("DURASI "); Serial.print(output); Serial.print(" MENIT");
keluar = output ;