BASIC4MCU | 질문게시판 | 아두이노 RC카 소스코드 작성중 어려움이 있어 도움 부탁드립니다.
페이지 정보
작성자 쿤싼 작성일2019-11-04 14:30 조회3,246회 댓글0건
https://www.basic4mcu.com/bbs/board.php?bo_table=gac&wr_id=10529
본문
void loop(){front_detection();if(Front_Distance<20){back(2); brake(2);left_detection(); Distance_display(Left_Distance);right_detection(); Distance_display(Right_Distance);//if ((Left_Distance<20)&&(Right_Distance<20)){ spin_left(0.7); }else if(Left_Distance>Right_Distance ){ left(10); brake(1); }else { right(10); brake(1); }}else{ run(); }}이상황에서 저희가 설정을 바꾸고 싶어서 아래와 같이 소스코드를 추가하여 바꾼 부분인데 뜻한데로 실행이 되지 않아서 도움 요청드립니다..void loop(){front_detection(); //앞쪽 장애물 발견if(Front_Distance<20){ //거리가 20미만back(2); brake(2); //뒤로 2, 멈춤 2left_detection(); Distance_display(Left_Distance); //왼쪽 장애물 발견right_detection(); Distance_display(Right_Distance); //오른쪽 장애물 발견//if ((Left_Distance<20)&&(Right_Distance<20)) //IF문 (왼쪽<20), (오른쪽<20)인 경우{if (Left_Distance>Right_Distance) {spin_left(0.7); brake(1);} // IF문 왼쪽>오른쪽 경우 오른쪽으로 (0.7)스핀else {spin_right(0.7); brake(1);} // 그 외 오른쪽 (0.7)스핀}else if(Left_Distance>Right_Distance ){ left(10); brake(1); } //IF문 왼쪽>오른쪽 (왼쪽 10), (멈춤 1)else { right(10); brake(1); } //IF문 왼쪽<오른쪽 (오른쪽 10), (멈춤 1)}else{ run(); } //그 외 전진}저희가 설계하고 싶은 부분은 좌우측 20보다 작을때 이경우에서 또 왼쪽이 오른쪽보다 클경우 왼쪽 스핀 그리고 왼쪽이 오른쪽보다 작을 경우 오른쪽 스핀설정을 넣고 싶은데 나름 해본다고 시도하여도 계속 실패하여 질문드립니다. 아두이노 초보라 많이 배워가고 싶습니다....
댓글 0
조회수 3,246등록된 댓글이 없습니다.