#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int potpin = 0; // analog pin used to connect the potentiometer
int val; // variable to read the value from the analog pin
const int potensioPin = A0;
int nilaiPotensio = 0;
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
lcd.begin(16, 2);
// you can now interact with the LCD, e.g.:
lcd.print("PNL"); //menulis "RG TECH" di baris pertama
lcd.setCursor(0, 1); // memindahkan kursor ke baris ke dua
lcd.print ("Belajar Arduino"); // menulis "Belajar Arduino" di baris ke dua
delay(2000); // tunda proses program selama 2000mSec atau 2 detik
lcd.setCursor (0, 0); // memindahkan kursor ke baris pertama
lcd.print ("Potensiometer: "); // menulis "Potensiometer" pada baris pertama
lcd.setCursor(0, 1); // memindahkan kursor ke baris ke dua
lcd.print (" "); // sebagai clear screen pada baris ke dua
Serial.begin(9600);
}
void loop() {
val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023)
val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180)
myservo.write(val); // sets the servo position according to the scaled value
delay(15); // waits for the servo to get there
nilaiPotensio = analogRead(potensioPin);
lcd.setCursor (0, 1);
lcd.print(nilaiPotensio); // menampilkan nilai parameter di dalam kurung
delay(20);
}