[아두이노] Otto Bot and Bluetooth

이전 단순 Otto조립에서 추가로 Bluetooth를 연동하여 핸드폰 조정을 도전해 보았답니다.

집에 보유하고 있는 Bluetooth모듈이 HC-05와 HC-06이었으며 설정으로 Bluetooth의 이름/암호 변경으로 꽤 오랜 시간 동안 삽질을 하게 되었습니다. 


 추후 Bluetooh의 설정 및 문제되었던 부분에 대해서 정리하여 공유 하도록 하겠습니다.


사용 Source는 Git Hub에서 받으시면 됩니다. (상단 링크 참조)



cd6b0d5e5a1d3c2573747c39411a0aee.jpg



APP의 앤인벤터와 Bluetooth codes의 OTTO_BT_easy 아두이노를 사용할 하였습니다.


212f4f13962d47fb1467272911940334.jpg

앱 인벤터 화면의 사용 핸드폰이 화면 크기에 맞추는 정도의 작업 필요하며, 블록에서 Bluetooth에 보내는 캐릭터 문자를 U D L R을 사용하는 아두이노 소스에 맞도록 수정 작업 진행 하였다


a3fc578cdb2e8b5894c9d69290381515.jpg

제공된 아두이노 소스가 프로그램 Upload의 번거로움이 있어  10,11Pin을 활용한 Software Serial로 일부 코드를 수정 하였다.

#define PIN_BLUETOOTH_RX  10 

#define PIN_BLUETOOTH_TX  11


/////////////////////////////////////////////////////////////////////

//  Setup

///////////////////////////////////////////////////////////////////

void setup(){

  

  Serial.begin( 9600 ); //setup your bluetooth module to match this baudrate (or change it here) (https://github.com/OttoDIY/OttoDIY)


  BTSerial.begin( 9600 );


  //

  //  Set the servo pins

  //

  Otto.init(PIN_YL,PIN_YR,PIN_RL,PIN_RR,true);

  Otto.sing(S_connection); //Otto wake up!

  Otto.home();

  delay(50);

  

  Otto.sing(S_happy); // a happy Otto :)

}


///////////////////////////////////////////////////////////////////

//-- Principal Loop ---------------------------------------------//

///////////////////////////////////////////////////////////////////

void loop() {


  //----------------------------------------------------------------

  //  If something received over bluetooth, store the char

  //----------------------------------------------------------------

  if( Serial.available() ) 

    dato= Serial.read();


  if( BTSerial.available() ) 

    dato= BTSerial.read();

  

  //----------------------------------------------------------------

  // check the char received

  //----------------------------------------------------------------

  switch(dato)

  {//if we receive a...

  case 85: //"U": Up arrow received

        {

          Otto.walk(2,1000,1); //2 steps FORWARD

        }

        break;        

       

  case 68: //"D": Down arrow received

         {

            Otto.walk(2,1000,-1); //2 steps FORWARD

         }

        break;


  case 67: //"C": Center button received

         {

           Otto.playGesture(OttoFretful);

           Otto.home();

           Otto.sing(S_sleeping);

           delay(1000);

         }

        break;         

         

  case 76: //"L": Left arrow received

        {

          Otto.turn(2,1000,1);//2 steps turning RIGHT                

          delay(50);

        }

        break;        

         

  case 82: //"R": Right arrow received

         {

            Otto.turn(2,1000,-1);//2 steps turning RIGHT                

            delay(50);

         }

        break;         

         

  case 97: // "a" Received

        {

          Otto.moonwalker(3, 1000, 25, 1);

          Otto.home();

        }

        break;         

         

  case 98: // "b" Received

        {

          Otto.bend (1, 2000, 1);

          Otto.home();

        }

        break;                   

         

  case 99: // "c" Received

        {

          Otto.ascendingTurn(1, 2000, 22);

          Otto.home();

        }

        break;                   

         

   case 100: // "d" Received

        {

          Otto.updown(1, 2000, 22);

          Otto.home();        

        }

        break;          

         

  case 101: // "e" Received----OBSTACLE MODE ON!!!! (until a button is pressed in the app)------

        {

          obstacleMode();

        }

        break;                   

        //////////You can add different modes here with the other buttons in the app (f,g,h...)

  }

  dato=0; //clears the incoming data until it receives the next button from app

}

 


핸드폰에 인벤터 설치 후 Otto Bot의 전진 / 후직 / 왼쪽은 정상 동작하나 오른쪽 이상 동작하여 현재 관련 원인을 분석중에 있나, 혹 해결 되신분 정보 공유 부탁 드립니다.


void Otto::turn(float steps, int T, int dir){

//-- Same coordination than for walking (see Otto::walk)
//-- The Amplitudes of the hip's oscillators are not igual
//-- When the right hip servo amplitude is higher, the steps taken by
//-- the right leg are bigger than the left. So, the robot describes an
//-- left arc
int A[4]= {30, 30, 20, 20};
int O[4] = {0, 0, 4, -4};
double phase_diff[4] = {0, 0, DEG2RAD(-90), DEG2RAD(-90)};
if (dir == LEFT) {

A[0] = 30; //-- Left hip servo
A[1] = 10; //-- Right hip servo
}
else {
A[0] = 10;
A[1] = 30;

}
//-- Let's oscillate the servos!
_execute(A, O, T, phase_diff, steps);
}

Otto libraries 파일중 trun함수 부분 중 일부 조정이 필요하지 않을까 판단 됩니다. 



0
0
이 글을 페이스북으로 퍼가기 이 글을 트위터로 퍼가기 이 글을 카카오스토리로 퍼가기 이 글을 밴드로 퍼가기

메이커 스토리

번호 제목 글쓴이 날짜 조회수
87 일반 반려 동물 심폐 소생 시뮬레이터 icon 양재동메이커 09-26 14,563
86 일반 3D Printed Record icon HellMaker 09-05 14,790
85 일반 배터리 잔량 측정기 만들기 (마이크로 비트) icon HellMaker 09-04 18,253
84 아두이노 용인 ICT 스마트 다비아스 톤 - 아침에는 시간이 부족해 icon 양재동메이커 08-04 15,372
83 아두이노 아두이노 이용한 RC, 블루투스 배틀로봇의 외형 자료 icon 양재동메이커 07-25 15,629
82 아두이노 아두이노(아두이노 모터쉴드)를 이용한 RC, 블루투스 배틀로봇 +1 Wavy 07-22 16,161
81 아두이노 팬틸트를 활용한 태양 추적 장치의 개발 icon 양재동메이커 07-15 14,981
80 아두이노 미세먼지 조립 키트 조립기 icon 양재동메이커 07-10 15,262
79 아두이노 오또봇과 형제들 icon 양재동메이커 07-07 16,912
78 일반 김메모 - 미세먼지 관련 인식도 조사 결과 및 분석 icon 양재동메이커 06-17 16,655
77 아두이노 Otto Bot and Bluetooth icon 양재동메이커 06-08 15,860
76 아두이노 Tokyo Nana의 오또봇(Otto Bot) 제작기 1탄 Tokyonana 06-05 15,157
75 아두이노 오또봇 기본형 만들기 - 오또봇(Otto Bot) 조립 하기 +1 icon 양재동메이커 05-25 20,988
74 아두이노 양변기 자동 물내림 장치-2 절전 모드/저 전력 모드 +2 icon 양재동메이커 05-09 20,545
73 아두이노 DIY Longboard Electrification icon 양재동메이커 04-29 15,909
72 일반 2019년 4월 19일 DIY 청계천도사 프로젝트 진행 +1 icon 청계천도사 04-18 15,461
71 일반 김메모 와 헬메이커 2번째 협업 : 잡초제거 로봇 요구 분석 +2 icon 양재동메이커 04-14 17,407
70 아두이노 Automatic Model Train Control with Arduino icon 양재동메이커 04-11 16,528
69 일반 사랑의 독거 노인 도시락 MBED 프로그램 설명 icon 양재동메이커 04-04 15,084
68 일반 무게를 재는 방법에 대한 고찰 icon 양재동메이커 04-02 18,184