#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
Servo myServo;
LiquidCrystal_I2C lcd(0x27, 20, 4); // Set the LCD address and dimensions
int startButton = 4; // Pin for the start button
int stopButton = 3; // Pin for the stop button
bool isServoActive = false;
void setup() {
lcd.init();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Don Honorio Ventura State University");
delay(3000); // Display for 3 seconds
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("College of Industrial Technology");
delay(3000); // Display for 3 seconds
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("BSIT Electronics Technology");
delay(3000); // Display for 3 seconds
lcd.clear();
pinMode(startButton, INPUT);
pinMode(stopButton, INPUT);
myServo.attach(11); // Connect servo to pin 11 on Arduino Mega
}
void loop() {
int startButtonState = digitalRead(startButton);
int stopButtonState = digitalRead(stopButton);
Serial.print("Start Button State: ");
Serial.println(startButtonState);
Serial.print("Stop Button State: ");
Serial.println(stopButtonState);
if (startButtonState == HIGH && !isServoActive) {
isServoActive = true;
myServo.write(90); // Turn on the servo motor by moving it to 90 degrees
}
if (stopButtonState == HIGH && isServoActive) {
isServoActive = false;
myServo.write(0); // Turn off the servo motor by moving it to 0 degrees
}
}