TomYumBoys / Mbed 2 deprecated MM2017

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers left_motor.cpp Source File

left_motor.cpp

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