Go Down

Topic: Problems to print the analog value on LCD (Read 370 times) previous topic - next topic

darighi

Hi guys,

someone know what there is of wrong in this code?
The number printed on terminal is different from the number printed on LCD!
Also, if I connect A11 pin to GND, on LCD I've a low random number.
If the same pin is floating, on LCD I obtain numbers that can reach also 9000 while on terminal the value is totally different.

If I connect the A11 pin to 3.3V the LCD shows the right number and also on the terminal I can see the same number (1023).
Someone can help me?
Thanks



Code: [Select]


#include <LiquidCrystal.h>

LiquidCrystal lcd(25, 30, 37, 38, 39, 40);


void setup() {
 
  Serial.begin(9600);
 
  while (!Serial)  { ; }
 
  //- begin the lcd
  lcd.begin(16, 2);
 
}


void loop()
{
int16_t AD;

delay(500);

AD = analogRead(A11);

lcd.setCursor(0,0);
lcd.print(AD);

Serial.println(AD);
}

darighi

I found the problem...
before to print the value, I need to clear the old value prined on LCD with lcd.print("0000");



Go Up