BASIC4MCU | 질문게시판 | 답변 : 답변 : 답변 : 답변 : 코드에러
페이지 정보
작성자 master 작성일2018-09-13 13:39 조회6,944회 댓글1건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=3073
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-09-13 오후 1:43:34// by Ok-Hyun Park//#include <reg51.h>//sbit sound=P0^0; // sound sensor//sbit m1f=P2^0; // in1 pin of motor1sbit m1b=P2^1; // in2 pin of motor1sbit m2f=P2^2; // in1 pin of motor2sbit m2b=P2^3; // in2 pin of motor2//code char msg1[]="robot is moving forward";code char msg2[]="robot is moving backward";code char msg3[]="robot is moving right";code char msg4[]="robot is moving left";code char msg5[]="robot is stopped";//code char Smsg[]="Sound Sensor Detected";//void delay_us(unsigned int us){ while(us--); }void delay_ms(unsigned int ms){ while(ms){ delay_us(112); ms--; } }void delay_sec(unsigned char sec){ while(sec){ delay_ms(1000); sec--; } }//char rxdata(void){ while(!RI); RI=0; return SBUF; }void txdata(char x){ while(!TI); TI=0; SBUF=x; }void txStr(char*s){ while(*s)txdata(*s++); }//void main(void){unsigned char s;TMOD=0x20;SCON=0x50;TH1=0xfd;TR1=1;while(1){if(RI){s=rxdata();if(s=='f'){ m1f=1; m1b=0; txStr(msg1); }if(s=='b'){ m1f=0; m1b=1; txStr(msg2); }if(s=='r'){ m1f=1; m1b=0; txStr(msg3); }if(s=='l'){ m1f=0; m1b=1; txStr(msg4); }if(s=='s'){ m1f=0; m1b=0; txStr(msg5); }}//if(sound){ // sound 감지하면txStr(Smsg);m1f=1; m1b=0; // fwddelay_ms(1000);m1f=0; m1b=0; // stopdelay_sec(1);}}}
댓글 1
조회수 6,944디코랩님의 댓글
디코랩 작성일감사합니다 . 오류가 자꾸나서 다른 컴퓨터로 옮겨서 실행했는데 잘 컴파일 되었습니다.