Basic problem with analogRead()

I am working with arduino UNO and when i use the command analogRead("X") the program indicate a value in bits.
The problem is that i am not putting voltage y the arduino board, there is nothing connected.
Help please, it is for a college project.

when i use the command analogRead("X")

analogRead does not accept a string as an argument.

What do you mean with "analogRead not accept a string argument"?

analogRead("X")

"X" is a string.
analogRead accepts only "int" arguments.

The problem is that i am not putting voltage y the arduino board, there is nothing connected

So the input is what is known as floating and it is picking up interference. It happens to all unconnected inputs in digital electronics, it is no problem and no magic.

"X" is one example, I meant that if I write analogRead (1 .... 5), it returns a response bits that should not exist because I'm not giving voltage.

here is the code:
// Pin analógico que utilizaremos como entrada de datos
int entradaDatos = A0;
// Variable que recogerá las lecturas de A0
int valorDatos = 0;

void setup()
{
// Establecemos la velocidad para transmitir datos en serie a
// 9600 baudios
Serial.begin(9600);
}

void loop()
{
// Leemos el valor en la entrada analógica A0 y se lo asignamos a
// valorDatos
valorDatos = analogRead(entradaDatos);
// Imprimimos el valor por el puerto serie
Serial.println(valorDatos);
}

and i open de serial monitor and indicate values as if it had a 1 volt, it means, 200 bits

Grumpy_Mike:

The problem is that i am not putting voltage y the arduino board, there is nothing connected

So the input is what is known as floating and it is picking up interference. It happens to all unconnected inputs in digital electronics, it is no problem and no magic.

Do you read answers?

it returns a response bits that should not exist because I'm not giving voltage.

You're not, but what about the environment?

sorry, i was writting when you sent the message, and sorry for my ignorance but: how to remove that interference in arduino analog pins?

how to remove that interference in arduino analog pins?

Short them to ground.

i really sorry for my ignorance. if i short them to ground, how i connect the analog input of voltage?
and thank you very much for your help and patience

If you connect the inputs to a source, they’ll no longer be floating.
(when we say “floating”, think “antenna”)

The suggestion to short them to ground is to prove that floating condition was indeed causing readings with no input connected.
Connect then input to an analog sensor with an output between 0 and 5 volts to get your readings.
Do not leave the analog input floating else you will see some sort of signal when you expect to see none.

samuz__15:
i really sorry for my ignorance. if i short them to ground, how i connect the analog input of voltage?
and thank you very much for your help and patience

What we are trying to say is that you do not have a problem, you just think you do. If you do not have anything wired up to a specific analog input pin then simply do not perform a analogRead() on that pin, so no problem with that correct?

If you do have a valid electrical signal wired to a analog input pin then you are free to perform analogRead() function on it and use it's value as you please in your program.

Does that answer your concerns?