/*
author : Rajeev TR
date : 30/08/2024
https://github.com/HoNtErBoT
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
Servo myservo;
int pos ,pos1;
int motorvalue();
LiquidCrystal_I2C lcd(0x27,16,2);
void setup()
{
Serial.begin(9600);
lcd.begin(16,2);
lcd.clear();
lcd.print("Hello World!");
lcd.setCursor(0, 0);
Serial.println("enter position: ");
myservo.attach(9);
}
void loop()
{
motorvalue();
}
int motorvalue()
{
char x;
if (Serial.available())
{
x=Serial.read();
if(x=='p')
{
pos = Serial.parseInt();
Serial.println(pos);
myservo.write(pos);
lcd.clear();
lcd.print( "Turned to ");
lcd.print(pos);
}
}
return pos;
}