diff --git a/arduino/catchrobo2012/catchrobo2012.ino b/arduino/catchrobo2012/catchrobo2012.ino index 5e7de7e..5450960 100644 --- a/arduino/catchrobo2012/catchrobo2012.ino +++ b/arduino/catchrobo2012/catchrobo2012.ino @@ -16,16 +16,12 @@ #define PIN_PWR A3 #define PIN_GND A2 -int loop_cnt = 0; Servo base; Servo catcher; WiiNun wiiNun; Motor horMotor; Motor verMotor; -byte baseDeg = 90; -byte catcherDeg = 90; - void setup(){ pinMode(PIN_PWR, OUTPUT); pinMode(PIN_GND, OUTPUT); @@ -64,12 +60,14 @@ void loop(){ // char ax = (char)(accx-0x7F); char ay = (char)(accy-0x7F); // 水平状態を0にする + byte baseDeg = 90; + byte catcherDeg = 90; if(zbut){ // zボタン押しながら digitalWrite(PIN_LED, HIGH); if(y>0x1F) baseDeg = 180 - atan2(y, x)*180/PI; // 台座をスティックの角度にする if(baseDeg < 10) baseDeg = 10; else if(baseDeg > 170) baseDeg = 170; - }else{ // zボタン離すと + }else{ // zボタン離しながら digitalWrite(PIN_LED, LOW); horMotor.speed(y); baseDeg += x/32; // 台座をxに応じて相対移動