게시판 즐겨찾기
편집
드래그 앤 드롭으로
즐겨찾기 아이콘 위치 수정이 가능합니다.
ㅁㄴㅇㄹ
게시물ID : freeboard_630917짧은주소 복사하기
작성자 : 이런거한다
추천 : 2
조회수 : 556회
댓글수 : 2개
등록시간 : 2012/10/29 17:28:05

#include<avr/io.h>

#include<util/delay.h>

int main(){


unsigned char number[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x98};

unsigned char number_dot[] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x78,0x00,0x18};

int location[] = {0B11111110, 0B11111101, 0B11111011, 0B11110111};


DDRA = 0xff;

DDRC = 0xff;

DDRF = 0xff;


int s=0, m=0, h=12, tm=0;

int s1,s10,m1,m10,h1,h10,tm1,tm10;


s1=s%10;

s10=s/10;

h1=h%10;

h10=h/10;




while(1){


if(PINF !=0){

switch(PINF){


case 1: 

s++;

h=12;

while(1){

tm1=tm%10;

tm10=tm/10;

h1=h%10;

h10=h/10;

PORTA=number[h10]; PORTC=location[0]; _delay_ms(30);

PORTA=number_dot[h1]; PORTC=location[1]; _delay_ms(30);

PORTA=number[tm10]; PORTC=location[2]; _delay_ms(30);

PORTA=number[tm1]; PORTC=location[3]; _delay_ms(30);


tm++;

if(tm>59)

{

h++;

tm=0;

}

if(h>23)

{

h=0;

}


}//////////////////////////////////////////////////////   while끝


case 2:

s++;

m=0;


while(1){

s1=s%10;

s10=s/10;

m1=m%10;

m10=m/10;

PORTA=number[m10]; PORTC=location[0]; _delay_ms(30);

PORTA=number_dot[m1]; PORTC=location[1]; _delay_ms(30);

PORTA=number[s10]; PORTC=location[2]; _delay_ms(30);

PORTA=number[s1]; PORTC=location[3]; _delay_ms(30);


s++;

if(s>59)

{

m++;

s=0;

}

}//////////////////////////////////////////////////////   while끝

}//////////////////////////////////////////////////////   switch끝

}//////////////////////////////////////////////////////   if끝

}//////////////////////////////////////////////////////   while끝

}// main끝

전체 추천리스트 보기
새로운 댓글이 없습니다.
새로운 댓글 확인하기
글쓰기
◀뒤로가기
PC버전
맨위로▲
공지 운영 자료창고 청소년보호