#include #include Servo myservo; // create servo object to control a servo LiquidCrystal lcd(2, 3, 10, 11, 12, 13);// Pinout, RS=2, E=3, DB4=10, DB5=11, DB6=12, DB7=13 int numRows = 2; // Number of rows of the LCD int numCols = 16; // Number of Columns of the LCD int potpin = 0; // analog pin used to connect the potentiometer int val; // variable to read the value from the analog pin void setup() // We write the initial configuration of our program. { myservo.attach(4); // attaches the servo on pin 9 to the servo object lcd.begin(numRows, numCols); // Allocates or initializes the number of rows and columns of the LCD. lcd.clear(); // Clean the LCD screen lcd.setCursor(0,0); // Place the cursor at column 0, row 0. lcd.print("* Arduino *"); // Write on the screen that is indicated between quotes. lcd.setCursor(0,1); // Place the cursor at column 0, row 1. lcd.print("* Professor *"); // Write on the screen that is indicated between quotes. delay(2000); // Wait 2 seconds. lcd.clear(); // Clean the LCD screen lcd.setCursor(0,0); // Place the cursor at column 0, row 0. lcd.print("* LCD Screen *"); // Write on the screen that is indicated between quotes. lcd.setCursor(0,1); // Place the cursor at column 0, row 1. lcd.print("* ADC & SERVO *"); // Write on the screen that is indicated between quotes. delay(2000); // Wait 2 seconds. lcd.setCursor(0,0); // Place the cursor at column 0, row 0. lcd.print("* Servo Motor: *"); // Write on the screen that is indicated between quotes. lcd.setCursor(0,1); // Place the cursor at column 0, row 1. lcd.print("* Axis Pos: "); // Write on the screen that is indicated between quotes. } 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) // map(value, fromLow, fromHigh, toLow, toHigh) myservo.write(val); // sets the servo position according to the scaled value delay(20); // waits for the servo to get there lcd.setCursor(12,1); // Place the cursor at column 12, row 1. lcd.print(val); // Write on the screen "val" value delay(500); // Wait 0.5 seconds. lcd.setCursor(12,1); // Place the cursor at column 12, row 1. lcd.print(" "); // Write on the screen that is indicated between quotes. }