Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Pages: [1]   Go Down
Author Topic: display the analogRead to lcd screen  (Read 738 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 38
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what i need to do is write in the screen:
Value 1 = (the reading from sensor)

my code is:
  sensorValue = analogRead(sensorOne);      // read sensorOne value.
  lcd.setCursor(0, 1)
  Serial.print("Sensor One = "sensorValue, DEC);


does this look right!?!
« Last Edit: March 03, 2011, 04:45:00 am by latif » Logged

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Nope.

More like:
Code:
  sensorValue = analogRead(sensorOne);      // read sensorOne value.
  lcd.setCursor(0, 1)
  lcd.print("Sensor One = ");
  lcd.print(sensorOne);
Logged

Central MN, USA
Offline Offline
Tesla Member
***
Karma: 76
Posts: 7354
Phi_prompt, phi_interfaces, phi-2 shields, phi-panels
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

what i need to do is write in the screen:
Value 1 = (the reading from sensor)

my code is:
  sensorValue = analogRead(sensorOne);      // read sensorOne value.
  lcd.setCursor(0, 1)
  Serial.print("Sensor One = "sensorValue, DEC);


does this look right!?!
The above won't work. You should use the code posted by mowcius.
If you want this to work, you could look into the sprintf on cplusplus.com. The sprintf gives you more handle on how many digits you print before and after the decimal point and what not. I do this:

char msg[20];
sprintf(msg,"value=%04d", sensorValue);
Serial.print(msg);

This way also saves you program size if you will need to use the sprinft for other outputs in your program anyway. You save from not having to compile the overloaded Serial.print(int,int)

BTW, didn't you mean lcd.print instead of Serial.print?  smiley-cool
Logged


Pages: [1]   Go Up
Arduino Forum upgrade scheduled for Monday, October 20th, 11am-4pm (CEST). Sorry for the inconvenience!
Jump to: