Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
569 B
2
Indexable
Never
#include <Servo.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

Servo myservo;

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                    
  lcd.backlight();
  Serial.begin(9600);
  myservo.attach(9);
  lcd.print("ready to display");
}

void loop()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("CursorAngle:");
  lcd.setCursor(13,0);
  int val = map(analogRead(A0), 0, 1023, 0, 180);
  lcd.print(val);
  myservo.write(val);
  delay(500);
}
Leave a Comment