Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
LineFollowingRobot/L298_H.h@6:b457f1e2fff8, 2019-03-14 (annotated)
- Committer:
- Nicolaemf
- Date:
- Thu Mar 14 10:37:05 2019 +0000
- Revision:
- 6:b457f1e2fff8
- Child:
- 7:b9c2097e5cb2
l298 header added;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nicolaemf | 6:b457f1e2fff8 | 1 | #ifndef L298_H |
Nicolaemf | 6:b457f1e2fff8 | 2 | #define L298_H |
Nicolaemf | 6:b457f1e2fff8 | 3 | |
Nicolaemf | 6:b457f1e2fff8 | 4 | #include <mbed.h> |
Nicolaemf | 6:b457f1e2fff8 | 5 | |
Nicolaemf | 6:b457f1e2fff8 | 6 | //RobotControl is used to control the direction and speed of the robot |
Nicolaemf | 6:b457f1e2fff8 | 7 | //attributes : the pinouts of the enable and pwm forward and backwards |
Nicolaemf | 6:b457f1e2fff8 | 8 | //methods : SetSpeed and SetDirection to set speed and set direction |
Nicolaemf | 6:b457f1e2fff8 | 9 | |
Nicolaemf | 6:b457f1e2fff8 | 10 | class L298 |
Nicolaemf | 6:b457f1e2fff8 | 11 | { |
Nicolaemf | 6:b457f1e2fff8 | 12 | private: |
Nicolaemf | 6:b457f1e2fff8 | 13 | |
Nicolaemf | 6:b457f1e2fff8 | 14 | DigitalOut m_motorBw; |
Nicolaemf | 6:b457f1e2fff8 | 15 | DigitalOut m_motorFw |
Nicolaemf | 6:b457f1e2fff8 | 16 | PwmOut m_motorEnable; |
Nicolaemf | 6:b457f1e2fff8 | 17 | |
Nicolaemf | 6:b457f1e2fff8 | 18 | |
Nicolaemf | 6:b457f1e2fff8 | 19 | bool m_prevDir; |
Nicolaemf | 6:b457f1e2fff8 | 20 | |
Nicolaemf | 6:b457f1e2fff8 | 21 | |
Nicolaemf | 6:b457f1e2fff8 | 22 | public: |
Nicolaemf | 6:b457f1e2fff8 | 23 | |
Nicolaemf | 6:b457f1e2fff8 | 24 | bool m_dir; |
Nicolaemf | 6:b457f1e2fff8 | 25 | float m_speed; |
Nicolaemf | 6:b457f1e2fff8 | 26 | |
Nicolaemf | 6:b457f1e2fff8 | 27 | L298(PinName pin1, PinName pin2, PinName pin3); //initializes the pins, direction and speed |
Nicolaemf | 6:b457f1e2fff8 | 28 | |
Nicolaemf | 6:b457f1e2fff8 | 29 | void SetDirection(bool dir); //sets direction of robot, forward or backwards |
Nicolaemf | 6:b457f1e2fff8 | 30 | void SetSpeed(float speed); //sets speed of robot regardless of direction |
Nicolaemf | 6:b457f1e2fff8 | 31 | |
Nicolaemf | 6:b457f1e2fff8 | 32 | }; |
Nicolaemf | 6:b457f1e2fff8 | 33 | |
Nicolaemf | 6:b457f1e2fff8 | 34 | |
Nicolaemf | 6:b457f1e2fff8 | 35 | |
Nicolaemf | 6:b457f1e2fff8 | 36 | |
Nicolaemf | 6:b457f1e2fff8 | 37 | #endif |