Here is my code. I want to ask why I use Arduino Due to record the time and analog value, it will print two same time point value. Kindly to check in the figure, this is what I get from this code.
Why does it show the same value?
float z[2900][3];
int s;
int p;
int inPin = 5;
void setup() {
pinMode(9,OUTPUT);
digitalWrite(9,HIGH);
pinMode(10,OUTPUT);
digitalWrite(10,HIGH);
Serial.begin(115200);
analogReadResolution(12);
pinMode(inPin,INPUT);
}
void loop() {
if (Serial.available() > 0) {
int inByte1 = Serial.read();
switch (inByte1) {
case '2':
digitalWrite(9,LOW);
delay(1500);
digitalWrite(9,HIGH);
delay(300);
digitalWrite(10,LOW);
delay(300);
digitalWrite(10,HIGH);
//delay(76000); //等待extraction step
p=0;
while(p < 1){
if(digitalRead(inPin) == 1){
//delayMicroseconds(7420);
for (int s=0;s<2620;s++){
z[s][0] = micros();
z[s][1] = analogRead(A1);
}
p = p+1;
}
}
/*while (p < 75){
if(digitalRead(inPin) == 1){
//x[p][3] = millis();
for (int s=0;s<2620;s++){
z[s][0] = micros();
z[s][2] = analogRead(A2);
}
p = p+1;
for (int s=0;s<2620;s++){
z[s][1] = z[s][2] + z[s][1];
}
}
}
for (int s=0;s<2620;s++){
z[s][1] = z[s][1]/p;
}*/
for(int s=0;s<2620;s++){
Serial.print(z[s][0]);
Serial.print(",");
Serial.print(z[s][0]-z[0][0]);
Serial.print(",");
Serial.print(z[s][1]);
Serial.print("\n");
delay(3);
}
break;
}
}
}