淳熙 姜
/
JOYSTICK_control
いろんな出力のお試しコード
Diff: main.cpp
- Revision:
- 1:b4d995953362
- Parent:
- 0:2ea8da556ef4
- Child:
- 2:a8e6713fbe41
diff -r 2ea8da556ef4 -r b4d995953362 main.cpp --- a/main.cpp Thu May 14 08:34:54 2015 +0000 +++ b/main.cpp Sat May 16 06:30:14 2015 +0000 @@ -10,16 +10,15 @@ DigitalInOut Bbutton(dp26); //デジタル出力ピン(モーター)の指定 -//今回のみオープンドレインを用いて行う -DigitalInOut motorA(dp5); -DigitalInOut motorB(dp27); +DigitalInOut motorA(dp4); +DigitalInOut motorB(dp6); //デジタル出力ピン(LED)の指定 DigitalInOut myLED(LED1); //アナログ読み取りピンの指定 -AnalogIn JOYstick_LR(dp4); -AnalogIn JOYstick_UD(dp13); +AnalogIn JOYstick_LR(dp9); +AnalogIn JOYstick_UD(dp10); //PWM出力ピン(モーター?)の指定 PwmOut motorLR(dp1); @@ -32,8 +31,8 @@ //初期設定 myLED = LOW; - motorA = OD_LOW; - motorB = OD_LOW; + motorA = LOW; + motorB = LOW; motorLR = LOW; motorUD = LOW; @@ -76,25 +75,25 @@ //タクトスイッチ(Aボタン)が押されていれば"A"を表示.モータ正回転 if(Abutton == HIGH && Bbutton == LOW){ Controller.printf("A \n"); - motorA = OD_HIGH; - motorB = OD_LOW; + motorA = HIGH; + motorB = LOW; } //タクトスイッチ(Bボタン)が押されていれば"B"を表示.モータ逆回転 else if(Abutton == LOW && Bbutton == HIGH){ Controller.printf("B \n"); - motorA = OD_LOW; - motorB = OD_HIGH; + motorA = LOW; + motorB = HIGH; } //タクトスイッチ(AボタンとBボタン)が押されていれば"AとB"を表示.モータは動かない else if(Abutton == HIGH && Bbutton == HIGH){ Controller.printf("A and B \n"); - motorA = OD_HIGH; - motorB = OD_HIGH; + motorA = HIGH; + motorB = HIGH; } //何も押されていなければ、何も表示しない.モータは動かない else{ - motorA = OD_HIGH; - motorB = OD_HIGH; + motorA = HIGH; + motorB = HIGH; } //100ms待機