Hy guys,
I am having an issue with my new LCD16x2 display. I connected a potentiometer and read the values. The values are properly read and send to Serial. I also display the values on the display. I am having no issues when increasing the values, but when I go down again at a certain point the displays doesn't display the correct value anymore, but on the Serial I can still see the right readings.
I suppose this has something to do with the display still storing previous values for this digit in the buffer and when I go down the values are not properly reset. But I don't wan't to clear the whole buffer, since then the whole thing just blinks every iteration.
Here's my code
// ESC_Calibration.ino
#include <Wire.h>
#include <Adafruit_MCP23017.h>
#include <Adafruit_RGBLCDShield.h>
#include <Servo.h>
#define WHITE 0x7
Servo firstESC;
Servo secondESC;
int throttlePin = 2;
int firstESCPin = 2;
int secondESCPin = 3;
Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
lcd.setBacklight(WHITE);
lcd.setCursor(0, 0);
lcd.print("throttle:");
firstESC.attach(firstESCPin);
secondESC.attach(secondESCPin);
}
void loop() {
int throttle = analogRead(throttlePin);
throttle = map(throttle, 0, 1023, 0, 179);
lcd.setCursor(0, 1);
Serial.println(throttle);
lcd.setCursor(0, 1);
lcd.print(throttle);
firstESC.write(throttle);
secondESC.write(throttle);
delay(500);
}
Does anyone have a suggestion how to improve this and fix it, so it'll display the right readings, but doesn't blink?
Thanks for your help in advance! :-)