BASIC4MCU | 질문게시판 | 답변 : 89s51블루투스 코딩
페이지 정보
작성자 master 작성일2018-09-21 23:30 조회9,643회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=3198
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-09-21 오후 11:33:02// by Ok-Hyun Park//#include <reg51.h>//sbit LED=P2^0;sbit switch_pin=P0^0;code char msg1[]="robot is moving forward";//void Delay(int k){int j,i;for(i=0;i<k;i++){ for(j=0;j<100;j++); }}//void txdata(char x){ SBUF=x; while(!TI); TI=0; }void txStr(char *s){ while(*s)txdata(*s++); }//void main(void){TMOD=0x20; SCON=0x50; TH1=0xfd; TL1=0xfd; TR1=1;switch_pin=1; LED=1;while(1){if(switch_pin==1){ //If switch pressedtxStr(msg1);LED=0; Delay(500); LED=1; Delay(500);}}}이 코드로 돌려보세요
void txdata(char x){ while(!TI); TI=0; SBUF=x; }TI를 먼저 체크 할 때는 메인 초기에 TI=1; 설정 해둬야합니다.송신 한 적이 없는데 송신 완료를 기다리면 무한루프에 빠지겠죠
댓글 0
조회수 9,643등록된 댓글이 없습니다.