Cansatモータテスト用です。
Dependencies: mbed
Diff: main.cpp
- Revision:
- 0:b7ec2678555c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Aug 10 10:53:13 2018 +0000 @@ -0,0 +1,62 @@ +#include "mbed.h" + +DigitalOut motor1(p21); +DigitalOut motor2(p22); +DigitalOut motor3(p23); +DigitalOut motor4(p24); + +void Brake(); +void Turn(); +void Return(); +void Right(); +void Left(); + +int main() { + while(1) { + Turn(); + wait(3); + Return(); + wait(3); + Right(); + wait(3); + Left(); + wait(3); + Breky(); + wait(3); + } +} + +void Breky(){ + motor1 = 0; + motor2 = 0; + motor3 = 0; + motor4 = 0; +} + +void Turn(){ + motor1 = 1; + motor2 = 0; + motor3 = 1; + motor4 = 0; +} + +void Return(){ + motor1 = 0; + motor2 = 1; + motor3 = 0; + motor4 = 1; +} + +void Left(){ + motor1 = 1; + motor2 = 0; + motor3 = 0; + motor4 = 1; +} + +void Right(){ + motor1 = 0; + motor2 = 1; + motor3 = 1; + motor4 = 0; +} \ No newline at end of file