Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <avr/io.h>;
- #include <avr/interrupt.h>
- const unsigned char PS_16 = (1 << ADPS2);
- const unsigned char PS_32 = (1 << ADPS2) | (1 << ADPS0);
- const unsigned char PS_64 = (1 << ADPS2) | (1 << ADPS1);
- const unsigned char PS_128 = (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0);
- void setup()
- {
- Serial.begin(1000000);
- // pinMode(A0, INPUT);
- ADCSRA &= ~PS_128;
- ADCSRA |= PS_16;
- ADMUX |= (1 << REFS0);
- ADMUX |= (1 << ADLAR); // Left adjust ADC result to allow easy 8 bit reading
- // No MUX values needed to be changed to use ADC0
- ADCSRA |= (1 << ADIE); // Enable ADC Interrupt
- TCCR0A = 0;
- TCCR0B = 0;
- ADCSRA |= (1 << 5); // Set ADC to Free-Running Mode
- ADCSRA |= (1 << ADEN); // Enable ADC
- ADCSRA |= (1 << ADSC); // Start A2D Conversions
- while(true);
- // Serial.write(analogRead(A0)>>2);
- }
- ISR(ADC_vect)
- {
- Serial.write(ADCH);
- }
- void loop()
- {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement