BASIC4MCU | 질문게시판 | 답변 : 터치센서를 이용한 아두이노 선풍기 코딩 도와주십시오
페이지 정보
작성자 master 작성일2018-12-11 23:06 조회6,790회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=6740
본문
//const int switchPin=7;const int motorPin=9;//int switchState=0;int motorState=0;//void setup(){pinMode(motorPin,OUTPUT);pinMode(switchPin,INPUT);}//void loop(){if(digitalRead(switchPin)){if(switchState==0){ switchState=1;if(motorState){ motorState=0; digitalWrite(motorPin,LOW); }else { motorState=1; digitalWrite(motorPin,HIGH); }}}else switchState=0;}//-------------------------------------------------------------------------터치센서를 누르면 선풍기가 켜지고,다시 한번 더 누르면 선풍기가 꺼지도록하고 싶은데안됩니다ㅠㅠㅠ내일 시험인데 제발 도와주십시오!
댓글 0
조회수 6,790등록된 댓글이 없습니다.