Arduino Test final no lcd
Arduino Test final no lcd
// Sensor 2 Setup
const int sensor2Pin = A1; // Analog pin for moisture sensor
const int outputPin2 = 4; // Digital pin for controlling an output (e.g., an
LED)
int moistureValue2;
// Sensor 3 Setup
const int sensor3Pin = A3; // Analog pin for the water level sensor
const int buzzerPin = 8; // Digital pin for the buzzer
const int threshold = 500; // Threshold for the water level sensor
void setup() {
pinMode(outputPin1, OUTPUT);
pinMode(outputPin2, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(9600);
Serial.println("Reading from sensors...");
}
void loop() {
// Reading from Sensor 1
moistureValue = analogRead(sensor1Pin);
moistureValue = map(moistureValue, 550, 10, 0, 100);
Serial.print("Moisture: ");
Serial.print(moistureValue);
Serial.println("%");
if (moistureValue > 0) {
digitalWrite(outputPin1, HIGH); // Turn on the output if moisture value is
above 0
} else {
digitalWrite(outputPin1, LOW); // Turn off the output if moisture value is 0
or below
}
if (moistureValue2 > 0) {
digitalWrite(outputPin2, HIGH); // Turn on the output if moisture value is
above 0
} else {
digitalWrite(outputPin2, LOW); // Turn off the output if moisture value is 0
or below
}