read vdc voltage and display on LCD - program

I am using Arduino SMD R2 microcontroller and serial enabled LCD 16x2 - 5V(from sparkfun)- I need a program to write so that microcontroller reads Vdc voltage and display it on LCD.

Can anyone help me in getting me a program...i will be really thankful to them.

Regards, Syed

So what problems are you having and what have you tried so far?

Can anyone help me in getting me a program

Here's a start:

void setup()
{
}

void loop()
{
}

All you need to add are a few include files, some global variables, a call to analogRead() and whatever is necessary to make the value show up on the LCD.

This in NOT the homework hotline. We don't do your homework for you.

i dont have the program to write ...so i requesting to help me in providing me the program.

As i am new to this forom and first time i am using this microcontroller..

sajidkaleem: i dont have the program to write ...so i requesting to help me in providing me the program.

As i am new to this forom and first time i am using this microcontroller..

So you're asking us to write the program for you? How are you going to learn if you don't actually do it yourself?

@OP - posting the same question twice on the same forum within five minutes is not a good way to endear yourself to other users.

Your duplicate post has been deleted.

PaulS:

Can anyone help me in getting me a program

Here's a start:

void setup()
{
}

void loop() { }




All you need to add are a few include files, some global variables, a call to analogRead() and whatever is necessary to make the value show up on the LCD.

This in NOT the homework hotline. We don't do your homework for you.

I have started my program like this..hope atleast you will help me now..

void setup () { serial.begin (9600); }

int sensorvalue = analog read (A0); float voltage = sensor value * (5.0/1023.0); serial println (voltage);

}

Is my program fine...or does it require any changes or corrections

void setup () { serial.begin (9600);

}

int sensorvalue = analog read (A0); float voltage = sensor value * (5.0/1023.0);

serial.println (voltage);

}

Is my program correct or does it require any changes...plz help me

The compiler will tell you that your code isn't fine. That's its job.

Is my program fine...or does it require any changes or corrections

Did you try it? Does it produce reasonable results?

Personally, I don't think you even tried compiling it.

The form is right. Some of the names are using the wrong case. (Serial, not serial). You are missing a dereference operator between serial and println(). sensorvalue and sensor value are different names.

Once you get it to compile, and test it, then writing to the LCD is just as easy. Create an instance of the appropriate class, and use lcd.print() instead of Serial.print().

i tried to complie it using the same program with small changes lcd.print (voltage);

i got error message saying sensor value is not declared…

sketch_jul25b:8: error: expected ‘,’ or ‘;’ before ‘value’
sketch_jul25b:10: error: expected constructor, destructor, or type conversion before ‘.’ token
sketch_jul25b:12: error: expected declaration before ‘}’ token

i tried to complie it using the same program with small changes lcd.print (voltage);

Your program is small enough to post again.

void setup () { Serial.begin (9600);

}

int sensorvalue = analog read (A0); float voltage = sensor value * (5.0/1023.0);

lcd.print (voltage);

}

sensor was not declared in this scope error message i recevied :

sketch_jul25b:8: error: expected ',' or ';' before 'value' sketch_jul25b:10: error: expected constructor, destructor, or type conversion before '.' token sketch_jul25b:12: error: expected declaration before '}' token

Where did the loop() function go?

I told you already that "sensorvalue" and "sensor value" are two different things.

You have not created an instance of a class, calling that instance lcd. You can't just make up stuff.

int sensorvalue = 0;
void setup ()

{
Serial.begin (9600);

}

void loop ()

{
int sensorvalue = analog read (A0);
float voltage = sensorvalue * (5.0/1023.0);

lcd.print (voltage);
}

}

i complied now once again…it says lcd was not declared this time…i believe sensorvalue problem/error is solved…is it right.

Global and local variables of the same name are rarely a good idea. You have sensorvalue declared as both.

The number of { and } does not match.

it says lcd was not declared this time

The compiler is right. Imagine that.