Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Problem with lcd display

Status
Not open for further replies.

Enzy

Advanced Member level 1
Joined
Mar 20, 2016
Messages
488
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
4,607
I'm using an arduino to read battery voltage I added an lcd display, when I plug it in it comes up and shows battery voltage and then in a second or 2 it flashes off and shows some weird writing.

Does anyone know what could cause that.

- - - Updated - - -

 

Attachments

  • IMG_20161211_145939815.jpg
    IMG_20161211_145939815.jpg
    414.5 KB · Views: 34

Aussie Susan

Advanced Member level 4
Joined
Jan 5, 2015
Messages
1,344
Helped
388
Reputation
776
Reaction score
398
Trophy points
1,363
Activity points
15,807
Without meaning to be sarcastic, the answer is probably 'your program'.
If you are getting anything on the display then the 'setup' step is working correctly.
Therefore I'd look at your 'loop' code.
However without seeing it, I can only guess.
Susan
 

Enzy

Advanced Member level 1
Joined
Mar 20, 2016
Messages
488
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
4,607
Without meaning to be sarcastic, the answer is probably 'your program'.
If you are getting anything on the display then the 'setup' step is working correctly.
Therefore I'd look at your 'loop' code.
However without seeing it, I can only guess.
Susan

well im no pro for sure
Code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0; // resistance of R1 (100K) -see text!
float R2 = 10000.0; // resistance of R2 (10K) - see text!
int value = 0;
int battery = 8; // pin controlling relayA
int buzzer =7;
void setup(){
  pinMode(analogInput, INPUT);
  pinMode(battery, OUTPUT);
  pinMode(buzzer, OUTPUT);
  lcd.begin(16, 2);
  lcd.print("Battery Voltage");
}
void loop(){
  // read the value at analog input
  value = analogRead(analogInput);
  vout = (value * 5.0) / 1024.0; // see text
  vin = vout / (R2/(R1+R2)); 
  if (vin<0.09){
  vin=0.0;//statement to quash undesired reading !
  }
  if (vin<10.6) {
    digitalWrite(battery, LOW);
  }
  else {
    digitalWrite(battery, HIGH);
  }
  if (vin>14.4) {
    digitalWrite(battery, LOW);
} 
else {
  digitalWrite(battery, HIGH);
}
if (vin<10.9) {
digitalWrite(buzzer, HIGH);
}
  else {
    digitalWrite(buzzer, LOW);}
lcd.setCursor(0, 1);
lcd.print("INPUT V= ");
lcd.print(vin);
delay(500);}
 
Last edited by a moderator:

andre_luis

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,316
Helped
1,166
Reputation
2,351
Reaction score
1,152
Trophy points
1,403
Location
Brazil
Activity points
54,307
Does it make sense ?

if (vin<10.6) {
digitalWrite(battery, LOW);
}
else {
digitalWrite(battery, HIGH);
}
if (vin>14.4) {
digitalWrite(battery, LOW);
}
else {
digitalWrite(battery, HIGH);
}

The assignments in highlight are both conflicting.
 

Enzy

Advanced Member level 1
Joined
Mar 20, 2016
Messages
488
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
4,607
Yup it makes sense, even if it didn't make sense would that stop the screen from displaying correctly?

- - - Updated - - -

I made it up not saying it's correct, but if that battery is low 10.6 or lower it low send a low signal to the specific pin and if it's higher than normal operating voltage it will also send a long signal to that same pin, once voltages are in between both thresholds then the pin will be high.
 

hexreader

Advanced Member level 2
Joined
Apr 7, 2011
Messages
543
Helped
196
Reputation
396
Reaction score
196
Trophy points
1,323
Location
England
Activity points
5,050
Check the Arduino library help for the lcd.print function.

Printing of float values does not seem to be a valid option as far as I can tell
 

c_mitra

Advanced Member level 5
Joined
Nov 13, 2012
Messages
3,791
Helped
928
Reputation
1,858
Reaction score
918
Trophy points
1,393
Activity points
29,876
well im no pro for sure

1, remove everything and just try to get lcd.print("INPUT V= ") correctly.

2, Check you definition of int battery and also int buzzer (I guess your buzzer is also not working)

3, Which pins are set for input and which one is set for output?
 

Enzy

Advanced Member level 1
Joined
Mar 20, 2016
Messages
488
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
4,607
I removed everything to just print battery voltage and it worked just fine and as soon as I added the rest the same thing happened again so I guess something is wrong with the coding, I'm teaching myself as I go so based on my wording it looks good to me.

- - - Updated - - -

Actually the 14.4v battery voltage else statement was the problem I guess it conflicts with the previous else statement for the low battery voltage.
 

hexreader

Advanced Member level 2
Joined
Apr 7, 2011
Messages
543
Helped
196
Reputation
396
Reaction score
196
Trophy points
1,323
Location
England
Activity points
5,050
I take back the statement that I made in post 6.... lcd.print of a float does seem to work OK despite no mention in the library help :(

I have tried your sketch above on an Arduino Uno R3 and the LCD seems to display steady characters for me. The only change I made was to change LCD connections to suite my LCD shield.

Because your sketch seems to work OK for me, then the next thing I might suspect is the mess of wiring on your breadboard. Perhaps your wiring is picking up interference or dropping too much power somewhere? Can only guess....

EDIT: Seems that you have solved the issue... Great stuff :)
 
Last edited:

Enzy

Advanced Member level 1
Joined
Mar 20, 2016
Messages
488
Helped
2
Reputation
4
Reaction score
2
Trophy points
18
Activity points
4,607
I take back the statement that I made in post 6.... lcd.print of a float does seem to work OK despite no mention in the library help :(

I have tried your sketch above on an Arduino Uno R3 and the LCD seems to display steady characters for me. The only change I made was to change LCD connections to suite my LCD shield.

Because your sketch seems to work OK for me, then the next thing I might suspect is the mess of wiring on your breadboard. Perhaps your wiring is picking up interference or dropping too much power somewhere? Can only guess....

Read my previous comment

- - - Updated - - -

Also I made a big error, the lcd pins are connected to pin 8 and pin 7 and that's what I set my outputs to be also, so I switched them to pins 2 and 3 and is now testing the circuit, I am not getting accurate enough vtage reading I am guessing that's because of the resistors not being exact.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top