This commit is contained in:
Nebel 2012-08-30 09:14:41 +09:00
parent 7c24307b16
commit c37c972d1e

View file

@ -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に応じて相対移動