#include <LiquidCrystal.h>
#include <Servo.h>
Servo myservo;
// inhitialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const int potpin=A0;
int val= analogRead(potpin);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("hello, world!");
myservo.attach(6);
}
void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.clear();
lcd.setCursor(1,0);
lcd.print("hello, world");
delay(15);
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
lcd.setCursor(1, 1);
lcd.print(val);
myservo.write(val);
delay(15);
lcd.setCursor(9,1);
if(val == 0){lcd.print("closed");}
else if (val == 180){lcd.print("opened");}
else {lcd.print("");}
delay(1000);
}