#include <Servo.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2); // initialize I2C LCD
int servoPin1 = 9;
int servoPin2 = 10;
Servo servo1;
Servo servo2;
int angle = 0; // servo position in degrees
void setup()
{
lcd.init(); // initialize the LCD
lcd.backlight(); // turn on the backlight
servo1.attach(servoPin1);
servo2.attach(servoPin2);
}
void loop()
{
// scan from 0 to 180 degrees
for(angle = 0; angle < 90; angle++)
{
servo1.write(angle);
delay(15);
}
delay(2000);
// now scan back from 180 to 0 degrees
for(angle = 90; angle > 0; angle--)
{
servo1.write(angle);
delay(15);
}
// scan from 0 to 180 degrees
for(angle = 0; angle < 90; angle++)
{
servo2.write(angle);
delay(15);
}
delay(2000);
// now scan back from 180 to 0 degrees
for(angle = 90; angle > 0; angle--)
{
servo2.write(angle);
delay(15);
}
for (int i = 10; i > 0; i--)
{ // start countdown from 10 to 1
lcd.clear(); // clear the LCD screen
lcd.setCursor(0,0); // set the cursor to the first column of the first row
lcd.print("Countdown:");
lcd.setCursor(0,1); // set the cursor to the first column of the second row
lcd.print(i); // print the current count value
delay(1000); // wait for 1 second
}
lcd.clear();
}