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/IRSensor_H.h@1:a2ceed49374e, 2019-02-02 (annotated)
- Committer:
- Nicolaemf
- Date:
- Sat Feb 02 16:11:37 2019 +0000
- Revision:
- 1:a2ceed49374e
- Child:
- 3:54c41af9e119
implemented IRsensor class and added all the needed methods except weightPID
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Nicolaemf | 1:a2ceed49374e | 1 | #ifndef IRSensor_H |
Nicolaemf | 1:a2ceed49374e | 2 | #define IRSensor_H |
Nicolaemf | 1:a2ceed49374e | 3 | |
Nicolaemf | 1:a2ceed49374e | 4 | #include <mbed.h> |
Nicolaemf | 1:a2ceed49374e | 5 | #include "RobotControl_H.h" |
Nicolaemf | 1:a2ceed49374e | 6 | |
Nicolaemf | 1:a2ceed49374e | 7 | class IRSensor |
Nicolaemf | 1:a2ceed49374e | 8 | { |
Nicolaemf | 1:a2ceed49374e | 9 | private: |
Nicolaemf | 1:a2ceed49374e | 10 | |
Nicolaemf | 1:a2ceed49374e | 11 | DigitalIn m_leftIR; |
Nicolaemf | 1:a2ceed49374e | 12 | DigitalIn m_midLeftIR; |
Nicolaemf | 1:a2ceed49374e | 13 | DigitalIn m_midIR; |
Nicolaemf | 1:a2ceed49374e | 14 | DigitalIn m_midRightIR; |
Nicolaemf | 1:a2ceed49374e | 15 | DigitalIn m_rightIR; |
Nicolaemf | 1:a2ceed49374e | 16 | |
Nicolaemf | 1:a2ceed49374e | 17 | bool m_prevDirL, m_prevDirR; |
Nicolaemf | 1:a2ceed49374e | 18 | bool m_lineSensor[5]; |
Nicolaemf | 1:a2ceed49374e | 19 | |
Nicolaemf | 1:a2ceed49374e | 20 | short int m_error, m_prevError; |
Nicolaemf | 1:a2ceed49374e | 21 | const float m_Kp, m_Ki, m_Kd; |
Nicolaemf | 1:a2ceed49374e | 22 | float m_P, m_I, m_D; |
Nicolaemf | 1:a2ceed49374e | 23 | |
Nicolaemf | 1:a2ceed49374e | 24 | |
Nicolaemf | 1:a2ceed49374e | 25 | |
Nicolaemf | 1:a2ceed49374e | 26 | public: |
Nicolaemf | 1:a2ceed49374e | 27 | |
Nicolaemf | 1:a2ceed49374e | 28 | bool m_dirL, m_dirR, m_toggle; |
Nicolaemf | 1:a2ceed49374e | 29 | float m_speedL, m_speedR; |
Nicolaemf | 1:a2ceed49374e | 30 | |
Nicolaemf | 1:a2ceed49374e | 31 | IRSensor(PinName pin1, PinName pin2, PinName pin3, PinName pin4, PinName pin5, float Kp, float Ki, float Kd); |
Nicolaemf | 1:a2ceed49374e | 32 | void Sample(); |
Nicolaemf | 1:a2ceed49374e | 33 | void WeightPID(); |
Nicolaemf | 1:a2ceed49374e | 34 | void CalculatePID(); |
Nicolaemf | 1:a2ceed49374e | 35 | void MotorControl(RobotControl controlLeft, RobotControl controlRight); |
Nicolaemf | 1:a2ceed49374e | 36 | |
Nicolaemf | 1:a2ceed49374e | 37 | |
Nicolaemf | 1:a2ceed49374e | 38 | }; |
Nicolaemf | 1:a2ceed49374e | 39 | |
Nicolaemf | 1:a2ceed49374e | 40 | |
Nicolaemf | 1:a2ceed49374e | 41 | |
Nicolaemf | 1:a2ceed49374e | 42 | #endif |