TDPS3

Dependencies:   mbed HC_SR04_Ultrasonic_Library

Committer:
QingshuZhang
Date:
Thu Mar 14 14:37:20 2019 +0000
Revision:
1:60ad9c191ea9
Parent:
0:aed6099bd419
TDPS3;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
QingshuZhang 0:aed6099bd419 1 #ifndef RobotControl_H
QingshuZhang 0:aed6099bd419 2 #define RobotControl_H
QingshuZhang 0:aed6099bd419 3
QingshuZhang 0:aed6099bd419 4 #include <mbed.h>
QingshuZhang 0:aed6099bd419 5
QingshuZhang 0:aed6099bd419 6 //RobotControl is used to control the direction and speed of the robot
QingshuZhang 0:aed6099bd419 7 //attributes : the pinouts of the enable and pwm forward and backwards
QingshuZhang 0:aed6099bd419 8 //methods : SetSpeed and SetDirection to set speed and set direction
QingshuZhang 0:aed6099bd419 9
QingshuZhang 0:aed6099bd419 10 class RobotControl
QingshuZhang 0:aed6099bd419 11 {
QingshuZhang 0:aed6099bd419 12 private:
QingshuZhang 0:aed6099bd419 13
QingshuZhang 0:aed6099bd419 14 DigitalOut m_motorEnable;
QingshuZhang 0:aed6099bd419 15 PwmOut m_motorBw;
QingshuZhang 0:aed6099bd419 16 PwmOut m_motorFw;
QingshuZhang 0:aed6099bd419 17 PwmOut* m_pwmPtr;
QingshuZhang 0:aed6099bd419 18
QingshuZhang 0:aed6099bd419 19 bool m_prevDir;
QingshuZhang 0:aed6099bd419 20
QingshuZhang 0:aed6099bd419 21
QingshuZhang 0:aed6099bd419 22 public:
QingshuZhang 0:aed6099bd419 23
QingshuZhang 0:aed6099bd419 24 bool m_dir;
QingshuZhang 0:aed6099bd419 25 float m_speed;
QingshuZhang 0:aed6099bd419 26
QingshuZhang 0:aed6099bd419 27 RobotControl(PinName pin1, PinName pin2, PinName pin3); //initializes the pins, direction and speed
QingshuZhang 0:aed6099bd419 28
QingshuZhang 0:aed6099bd419 29 void SetDirection(bool dir); //sets direction of robot, forward or backwards
QingshuZhang 0:aed6099bd419 30 void SetSpeed(float speed); //sets speed of robot regardless of direction
QingshuZhang 0:aed6099bd419 31
QingshuZhang 0:aed6099bd419 32 };
QingshuZhang 0:aed6099bd419 33
QingshuZhang 0:aed6099bd419 34
QingshuZhang 0:aed6099bd419 35
QingshuZhang 0:aed6099bd419 36
QingshuZhang 0:aed6099bd419 37 #endif