#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define ANALOG_INPUT1 34
#define ANALOG_INPUT2 35
#define DIGITAL_INPUT1 32
#define DIGITAL_INPUT2 33
#define LED1 2
#define LED2 4
#define LED3 16
#define LED4 5
#define RELAY1 25
#define RELAY2 26
#define RELAY3 27
#define RELAY4 14
const int analogThreshold = 512;
const char *message = "Alert!";
LiquidCrystal_I2C lcd = LiquidCrystal_I2C(0x27, 16, 2);
void setup() {
Serial.begin(115200);
lcd.init();lcd.backlight();
pinMode(ANALOG_INPUT1, INPUT);
pinMode(ANALOG_INPUT2, INPUT);
pinMode(DIGITAL_INPUT1, INPUT);
pinMode(DIGITAL_INPUT2, INPUT);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);
pinMode(LED3, OUTPUT);
pinMode(LED4, OUTPUT);
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
}
void loop() {
int analogValue1 = analogRead(ANALOG_INPUT1);
int analogValue2 = analogRead(ANALOG_INPUT2);
int digitalValue1 = digitalRead(DIGITAL_INPUT1);
int digitalValue2 = digitalRead(DIGITAL_INPUT2);
if (analogValue1 > analogThreshold) {
lcd.setCursor(0, 0);lcd.print("Analog 1 Alert");
digitalWrite(LED1, HIGH);
digitalWrite(RELAY1, HIGH);
}
if (analogValue2 > analogThreshold) {
lcd.setCursor(0, 1);lcd.print("Analog 2 Alert");
digitalWrite(LED2, HIGH);
digitalWrite(RELAY2, HIGH);
}
if (digitalValue1 == LOW) {
lcd.setCursor(0, 0);lcd.print("Digital 1 Alert");
digitalWrite(LED3, HIGH);
digitalWrite(RELAY3, HIGH);
}
if (digitalValue2 == LOW) {
lcd.setCursor(0, 1);lcd.print("Digital 2 Alert");
digitalWrite(LED4, HIGH);
digitalWrite(RELAY4, HIGH);
}
delay(1000);
}