Qingshu Zhang / Mbed 2 deprecated new_HC-SR504

Dependencies:   mbed HC_SR04_Ultrasonic_Library

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RobotControl_H.h Source File

RobotControl_H.h

00001 #ifndef RobotControl_H
00002 #define RobotControl_H
00003 
00004 #include <mbed.h>
00005 
00006 //RobotControl is used to control the direction and speed of the robot
00007 //attributes : the pinouts of the enable and pwm forward and backwards
00008 //methods : SetSpeed and SetDirection to set speed and set direction
00009 
00010 class RobotControl
00011 {
00012 private:
00013     
00014     DigitalOut m_motorEnable;
00015     PwmOut m_motorBw;
00016     PwmOut m_motorFw;
00017     PwmOut* m_pwmPtr;
00018     
00019     bool m_prevDir;
00020     
00021     
00022 public:
00023     
00024     bool m_dir;
00025     float m_speed;
00026     
00027     RobotControl(PinName pin1, PinName pin2, PinName pin3); //initializes the pins, direction and speed
00028     
00029     void SetDirection(bool dir);        //sets direction of robot, forward or backwards
00030     void SetSpeed(float speed);         //sets speed of robot regardless of direction
00031     
00032 };
00033 
00034 
00035 
00036 
00037 #endif