#include<avr/io.h>
int main()
{
DDRC = 0x00;
DDRE = 0xff;
volatile unsigned char a=0;
volatile unsigned char R=0;
volatile unsigned char L=0;
for(;;)
{
asm("NOP");
R=0x00;
L=0x00;
a=0;
while(1){
if(9>=a)
{
//PORTE=R;
_delay_ms(200);
a++;
R++;
}
else if(0x99>=R)
{
a=0;
R=0;
L=L+0x10;
R=L;
}
else
{
a=0;
R=0;
L=0;
}
PORTE=R;
}}
return 0;
}
/* 00~99까지 증가 FND
#include<avr/io.h>
int main()
{
DDRC = 0x00;
DDRE = 0xff;
volatile unsigned char a=0;
volatile unsigned char R=0;
volatile unsigned char L=0;
for(;;)
{
asm("NOP");
R=0x00;
L=0x00;
a=0;
while(1){
if(9>=a)
{
//PORTE=R;
_delay_ms(200);
a++;
R++;
}
else if(0x99>=R)
{
a=0;
R=0;
L=L+0x10;
R=L;
}
else
{
a=0;
R=0;
L=0;
}
PORTE=R;
}}
return 0;
}
*/
/* 스위치+FND숫자표시
#include<avr/io.h>
int main()
{
DDRC = 0x00;
DDRE = 0xff;
volatile unsigned char a=0;
volatile unsigned char R=0;
volatile unsigned char L=0;
for(;;)
{
asm("NOP");
R=0x00;
L=0x00;
a=~PINC;
while(a>=1)
{
a/=2;
R++;
L=R<<4;
}
PORTE=R+L;
}
return 0;
}
0000 0001 = 0000 0001 1
0000 0010 = 0000 0010 2
0000 0100 = 0000 0011 3
1000 0000 = 0000 1000 8
*/
'Embeded > ATmega128' 카테고리의 다른 글
FND+LED+SW 사용 두더지 잡기 게임 만들기 (0) | 2010.10.29 |
---|---|
2010년 10월 25일 월요일 (LED 랜덤 on / off) (0) | 2010.10.25 |
2010년 10월 21일 (타이머 카운터) (0) | 2010.10.21 |
2010년 10월 13일 수요일 (0) | 2010.10.13 |
2010년 10월 12일 화요일 (0) | 2010.10.12 |