반응형
1. Ring Counter // 1->2->4->8->16->32->64->128->1 순으로 1초마다 변함
int main()
{
unsigned char count = 1;
DDRA = 0xff;
while(1)
{
PORTA = count;
_delay_ms(300);
if(count<=64)
count = count*2;
else
count = 1;
}
}
2.LED를 맨 오른쪽 1개만 켜고 이를 1초에 한칸씩 왼쪽으로 이동시키고
왼쪽 끝에 도달하면 다시 오른쪽으로 한칸씩 이동시키기 (Boundary Detector)
int main()
{
DDRA = 0xff;
PORTA = 0x01;
unsigned int i = 0;
while(1){
for(i=1;i<=0x80;i<<=1){
PORTA = i;
_delay_ms(50);
}
for(i=0x40;i>=0x01;i>>=1){
PORTA = i;
_delay_ms(50);
if(!i)
break;
}
}
}
반응형
'Project > j-kit-128-1실습' 카테고리의 다른 글
Serial 통신_Uart0_문자 1개 (0) | 2018.10.01 |
---|---|
FND_Display with Timer/Counter (0) | 2018.10.01 |
FND 실습 (0) | 2016.02.26 |
FND 실습 1/100초 스탑워치, 24시간 디지털 시계만들기 (0) | 2016.02.26 |
회로도 참고 (0) | 2016.02.26 |