Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include #include #define pHPin 3 5 #define TRIG _ PIN 1 1 9 #define ECHO _ PIN 1 1 8 #define TRIG

#include
#include
#include
#include
#include
#define pHPin 35
#define TRIG_PIN119
#define ECHO_PIN118
#define TRIG_PIN217
#define ECHO_PIN216
#define thermoCLK 13
#define thermoCS 12
#define thermoDO 14
#define flowPin122
#define flowPin223
#define calibrationFactor 7.5
#define toplamUzunluk 13
#define motorPin1133
#define motorPin1232
#define enablePin121
#define motorPin2125
#define motorPin2226
#define enablePin227
AnalogPHMeter pHSensor(pHPin);
unsigned int pHCalibrationValueAddress =128;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
float voltage1=2.42, pH1=2.57;
float voltage2=1.49, pH2=13.6;
// Eim ve y kesim noktasn hesapla
float m =(pH2- pH1)/(voltage2- voltage1); //10.22
float b = pH1- m * voltage1; //-22.86
// pH =10.22*voltage -22.86
#define N 25
float readings[N]; // Okumalar saklamak iin dizi
int idx =0; // Mevcut okuma iin indeks
float temp =0;
float pH =0;
float flow1=0;
float flow2=0;
long duration, distance;
int seviye1, seviye2;
unsigned long currentTime ;
unsigned long cloopTime ;
unsigned long pulseTime =0;
unsigned long oldTime =0;
byte motorState =0;
int speedValue1=255;
int speedValue2=255;
volatile int flow_frequency1; // Sensr darbe says
unsigned int l_minute1; // Dakikadaki litre miktar
volatile int flow_frequency2; // Sensr darbe says
unsigned int l_minute2; // Dakikadaki litre miktar
volatile int flowCounter1=0;
volatile int flowCounter2=0;
const char* ssid = "sevda";
const char* password = "sevdanurbilgin342";
WebServer server(80);
void IRAM_ATTR flowSensor1PulseCounter(){
flowCounter1++;
}
void IRAM_ATTR flowSensor2PulseCounter(){
flowCounter2++;
}
void setup(){
Serial.begin(115200);
for(int i=0; i=400|| distance <=2){
return -1;
} else {
return distance;
}
}
float readThermocouple(){
float sicaklikTemp = thermocouple.readCelsius();
if (sicaklikTemp <=0){
return -1;
} else {
return sicaklikTemp;
}
}
float readFlow(volatile int &flowCounter){
return (flowCounter *2.25)/1000; // L/dakika cinsinden
}
void flow1_INT(){
flow_frequency1++;
}
void flow2_INT(){
flow_frequency2++;
}
float readPH(){
float new_reading = analogRead(pHPin)*(3.3/4095.0); // Yeni okumay al
readings[idx]= new_reading; // Yeni okumay dizide sakla
idx++;
if (idx >= N){
idx =0;
}
float sum =0.0; // Toplam hesapla
for(int i=0; i14){
pH =14;
}else{
float pH =0.98*(m * average + b); // pH deerini hesapla
}
return (pH); // Ortalamay yazdr
}
void handleCalibrationMid(){
pHSensor.calibrationMid(7.100f);
server.send(200, "text/plain", "Kalibrasyon orta nokta ayarland");
}
void handleCalibrationLow(){
pHSensor.calibrationLow(2.570f);
server.send(200, "text/plain", "Kalibrasyon dk nokta ayarland");
}
void handleCalibrationHigh(){
pHSensor.calibrationHigh(13.600f);
server.send(200, "text/plain", "Kalibrasyon yksek nokta ayarland");
}
void handleCalibrationClear(){
pHSensor.calibrationClear();
server.send(200, "text/plain", "Kalibrasyon deerleri temizlendi");
}
void handleSaveCalibration(){
EEPROM.put(pHCalibrationValueAddress, pHSensor.getCalibrationValue());
server.send(200, "text/plain", "Kalibrasyon deerleri kaydedildi");
}
void handleStart(){
motorState =!motorState;
if (motorState){
digitalWrite(motorPin11, HIGH);
digitalWrite(motorPin12, LOW);
digitalWrite(motorPin21, HIGH);
digitalWrite(motorPin22, LOW);
server.send(200, "text/plain", "Sistem Baslatildi.");
} else {
server.send(200, "text/plain", "Sistem Durduruldu.");
digitalWrite(motorPin11, LOW);
digitalWrite(motorPin12, LOW);
digitalWrite(motorPin21, LOW);
digitalWrite(motorPin22, LOW);
}
}
void handleForward1(){
digitalWrite(motorPin11, HIGH);
digitalWrite(motorPin12, LOW);
server.send(200, "text/plain", "Motor1 ileri gidiyor, mevcut hiz: "+ String(speedValue1));
}
void handleStop1(){
digitalWrite(motorPin11, LOW);
digitalWrite(motorPin12, LOW);
server.send(200, "text/plain", "Motor durdu, mevcut hiz: "+ String(speedValue1));
}
void handleSpeedUp1(){
if(speedValue1<255) speedValue1+=15;
analogWrite(enablePin1, speedValue1);
server.send(200, "text/plain", "Motor hizi artirildi, mevcut hiz: "+ String(speedValue1));
}
void handleSpeedDown1(){
if(speedValue1>0) speedValue1-=15;
analogWrite(enablePin1, speedValue1);
server.send(200, "text/plain", "Motor hizi azaltildi, mevcut hiz: "+ String(speedValue1));
}
void handleForward2(){
digitalWrite(motorPin21, HIGH);
digitalWrite(motorPin22, LOW);
server.send(200, "text/plain", "Motor2 ileri gidiyor, mevcut hiz: "+ String(speedValue2));
}
void handleStop2(){
digitalWrite(motorPin21, LOW);
digitalWrite(motorPin22, LOW);
server.send(200, "text/plain", "Motor2 durdu, mevcut hiz: "+ String(speedValue2));
}
void handleSpeedUp2(){
if(speedValue2<255) speedValue2+=15;
analogWrite(enablePin2, speedValue2);
server.send(200, "text/plain", "Motor hizi artirildi, mevcut hiz: "+ String(speedValue2));
}
void handleSpeedDown2(){
if(speedValue2>0) speedValue2-=15;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

What do you mean by dual mode operation?

Answered: 1 week ago

Question

Explain the difference between `==` and `===` in JavaScript.

Answered: 1 week ago

Question

2.1 Explain how employment-related issues are governed in Canada.

Answered: 1 week ago

Question

2.3 Describe the requirements for reasonable accommodation.

Answered: 1 week ago