Printing user input data from servo to LCD display

Hi I am using a 16x2 LCD display and I want to print the position I set from the serial monitor to the servo motor onto the LCD, I have been messing around trying to get it to work but can’t. thank you to anyone who can help so if the code has some redundancies that are why. Thank you to anyone who can help

#include <Arduino.h>
#include <LiquidCrystal.h>
#include <servo.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Servo servo_test;

int angle = 0;
int state = 0;
void Servoangle(int angle)
{
lcd.setCursor(0, 1);
lcd.print(angle);
lcd.print(" ");
}

void setup() {
lcd.begin(16,2);
servo_test.attach(7);

Serial.begin(9600);
Serial.println(“ARos is loading…”);
delay(1000);
Serial.println(“ARos loaded succesfully”);
Serial.println(“Calibrating servo…”);
for (angle = 0; angle <=180; angle +=1)
servo_test.write(0);
delay(1000);
servo_test.write(180);
delay(1000);
servo_test.write(90);
delay(1000);
Serial.println(“Cal Done”) ;

}

void loop()
{
for(angle = 0; angle <= 180; angle +=1)
if(Serial.available())
{
int state = Serial.parseInt();

if (state < 10)
{
Serial.print(">");
Serial.println(state);
Serial.println(“Number to low”);
}

if(state >= 10 && state <170)
{
Serial.print(">");
Serial.println(state);
Serial.print(“Turning servo to “);
Serial.print(state);
Serial.println(” degrees”);
servo_test.write(state);
}
}

}

This topic was automatically closed after 53 days. New replies are no longer allowed.