Hello there,
firs of all, I'm new to the community, but love what you are doing. Thanks for all the help I've found on the forum. Without any experience in electronics whatsoever, I have managed to build some equipments and tools I now use everyday.
That being said, I have now run into a problem to which I can't find a solution. I've spent two nights goolging it and scrolling through the forum.
What I'd like to do:
Have a device that:
- Measures pH of a solution (that part works very well).
- Output the pH via the serial monitor to Excel (that works very well thanks to PLX-DAQ)
- Output the pH on an LCD display (that works very well on a 20x4 LCD)
Now, do all three at the same time. That's when my LCD starts outputting gibberish (random signs, mostly pound sign, cent signs, ö etc).
I've figure out it's a problem in the code (The LCD and Serial Monitor work great independently)
Here's a simplified code leaving out all the pH stuff
#include <LiquidCrystal.h>
LiquidCrystal lcd(5, 4, 3, 2, 1, 0);
void setup()
{
lcd.begin(20, 4);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("before serial.begin.");
lcd.setCursor(0, 1);
lcd.print("before serial.begin.");
lcd.setCursor(0, 2);
lcd.print("before serial.begin.");
lcd.setCursor(0, 4);
lcd.print("before serial.begin.");
delay(2500);
Serial.begin(9600);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("after serial.begin.");
lcd.setCursor(0, 1);
lcd.print("after serial.begin.");
lcd.setCursor(0, 2);
lcd.print("after serial.begin.");
lcd.setCursor(0, 4);
lcd.print("after serial.begin.");
delay(2500);
Serial.println("CLEARDATA"); //clears all data from previous projects
Serial.println("LABEL,Time,Time (sec),pH,uL / minute added"); //always write LABEL, so excel
Serial.println("RESETTIMER"); //resets timer to 0
Serial.println("Ready"); //Test the serial monitor
}
void loop()
{
Serial.print("DATA,TIME,TIMER"); //writes the time in the first column A and the time since the measurements started in column B
Serial.print(","); //next cell
delay(1000);
}
To troubleshoot the code, I deliberately put in twice some piece of text for the LCD. The first rounds works good, the second (after Serial.begin(9600); ) messes evertyhing up. The lcd.clear(); is even ignored. So, I see part of the innitial text with gibberish next to it.
The serial monitor works fine, btw.
I am working with an arduino uno, macbook pro and a Backlight 2004 20x4 HD44780 LCD .
Can anyone help me with this? Why does the LCD coding stop working after serial.begin?
Many thanks,
Jobbus.