Untitled
By: a guest | Mar 22nd, 2010 | Syntax:
C | Size: 0.52 KB | Hits: 149 | Expires: Never
#include <avr/interrupt.h>
#include <avr/io.h>
#include <stdio.h>
int main(void)
{
DIDR0 = 0x00;
DDRC = 0x00;
DDRB = 0xFF;
PORTB = 0x00;
ADCSRA = (1 << ADEN) | (1 << ADATE) | (1 << ADIE) | (0b111 << ADPS0);
ADCSRB = 0x00;
ADMUX = (0b00 << REFS0) | (1 << ADLAR) | (0x0 << MUX0);
sei(); // Interrupt Enable
ADCSRA |= (1 << ADSC); // Start first conversion
while (1) { }
return 0;
}
// PS2 Interrupt - Bit receive
ISR(ADC_vect)
{
PORTB = ~(1 << ((ADCH * 8) / 255));
}