BASIC4MCU | 질문게시판 | 아트메가 공부중에 질문있습니다..
페이지 정보
작성자 suid82 작성일2022-05-23 14:50 조회398회 댓글1건본문
만드는 목적은 심박센서의 값을 읽어 lcd에 표시하고 앱인벤터를 사용하여 블루투스를 이용해 핸드폰에 설정하게 만드는 것이 목표입니다
#include <avr/io.h>
//
#define BAUD_DIV (F_CPU/8/BAUD - 1)
#define BAUD_DIV_H BAUD_DIV>>8
#define BAUD_DIV_L BAUD_DIV
#define BAUD 9600 // 115200 for JMOD-BT-1, 9600 for fb155bc, 38400 for HC-05, 9600 for HC-06
//
#define LCD_DATA PORTA
#define LCD_INST PORTA
#define LCD_CTRL PORTG
#define LCD_RS_1 PORTG|=0x04 //PG2
#define LCD_RS_0 PORTG&=~0x04 //PG2
#define LCD_RW_1 PORTG|=0x08 //PG3
#define LCD_RW_0 PORTG&=~0x08 //PG3
#define LCD_EN_1 PORTG|=0x10 //PG4
#define LCD_EN_0 PORTG&=~0x10 //PG4
//
#define ON 1
#define OFF 0
//
char str2[40]="NORMAL";
char str4[40]="LOW";
char str5[40]="Hypertension";
char str6[40]="Put Your finger";
char str7[40]="please!";
char buf[40];
char ch[100];
//
unsigned int tmr_cnt=0,temp=0,cnt=0;
long sum=0;
//
void LCD_data(char d){ LCD_DATA=d; LCD_CTRL=0x14; _delay_us(1); LCD_CTRL=4; _delay_us(50); }
void LCD_comd(char c){ LCD_DATA=c; LCD_CTRL=0x10; _delay_us(1); LCD_CTRL=0; _delay_ms( 5); }
void LCD_CHAR(char c){ LCD_data(c); }
void LCD_STR(char *s){ while(*s)LCD_CHAR(*s++); }
void LCD_pos(char col,char row){ LCD_comd(0x80|(col+row*0x40)); }
void LCD_clear(void){ LCD_comd(1); }
//
void LCD_init(void){
_delay_ms(100);
LCD_comd(0x38); LCD_comd(0x38); LCD_comd(0x38);
LCD_comd(0x0E); LCD_comd(0x06); LCD_clear();
}
//------------------------------------------------
void TX0_CH(char c){ while(!(UCSR0A&0x20)); UDR0=c; } // 1바이트 송신
void TX0_STR(char *s){ while(*s)TX0_CH(*s++); } // 문자열 송신
//------------------------------------------------
void senddata (void){ TX0_CH(0xf1); TX0_CH((char)temp); }
//
ISR(INT0_vect){
tmr_cnt=TCNT1;
PORTB&=0xFE;
if(tmr_cnt>5200){ //5200*64us=332.8ms 이상
TCNT1=0;
sum+=tmr_cnt;
if(++cnt>=8){ cnt=0;
sum/=8;
temp=(unsigned int)(937500L/sum); // 60000000UL/(tmr_cnt*64)
sprintf(buf,"HeartRate:%dbpm",temp); LCD_clear(); LCD_pos(0,0); LCD_STR(buf);
senddata();
if (temp< 60){ LCD_pos(0,1); LCD_STR(str4); } // TEMP값이 60보다 낮으면
else if(temp>100){ LCD_pos(0,1); LCD_STR(str5); } // TEMP값이 100보다 크면
else { LCD_pos(0,1); LCD_STR(str2); } // TEMP값이 60보다 크고 100보다 작으면
sum=0;
}
PORTC=1<<cnt;
sprintf(buf,"%d\r\n",temp); TX0_STR(buf);
}
}
//
int main(void){
DDRA=0xFF; DDRB=0x01; DDRC=0xFF; DDRG=0xFF;
UCSR0A=2; UCSR0B=0x18; UBRR0H=BAUD_DIV_H ; UBRR0L=BAUD_DIV_L;
UCSR1A=2; UCSR1B=0x18; UBRR1H=BAUD_DIV_H ; UBRR1L=BAUD_DIV_L;
LCD_init();
LCD_pos(0,0); LCD_STR(str6);
LCD_pos(0,1); LCD_STR(str7);
//
TCCR1B=5;
EICRA=2; EIFR=1; EIMSK=1;
SREG=0x80;
while(1){
if(temp== 10){ UDR1=49; _delay_ms(60); UDR1=48; _delay_ms(60); }
if(temp== 11){ UDR1=49; _delay_ms(60); UDR1=49; _delay_ms(60); }
if(temp== 12){ UDR1=49; _delay_ms(60); UDR1=50; _delay_ms(60); }
if(temp== 13){ UDR1=49; _delay_ms(60); UDR1=51; _delay_ms(60); }
_delay_ms(1500);
if(temp== 14){ UDR1=49; _delay_ms(60); UDR1=52; _delay_ms(60); }
if(temp== 15){ UDR1=49; _delay_ms(60); UDR1=53; _delay_ms(60); }
if(temp==193){ UDR1=49; _delay_ms(50); UDR1=57; _delay_ms(50); UDR1=51; _delay_ms(50); }
if(temp==194){ UDR1=49; _delay_ms(50); UDR1=57; _delay_ms(50); UDR1=52; _delay_ms(50); }
if(temp==195){ UDR1=49; _delay_ms(50); UDR1=57; _delay_ms(50); UDR1=53; _delay_ms(50); }
if(temp==196){ UDR1=49; _delay_ms(50); UDR1=57; _delay_ms(50); UDR1=54; _delay_ms(50); }
if(temp==197){ UDR1=49; _delay_ms(50); UDR1=57; _delay_ms(50); UDR1=55; _delay_ms(50); }
if(temp==198){ UDR1=49; _delay_ms(50); UDR1=57; _delay_ms(50); UDR1=56; _delay_ms(50); }
if(temp==199){ UDR1=49; _delay_ms(50); UDR1=57; _delay_ms(50); UDR1=57; _delay_ms(50); }
_delay_ms(1500);
if(PIND&1)PORTB|=1; else PORTB&=~1;
}
}
이런 에러가 뜨는데 뭐가 문제인지 잘 모르겠습니다 도와주세요
Error recipe for target 'main.o' failed GccApplication3
Error expected constructor, destructor, or type conversion before '(' token
댓글 1
조회수 398master님의 댓글
master 작성일
오류를 클릭하면 커서가 해당 라인으로 이동합니다.
오류는 그 라인에 있을 수도 있고, 윗 라인에 있을 수도 있습니다.
//
다른 컴퓨터에서 정상적으로 컴파일 되었었다면
새 프로젝트를 만들어서 복사해서 다시 컴파일 하세요