Robson Cardoso dos Santos / Sophia
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Sophia.cpp Source File

Sophia.cpp

00001 #include "mbed.h"
00002 #include "Motor.h"
00003 #include "Sophia.h"
00004 
00005 Motor motor_right(PTD4, PTC13, PTC12);    // pwm, fwd, rev
00006 Motor motor_left(PTD4, PTA13, PTD5);
00007 
00008 void Sophia::move(float speed, int direction) {
00009     if(direction) {
00010         motor_right.speed(speed);
00011         motor_left.speed(speed);
00012     }
00013     else {
00014         motor_right.speed(-speed);
00015         motor_left.speed(-speed);    
00016     }
00017 }
00018 
00019 void Sophia::turn(float speed, int direction) {
00020     if(direction) {
00021         motor_right.speed(0.0);
00022         motor_left.speed(speed);
00023     }
00024     else {
00025         motor_right.speed(speed);
00026         motor_left.speed(0.0);
00027     }
00028 }
00029 void Sophia::spin(float speed, int direction) {
00030     if(direction) {
00031         motor_right.speed(-speed);
00032         motor_left.speed(speed);
00033     }
00034     else {
00035         motor_right.speed(speed);
00036         motor_left.speed(-speed);
00037     }
00038 }