BASIC4MCU | 질문게시판 | 답변 : 박옥현님 네이버 질문에 답달아주신거 추가질문입니다 .ㅠ
페이지 정보
작성자 master 작성일2018-12-01 21:00 조회6,744회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=6127
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-12-01 오후 9:05:28// by Ok-Hyun Park//#include <avr/io.h>#define F_CPU 16000000UL#include <util/delay.h>//char seg[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7c,0x07,0x7f,0x67};//char RX0_char(void){ while(!(UCSR0A&0x80)); return UDR0; }//char RX1_char(void){ while(!(UCSR1A&0x80)); return UDR1; }//void TX0_char(char c){ while(!(UCSR0A&0x20)); UDR0=c; }//void TX1_char(char c){ while(!(UCSR1A&0x20)); UDR1=c; }//void TX0_STR(char*s){ while(*s)TX0_char(*s++); }//void TX1_STR(char*s){ while(*s)TX1_char(*s++); }//void init(){ i=0; count=3000; PORTB=0; PORTC=0; PORTG=0; }//int main(void){char mode=0,r,c; int i=0,count=0;DDRC=0x0ff; DDRG=0x0f; DDRB=0x10;UCSR0B=0x18; UBRR0L=103; // 9600//UCSR1B=0x18; UBRR1L=103; // 9600while(1){if(UCSR0A&0x80){r=UDR0;if(r=='1'){ mode=1; init(); PORTB=0x10; } //1.Test LEDif(r=='2'){ mode=2; init(); } //2.Test FNDif(r=='3'){ mode=3; init(); PORTB=0x10; } // 3.Test Buzzerif(r=='4'){ mode=3; init(); PORTB=0x10; } // 4.Test All}//if(count){if(mode==1){if(++i>=250){ i=0; PORTB^=0x10; } // 1.Test LED}if(mode==2){PORTC=seg[c+1]; PORTG=8>>c; if(++c>3)c=0; // 2.Test FND}if(mode==3){PORTB^=0x10; // 3.Test Buzzer}if(mode==4){ // 4.Test AllPORTC=seg[c+1]; PORTG=8>>c; if(++c>3)c=0; //2.Test FNDPORTB^=0x10; // 3.Test Buzzer}if(--count==0)init();}_delay_ms(1);}}
일단 돌려보세요
댓글 0
조회수 6,744등록된 댓글이 없습니다.