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.
Diff: LineFollowingRobot/IRSensor_H.h
- Revision:
- 1:a2ceed49374e
- Child:
- 3:54c41af9e119
diff -r a02a278513d9 -r a2ceed49374e LineFollowingRobot/IRSensor_H.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LineFollowingRobot/IRSensor_H.h Sat Feb 02 16:11:37 2019 +0000 @@ -0,0 +1,42 @@ +#ifndef IRSensor_H +#define IRSensor_H + +#include <mbed.h> +#include "RobotControl_H.h" + +class IRSensor +{ +private: + + DigitalIn m_leftIR; + DigitalIn m_midLeftIR; + DigitalIn m_midIR; + DigitalIn m_midRightIR; + DigitalIn m_rightIR; + + bool m_prevDirL, m_prevDirR; + bool m_lineSensor[5]; + + short int m_error, m_prevError; + const float m_Kp, m_Ki, m_Kd; + float m_P, m_I, m_D; + + + +public: + + bool m_dirL, m_dirR, m_toggle; + float m_speedL, m_speedR; + + IRSensor(PinName pin1, PinName pin2, PinName pin3, PinName pin4, PinName pin5, float Kp, float Ki, float Kd); + void Sample(); + void WeightPID(); + void CalculatePID(); + void MotorControl(RobotControl controlLeft, RobotControl controlRight); + + +}; + + + +#endif \ No newline at end of file