BASIC4MCU | 질문게시판 | 도어락 소스코드 오류수정 부탁드려요..
페이지 정보
작성자 dedyw 작성일2018-12-18 22:25 조회6,262회 댓글0건본문
#include <mega128.h>
#include <lcd.h>
#include <delay.h>
#include <stdio.h>
#define BYTE unsigned char
#define SETBIT(ADDRESS,BIT) (ADDRESS |= (1<<BIT))
#define CLEARBIT(ADDRESS,BIT) (ADDRESS &= ~(1<<BIT))
#define TESTBIT(ADDRESS,BIT) (ADDRESS & (1<<BIT))
#define SCAN_OFF (PORTD |= 0x0f)
#define SEG_DATA(val) (PORTC = val)
unsigned char key;
int key_IN[4]; //입력되는 키값 저장배열
int sec_num[4]={0x33,0x31,0x32,0x31}; //비밀번호
int arr_cnt=1, right=1; //비밀번호 검사를 위한 변수 선언
int g=0, s=0; //비밀번호 검사를 위한 변수선언
int i=0; //LCD출력을 위한 변수
flash BYTE seg_hexfont[2] = {0xc0,0xbf};
BYTE FND_selector[3]={0xBF, 0xDF, 0xEF};
BYTE seg_data[3]= {0xbf,0xbf,0xbf};
////////////////////////////////////////////////////////////
////////////////LCD출력을 위한 함수들///////////////////////
///////////////////////////////////////////////////////////
void initialize_PORT(void)
{
DDRA = 0xFF; // PORTA 출력
PORTA=0xFF;
DDRC = 0xFF; // PORTC 출력
PORTC=0xFF;
DDRD = 0xFF; // PORTD 출력
PORTD=0xFF;
}
interrupt [EXT_INT4] void RETRY (void)
{
lcd_clear(); // LCD를 지운다.
lcd_puts("password");
}
interrupt [EXT_INT5] void sw5 (void)
{
lcd_gotoxy(0,0);
lcd_puts("1");
}
interrupt [EXT_INT6] void sw6 (void)
{
lcd_gotoxy(0,1); // LCD를 지운다.
lcd_puts("2");
}
interrupt [EXT_INT7] void sw7 (void)
{
lcd_gotoxy(0,2); // LCD를 지운다.
lcd_puts("3");
}
void lcd_decimal(BYTE *ptr, BYTE hex)
{
unsigned int h;
*ptr = (hex / 1000);
if(h != 0)
char_out(h + '0');
else
char_out(0);
(*ptr+1)= ((hex % 1000) / 100);
if(h != 0)
char_out(h + '0');
else
char_out(0);
(*ptr+2)= (((hex % 1000) % 100) /10);
if(h != 0)
char_out(h + '0');
else
char_out(0);
*ptr+3)= (((hex % 1000) % 100) % 10);
if(h != 0)
char_out(h + '0');
else
char_out(0);
}
void lcd2hex(unsigned char ch)
{
unsigned char ddata=0x00, dch;
dch = (ch>>4)&0x0f;
if( dch <= 9 ) ddata = '0'+dch;
else ddata = 'A'+(dch-10);
char_out(ddata);
dch = ch&0x0f;
if( dch <= 9 ) ddata = '0'+dch;
else ddata = 'A'+(dch-10);
char_out(ddata);
}
unsigned char Key(void)
{
PORTE = 0x10;
delay_ms(5000); //포트의 출력이 완전하게 바뀐후에 비교를 하기위한 딜레이
{
if((PINE & 0x10) == 0x10)
return 0x30; // 0
else if((PINE & 0x20) == 0X20)
return 0x34; // 4
else if((PINE & 0x40) == 0X40)
return 0x38; // 8
else if((PINE & 0x80) == 0X80)
return 0x41; // A
}
PORTE = 0x20;
delay_ms(5000); //포트의 출력이 완전하게 바뀐후에 비교를 하기위한 딜레이
{
if((PINE & 0x10) == 0x10)
return 0x31; // 1
else if((PINE & 0x20) == 0X20)
return 0x35; // 5
else if((PINE & 0x40) == 0X40)
return 0x39; // 9
else if((PINE & 0x80) == 0X80)
return 0x42; // B
}
PORTE = 0x40;
delay_ms(5000); //포트의 출력이 완전하게 바뀐후에 비교를 하기위한 딜레이
{
if((PINE & 0x10) == 0x10)
return 0x32; // 2
else if((PINE & 0x20) == 0X20)
return 0x36; // 6
else if((PINE & 0x40) == 0X40)
return 0x2a; // *
else if((PINE & 0x80) == 0X80)
return 0x43; // C
}
PORTE = 0x80;
delay_ms(5000); //포트의 출력이 완전하게 바뀐후에 비교를 하기위한 딜레이
{
if((PINE & 0x10) == 0x10)
return 0x33; // 3
else if((PINE & 0x20) == 0X20)
return 0x37; // 7
else if((PINE & 0x40) == 0X40)
return 0x23; // #
else if((PINE & 0x80) == 0X80)
return 0x44; // D
}
return 0xff;
}
void sec_test(unsigned char b);
{
if(arr_cnt==8)
{
for(g=0;g<8;g++)
{
if(key_IN[g]==sec_num[g])
right++;
}
if(right==8)
{
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts("open");
delay_ms(500);
PORTC = seg_data[1];
PORTD = FND_selector[3];
lcd_clear(); // LCD를 지운다.
lcd_gotoxy(0,0);
lcd_puts("password"); // LCD의 첫번째 라인
arr_cnt=1;
right=1;
g=0;
s=0;
i=0;
}
else
{
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts("RETRY"); // LCD의 첫번째 라인
delay_ms(500);
PORTC = seg_data[2];
PORTD = FND_selector[3];
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts("password"); // LCD의 첫번째 라인
arr_cnt=1;
right=1;
g=0;
s=0;
i=0;
}
}
}
void main(void)
{
initialize_PORT();
lcd_clear(); // LCD를 지운다.
lcd_gotoxy(0,0);
lcd_putsf("password"); // LCD의 첫번째 라인
delay_ms(100); // 1초 대기
DDRE=0xff; // PE4 입력 DDRE4 비트는 초기값이 0으로 설정되어 있기 때문에
// "DDRE_Bit4=0;"는 생략 가능하다. INT4(PE4)핀
// DDRE&=0xEF;
EIMSK|=0x0f; // INT4 개별 인터럽트 인에이블
EICRB|=0xff; // INT4 상승 에지
EIFR|=0xf0; // INTF4 클리어
SREG=0x80;
while(1)
{
key=Key(); // 키 함수의 리턴값을 키에 받음
if(key!=0xff) // 그런데 그 키의 값이 0xff가 아니라면?
{
lcd_gotoxy(1,i); // LCD에 출력 위치
delay_ms(1000);
char_out(key); // 리턴 키 값을 출력하는 함수.
delay_ms(500);
i++;
sec_test(); //비밀번호 확인 함수
}
}
}
}
아래는 오류 내용입니다...****************************************************************************************
Error: D:\new\doorlock1.c(68): undefined symbol 'instruction_out'
Error: D:\new\doorlock1.c(73): undefined symbol 'char_out'
Error: D:\new\doorlock1.c(80): undefined symbol 'char_out'
Error: D:\new\doorlock1.c(87): undefined symbol 'char_out'
Error: D:\new\doorlock1.c(94): undefined symbol 'char_out'
Error: D:\new\doorlock1.c(106): undefined symbol 'char_out'
Error: D:\new\doorlock1.c(111): undefined symbol 'char_out'
Error: D:\new\doorlock1.c(190): '{' not expected
댓글 0
조회수 6,262등록된 댓글이 없습니다.