Hello All,
Been working on my project and have run into a snag. My LCD display will get all garbled randomly while the code is measuring a Analog Input. If I go to a section of the code that is not using the AD the display is fine. I can't seem to fine the issue. Sometimes the LCD print out is fine through the measuring section, Other times it gets all garbled.
The only way to get things working again is to hit the reset. I've try different LCD with the same results. Every thing is powered from the Adruino VCC.
I'm using the 4 Bit mode on the LCD, and the library is LiquidCrystal.h.
I'm new to this so I'm sure its my code it'c just the randomness of the issue that has me stumped. I have include my setup and a section that measure the analog. If more is need to figure it out let me know.
THANKS
// include the library code for the LCD:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(3, 4, 5, 6, 7, 8);
void setup() { // LCD
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
analogReference(DEFAULT); // Set Analog reference to 5 Volts
pinMode(2, INPUT); // RPM Interupt
pinMode(9,INPUT);// Sets di 9 as input ZeroPB & RMS Mode select
pinMode(10,INPUT);// Sets di 10 as input MMS Mode Select
pinMode(11,INPUT);// Sets di 11 as input Current Mode Select
pinMode(12,INPUT);// Sets di 12 as input RPM Mode Select
pinMode(13,INPUT);// Sets di 13 as input
// Print a start up message to the LCD.
lcd.print("MMS Complete!");
lcd.setCursor(0, 1);
lcd.print("Select a mode");
}
Here is where I get the random Garbled LCD on both line
lcd.setCursor(0, 0);
lcd.print("RMS Mode");
delay(100);
// set the cursor to column 0, line 2
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 1);
// Measurement section
A1_Value = analogRead(A1)-Zero; // read A1 value - the senors zero state
F1 = A1_Value*4.8875; // convert the AD to Volts 4.8875 per steps (5 / 1023)
if (F1<-100.0) {
F1= (F1-RMS_trim);
}
else if (F1>100.0) {
F1= RMS_trim + F1;
}
lcd.print(F1,0); // Print to LCD with out decimal
delay(500);