zhouhang shao
/
test
test
Embed:
(wiki syntax)
Show/hide line numbers
motor.cpp
00001 /* 00002 #include "motor.h" 00003 #include "mbed.h" 00004 const int ONE_MILLISECOND = 0.001; 00005 00006 Motor::Motor(PinName curr_pwm_pin, PinName curr_dir): 00007 pwm_pin(_pwm_pin), dir(_dir){ 00008 pwm_pin(curr_pwm_pin); 00009 dir(curr_dir); 00010 00011 pwm_pin.period(ONE_MILLISECOND); 00012 pwm_pin.write(0.1f); 00013 dir = 0; 00014 curr_speed = 0; 00015 } 00016 00017 //Sets motor speed 00018 void Motor::speed(float speed) { 00019 curr_speed = speed; 00020 pwm_pin.write(speed); 00021 } 00022 00023 //Sets motor speed to 0 00024 void Motor::stop() { 00025 speed(0); 00026 } 00027 00028 */
Generated on Sun Sep 11 2022 08:09:41 by 1.7.2