How to write the A/D Value read from the potentiometer onto the LCD?

Hello,

I’m learning the basic interfacing using Arduino ATMEGA 2560 Development board. I’m facing difficulty in writing code as a beginner.

I have a question: How to write the A/D Value read from the potentiometer onto the LCD?

Thanks

Assuming you have the LCD working, say along the lines of the hello world example in the ide (file > examples > liquidcrystal > helloworld), all you need to do is add a line like this:

lcd.print(analogRead(0)); // or whatever piun number

Rest of the program doesn’t change??

if i just replace lcd.print(“hello, world!”);

with

lcd.print(analogRead(0));

???

this is the actual program right?? for Hello World:

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

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(“hello, world!”);
}

void loop() {
// set the cursor to column 0, line 1
// (note: line 1 is the second row, since counting begins with 0):
lcd.setCursor(0, 1);
// print the number of seconds since reset:
lcd.print(millis()/1000);
}

How to display Pot value on LCD then??

Rest of the program doesn't change??

if i just replace lcd.print("hello, world!");

with

lcd.print(analogRead(0));

??? :

Yes.

OK I just tried doing it .. But lcd doesnot display any data.. and my lcd light is not glowing?? What may be the reason??

But my lcd light is not glowing?? What may be the reason??

You haven't turned it on?

(Is your question mark key stuck?)

nehaberi: OK I just tried doing it .. But lcd doesnot display any data.. and my lcd light is not glowing?? What may be the reason??

Sounds like your LCD is either broken or not wired up correctly. Does the normal hello world sketch work?

No need to give any baud rate??

And yes its turned on.

Grumpy_Mike:

nehaberi:
OK I just tried doing it … But lcd doesnot display any data… and my lcd light is not glowing?? What may be the reason??

Sounds like your LCD is either broken or not wired up correctly.
Does the normal hello world sketch work?

Yes Yes it does the normal Helloworld but its not showing the pot value.

but its not showing the pot value.

What is it showing?

AWOL:

but its not showing the pot value.

What is it showing?

It is blank.

for analog read the program i just refered is: http://arduino.cc/en/Reference/AnalogRead where I saw baud rate is given.

Post code. Use code tags.

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

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print(analogRead(3));
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

So is the only difference between that code you posted and the example that works that first LCD.print in the setup function? I find it hard to believe that one shows numbers and the other shows nothing.

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

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows: 
  lcd.begin(16, 2);
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print(analogRead(3));
}

void loop() {
}

What does that do?

AWOL:

// include the library code:

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD’s number of columns and rows:
  lcd.begin(16, 2);
  lcd.setCursor(0, 1);
  // Print a message to the LCD.
  lcd.print(analogRead(3));
}

void loop() {
}



What does that do?

Does nothing… shows a blank LCD.
I’m not understanding how to display pot value to the LCD

Pin 3 has not been declared as an INPUT.

nehaberi: I'm facing difficulty in writing code as a beginner.

The best way to learn is to look at some of the introductory tutorials which will examine the basics of Arduino programming.

Magicj: Pin 3 has not been declared as an INPUT.

It's an analogue input.