Guest User

Untitled

a guest
Apr 20th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.51 KB | None | 0 0
  1. ISR(ADC_vect){
  2.     uint8_t sample = ADCH; // Store the result (8 -bits, discard the 3 LSB)
  3.     ADCSRA &= ~(1 << ADEN); // Disable the ADC
  4.     ad[channel] = sample;
  5.     if(channel<7){ //Cycle trough the channels 0-4
  6.         channel ++;
  7.         ADMUX = channel;//Update the ADMUX register
  8.         ADCSRA |= (1 << ADEN); // Enable the ADC
  9.     }      
  10.     else if (channel == 7){
  11.     cli(); // disable interrupts for now
  12.     newSampleReady = 1; // 7 channels sampled
  13.     channel = 0; // Reset to channel 0
  14.     ADMUX = channel; //Update the ADMUX register
  15.     }  
  16. }
Add Comment
Please, Sign In to add comment