AVR I/O & INTERRUPT
Input…자료 정리는 좀만 이따 ㅎ
// I/O 1번과제
#include <avr/io.h>
int main()
{
DDRA = 0xFF;
DDRD = 0x00;
while(1)
{
if (~PIND & 0b00000001) PORTA = 0b11111111;
else if (~PIND & 0b00000010) PORTA = 0b00000000;
else PORTA = 0b10101010;
}
}
// I/O 2번과제
#define F_CPU 16000000
#include <avr/io.h>
#include <avr/interrupt.h>
int led = 0b11111111;
ISR(INT0_vect)
{
if(PORTA == 0b00000000) led = 0b11111110;
else led = (led<<1);
PORTA = led;
}
ISR(INT1_vect)
{
if(led == 0b11111111) led = 0b11111111;
else led = (~(~led)>>1);
PORTA = led;
}
int main()
{
DDRA = 0xFF;
DDRD = 0x00;
PORTA = 0xff;
EIMSK = (1<<INT0)|(1<<INT1);
EICRA = (1<<ISC01)|(1<<ISC00)|(1<<ISC11)|(1<<ISC10);
sei();
while (1){}
}
Leave a comment