You are on page 1of 2

Mathew V.

Gacosta March 16, 2021

CPE 006 – CPE51S1

Chapter 9 – Practice Activity

1. Modify Chapter 9 Example 2, show the value of potentiometer and servo motor
position on the LCD.

Souce Code:

#include <Servo.h>

#include <LiquidCrystal.h>

Servo servo_9;

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);

void setup()

pinMode(A1,INPUT);

servo_9.attach(A0);

lcd.begin(16, 2);

lcd.print("Pot Value:");
lcd.setCursor(0,1);

lcd.print("Deg Value:");

void loop()

int pot=analogRead(A1);

int deg=map(pot, 0, 1023, 0, 180);

lcd.setCursor(11,0);

lcd.print(pot);

lcd.print(" ");

lcd.setCursor(11,1);

lcd.print(deg);

lcd.print(" ");

servo_9.write(deg);

Google Drive Link: https://drive.google.com/drive/folders/1UciqPd8BtmIas_WMJTxFPAMkq4QNWq6v?usp=sharing

You might also like