BASIC4MCU | 질문게시판 | 답변 : 89s51 코딩
페이지 정보
작성자 master 작성일2018-09-27 22:53 조회8,024회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=3227
본문
// MCU BASIC: https://www.basic4mcu.com// DateTime : 2018-09-27 오후 10:56:19// by Ok-Hyun Park//#include <reg51.h>//sbit LED=P2^0;sbit switch_pin=P0^0; //sound sensorcode 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){char cnt=10,flag=0;TMOD=0x20; SCON=0x50; TH1=0xfd; TL1=0xfd; TR1=1;switch_pin=1; LED=0;while(1){if(switch_pin==1){if(flag==0){ flag=1; cnt=0; txStr(msg1); LED=1; Delay(500); LED=0; }}else{if(flag==1){if(cnt<10){ if(++cnt==10)flag=0; }}}Delay(500);}}
else{if(flag==1){if(cnt<10){ if(++cnt==10)flag=0; }}}Delay(500);}}if()문의 체크 값과 딜레이로 노이즈 신호를 무시하는 시간이 결정 됩니다.
댓글 0
조회수 8,024등록된 댓글이 없습니다.