Hi everyone,
First I am a newbie with Arduino, so maybe my problem is really simple...
I want to measure different inputs as a function of time using 4 different analogic inputs (A0, A1, A2, A3) of my Arduino Due. From now I have just plugged A0 and A1 to a 1.5V battery and grounded A2 and A3. My problem is that most of the time my Due measures the wrong input.
Here is a draw of my circuit:
Here is my code:
///Assign pins:
//Pin of the analog input 1:
byte SensorPin1 = 0;
//Pin of the analog input 2:
byte SensorPin2 = 1;
//Pin of the analog input 1:
byte SensorPin3 = 2;
//Pin of the analog input 2:
byte SensorPin4 = 3;
///Define variables:
//Time (in ms):
unsigned long Time0;
//Analog measure input 1:
unsigned int Analog1;
//Analog measure input 2:
unsigned int Analog2;
//Analog measure input 3:
unsigned int Analog3;
//Analog measure input 4:
unsigned int Analog4;
///Stepup:
void setup()
{
//Initialize serial port (speeds: 9600, 14400, 19200, 28800, 38400, 57600, 115200):
Serial.begin(9600);
//Turn the resoltion to 12 bits:
analogReadResolution(12);
}
///Functionning loop:
void loop()
{
//Measure time:
Time0=millis();
//Measure analog inputs:
Analog1=analogRead(SensorPin1);
Analog2=analogRead(SensorPin2);
Analog3=analogRead(SensorPin3);
Analog4=analogRead(SensorPin4);
//Return data:
Serial.print(Time0);
Serial.print(" , ");
Serial.print(Analog1);
Serial.print(" , ");
Serial.print(Analog2);
Serial.print(" , ");
Serial.print(Analog3);
Serial.print(" , ");
Serial.println(Analog4);
}
Here is what I get:
2 , 1880 , 1885 , 1885 , 6
29 , 1884 , 4 , 3 , 1884
56 , 1886 , 6 , 4 , 1883
83 , 1885 , 6 , 4 , 1872
110 , 1885 , 5 , 3 , 1884
I would be really grateful if one of you have an idea to help me !
Thanks in advance...