6677

Untitled

Dec 11th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <avr/io.h>
  2. #include <avr/interrupt.h>
  3. ISR(ADC_vect)
  4. {
  5. PORTA = ~ADCH;
  6. }
  7.  
  8.  
  9. int main( void )
  10. {
  11.  
  12. DDRA = 0xff; // PORTB to output
  13. PORTA = 0Xff; // All LEDs off
  14.  
  15. // Enable ADC. ADC interrupt enable. Free running mode. Prescale=16
  16. ADCSRA = (1<<ADEN)|(1<<ADIE)|(1<<ADATE)|(1<<ADPS2);
  17. ADMUX = (1<<ADLAR) | (1<<REFS0); // Left-adjust, Ref. = AVCC
  18. // Single-ended on ADC0 is default
  19.  
  20. ADCSRA |= (1<<ADSC);
  21. sei();
  22.  
  23. while(1)
  24. {
  25. asm("nop");
  26. } // endless loop
  27.  
  28. }// end main()
Add Comment
Please, Sign In to add comment