Hello Everybody
Again thank you all very much for your help so far, I will try to follow up on everything we have discussed up until now. Please bare with me if I miss something.
- Capacitors for LM7805: First of all I have changed the capacitors around the LM7805 so it now has a 100 nF capacitor between ground and out as well. I unfortunately do not have a 330 nF capacitor to use but I asked my colleague (Electric engineer) and he said it should not matter if it is only 200 nF, but he agreed the 100 nF was essential.
-
A0 as contrast pin: In regards to the whole A0 as contrast pin, I have no idea how I made it work before (it was couple of years ago and with an UNO and MEGA. But I have done the measurements you guys asked for and it is either 0V or 5V and it seems to change around 127 (so half way to 256) which is also why I see no change with my previous experiments
I will now just short it to ground as that seems to be what is happening and the contrast is fine for me. Then I will just live with not being able to adjust the contrast in software on this project and solve that seperately afterwards. - What happens if I have nothing in my loop?: If I leave everything empty in loop, the LCD will show what I wrote in the setup indefinitely - no problems at all
- Timing before it messes up: It seems to be a bit different when it happens but mostly around 5-6 seconds. Something weird happend though when I changed the code to the what I have pasted in below. Suddenly I have no problems at all and the screen updates fine and have now been running for the whole time I wrote this whole reply without fail. When I change the code back to what I wrote originally I have the problem again. I took out the Serial.println() and the initialization of the serial and still printed the millis() function, and still no problem. It is only when I try to write some text I get my issue. This seems very weird to me...
#include <LiquidCrystal.h>
//---------LCD---------
LiquidCrystal lcd(11, 10, 9, 8, 7, 6);
const int contrastPin = A0;
int timing = 0;
void setup(){
Serial.begin(4800);
analogWrite(contrastPin, 20); //Setting the contrast
//LCD
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Ideart");
lcd.setCursor(0, 1);
lcd.print("Homelab Exp");
}
void loop(){
timing = millis();
lcd.setCursor(0, 0);
lcd.print("Dette er skrevet");
delay(1000);
lcd.setCursor(0, 1);
lcd.print(timing);
Serial.println(timing);
}
- Wiring: My wiring is hard to show with a picture as it is a double sided homemade PCB but I have written out a small schematic to show how I have wired the LCD and the LM7805. I hope this is okay. I have also taken pictures of the actual PCB just in case you want to see it.
- The "up" side of my PCB:*
- The "down" side of my PCB*
- My small schematic (for some reason it decided to rotate the image in the upload and I cannot figure out how to rotate it back, sorry about that):*
As you can see on the down side of the PCB I soldered a wire from the 5V out of the LM7805 to the LCD as I was getting an unwanted voltage drop (possibly because of my homemade PCB) that is now fixed with that wire. I left out the other parts of the schematic as, at this point, I don't use it. It involves two DS18B20 temperature sensors, one YF-S201 flowmeter and a power output for 12 V controlled by a transistor. Also I have two tactile switches for controlling the whole thing.
-
Power up state: It seems to be a default power up state when the error occurs, but when I tilt the screen I can see that it is actually printing characters, I have taken a picture of that as well:
It is just hidden under what seems to be "squares" on each char in the LCD. -
@photoncatcher: Thank you very much for trying to build it up seperately, I am glad to know the code works, but for me it just makes the whole thing even more weird
Can you adjust the contrast with A0 on your build?
I seriously really appreciate the help from all of you, I have no idea what I should do without this forum ![]()



