본문 바로가기

Embeded/ATmega128

2010년 10월 14일 목요일 (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;
}


/* 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

*/