#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <Servo.h>
Servo ESC;
LiquidCrystal_I2C LCD(0x27, 16, 4);
const int limit = 1;
int lastVal;
int val;
void setup() {
Wire.begin();
LCD.init();
ESC.attach(9);
LCD.setCursor(0,0);
LCD.print("Servo:");
}
void loop() {
val = analogRead(A0);
val = map(val,0,1023,0,180);
if(abs(val-lastVal)>limit){
ESC.write(val);
String Txt = "Servo:";
LCD.setCursor(0,0);
Txt += val;
Txt +="!";
LCD.print(Txt);
delay(30);
Txt =" ";
}
lastVal = val;
}