#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <Servo.h>
#define SensorPin 0 //pH Probe analog output set to input 0 on Arduino
#define Deadband 0.3 //Deadband to allow for range of acceptable pH
#define Setpoint 7.5 //Gives a setpoint value for what the best pH level is
unsigned long int avgValue; //Store the average value of the sensor feedback
float phValue;
int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
//OneWire oneWire(SENSOR_PIN);
//DallasTemperature sensors(&oneWire);
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo myservo4;
const float BETA = 3950; // should match the Beta Coefficient of the thermistor
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
myservo1.attach(2);
myservo2.attach(4);
myservo3.attach(7);
myservo4.attach(5);
}
void loop() {
// put your main code here, to run repeatedly:
if (SensorPin <= 500)
{
val1 = analogRead(SensorPin); // reads the value of the potentiometer (value between 0 and 1023)
val1 = map(val1, 0, 450, 180, 0); // scale it to use it with the servo (value between 0 and 180)
myservo1.write(val1); // sets the servo position according to the scaled value
// waits for the servo to get there
myservo3.write(0);
myservo4.write(0);
delay(15);
}
if (SensorPin <= 700)
{
val2 = analogRead(SensorPin); // reads the value of the potentiometer (value between 0 and 1023)
val2 = map(val2, 725, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo2.write(val2); // sets the servo position according to the scaled value
// waits for the servo to get there
myservo3.write(0);
myservo4.write(0);
delay(15);
}
while (analogRead(SensorPin) >= 501 && analogRead(SensorPin) <= 699)
{
myservo3.write(180);
myservo4.write(180);
delay(15);
}
int analogValue = analogRead(A1);
float celsius = 1 / (log(1 / (1023. / analogValue - 1)) / BETA + 1.0 / 298.15) - 273.15;
Serial.print("Temperature: ");
Serial.print(celsius);
Serial.println(" ℃");
}