Good afternoon,
I need your help. I am using an Arduino Mega 2560 board and I have 10 analog inputs connected, my voltage in these inputs changes when my inclinometers are moving. Then this voltage is between 0V and 5V and Arduino has a FS between 0 and 1023.
My question is, how is possible that the voltage that Arduino has in the analog input pins changes and Arduino always has 1023?
I am trying understand this with this easy example and it always is the same (1023), i don't understand anything... Can you help me, please?
I expect your answer. Thank you.
My best regards.
#include <SPI.h>
#include <Ethernet.h>
#include <Wire.h> // Incluye la libreria Wire
#include "RTClib.h" // Incluye la libreria RTClib
#include <EEPROMEx.h>
#include <math.h>
const int giPinSeguidorG1[5] = {36, 32, 31, 30, 33};
const int giEAnalogicasG1[5]= {0};
void setup()
{
Serial.begin(9600);
Wire.begin();
}
void loop()
{
int A= 0;
A = analogRead(giEAnalogicasG1[2]);
delay (1000);
Serial.println ("El valor de la entrada analogica es:");
Serial.println (A);
}
const int giPinSeguidorG1[5] = {36, 32, 31, 30, 33};
const int giEAnalogicasG1[5]= {0};
You declare an array of pin numbers, followed by a (useless) constant array of (presumably) values you want to set with an analogRead() of the pin numbers.
A = analogRead(giEAnalogicasG1[2]);
Then you read a pin contained in the constant array of values, which are all zero values.
So you are trying to reaad an analog value from pin 0. Not going to work.
The problem was the board. It has the analogic input broke, because they always are in 1023 and the voltage is changing but the input is always in 1023 (FS).
Thank you for your replies. I have bought other board.