TomYumBoys / Mbed 2 deprecated MM2017

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers right_motor.cpp Source File

right_motor.cpp

00001 #include "right_motor.h"
00002 PwmOut motor_channelA(PB_9);
00003 PwmOut motor_channelB(PB_8);
00004 
00005 RightMotor::RightMotor() {
00006  
00007     motor_channelA.period_us(50);
00008     motor_channelB.period_us(50);
00009 }
00010 
00011 //Sets motor speed
00012 void RightMotor::speed(float speed) {
00013 
00014     if(speed < 0.0f){
00015         motor_channelA.write(-speed/100);
00016         motor_channelB.write(0);
00017     }
00018     else{
00019         motor_channelB.write(speed/100);
00020         motor_channelA.write(0); 
00021     }
00022 }
00023 
00024 //void RightMotor::set_period(float period) {
00025 //    motor_right_sig.period(period);
00026 //}
00027 
00028 //Sets motor speed to 0
00029 void RightMotor::stop() {
00030     
00031     motor_channelB.write(0);
00032     motor_channelA.write(0);
00033 }