Loading...
Pages: [1]   Go Down
Author Topic: Help Needed on Voltage to SainSmart LCD display on Mega2560  (Read 207 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have the following program, which is straight forward from the tutorial, the only diference is that I have set the output to my LCD.
The Problem is that I get the volts displayed as follows ex. 2.312.312.312.31 and the same below on the secon line. I am using a 16X2 LCD
Here is the program:#


  // include the library code:
#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8,9,4,5,6,7);

void setup(){
    // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // initialize the serial communications:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 7:
  int sensorValue = analogRead(A7);
  // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  float voltage = sensorValue * (5.0 / 1023.0);
  // print out the value you read:
 
  lcd.print(voltage);
 
}#


Can anyone help this newbie please?

Thank you                   
                                                       
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 336
Posts: 36489
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The Problem is that I get the volts displayed as follows ex. 2.312.312.312.31 and the same below on the secon line.
Why is that a problem? What do you want, instead?

Quote
Can anyone help this newbie please?
Sure, once we know what the problem is.
Logged

East Anglia (UK)
Offline Offline
Edison Member
*
Karma: 55
Posts: 1601
May all of your blinks be without delay
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem is that you are not specifying where the voltage should be printed on the LCD, so each print immediately follows where the previous one stopped. Do some research on the lcd.Setcursor command and use it before you print to the LCD.
Logged

Pages: [1]   Go Up
Print
 
Jump to: