how to assign analog pin A7 (AD0) in arduino due

1 post / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have this code which works fine on pin A0 (AD7) but I want to use pin A7 (AD0), how do I do this.

 

 

int myArray[20000];
void setup()

Serial.begin(9600);
{
 
  REG_ADC_MR = 0x10380180;                     
  ADC -> ADC_CHER = 0x80;                        // enable ADC on pin A0

}

void getData()
{
for(int i = 0; i < 20000; i++) {
    
  
    while((ADC->ADC_ISR & 0x80)==0);             // wait for conversion
   
    myArray[i] = ADC->ADC_CDR[7];                         // read value A0
                         
  }  
}

void loop() {

 
  Serial.println(myArray[100]);

}