A LineFollower library for ASEE-2014
LineFollower.h@2:7a4179249fa4, 2014-02-21 (annotated)
- Committer:
- blu12758
- Date:
- Fri Feb 21 04:54:56 2014 +0000
- Revision:
- 2:7a4179249fa4
- Parent:
- 1:c319e24af8df
Debugging; ; Corrected motor speed assignments.; Fixed a for loop.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
blu12758 | 0:2623af9e8ef3 | 1 | #include "mbed.h" |
blu12758 | 0:2623af9e8ef3 | 2 | #include <stdint.h> |
blu12758 | 0:2623af9e8ef3 | 3 | |
blu12758 | 0:2623af9e8ef3 | 4 | #ifndef MBED_LINEFOLLOWER_H |
blu12758 | 0:2623af9e8ef3 | 5 | #define MBED_LINEFOLLOWER_H |
blu12758 | 0:2623af9e8ef3 | 6 | |
blu12758 | 0:2623af9e8ef3 | 7 | class LineFollower{ |
blu12758 | 0:2623af9e8ef3 | 8 | |
blu12758 | 0:2623af9e8ef3 | 9 | public: |
blu12758 | 0:2623af9e8ef3 | 10 | /** Create a Line Follower interface for an IR Sensor Array |
blu12758 | 0:2623af9e8ef3 | 11 | * |
blu12758 | 0:2623af9e8ef3 | 12 | * @param ir1 IR Sensor 1 |
blu12758 | 0:2623af9e8ef3 | 13 | * @param ir2 IR Sensor 2 |
blu12758 | 0:2623af9e8ef3 | 14 | * @param ir3 IR Sensor 3 |
blu12758 | 0:2623af9e8ef3 | 15 | * @param ir4 IR Sensor 4 |
blu12758 | 0:2623af9e8ef3 | 16 | * @param ir5 IR Sensor 5 |
blu12758 | 0:2623af9e8ef3 | 17 | * @param ir6 IR Sensor 6 |
blu12758 | 0:2623af9e8ef3 | 18 | * @param ir7 IR Sensor 7 |
blu12758 | 0:2623af9e8ef3 | 19 | * @param ir8 IR Sensor 8 |
blu12758 | 0:2623af9e8ef3 | 20 | */ |
blu12758 | 0:2623af9e8ef3 | 21 | Linefollower(DigitalIn ir1, DigitalIn ir2, DigitalIn ir3, DigitalIn ir4, |
blu12758 | 0:2623af9e8ef3 | 22 | DigitalIn ir5, DigitalIn ir6, DigitalIn ir7, DigitalIn ir8); |
blu12758 | 0:2623af9e8ef3 | 23 | |
blu12758 | 0:2623af9e8ef3 | 24 | |
blu12758 | 0:2623af9e8ef3 | 25 | /** Read the value of a LineFollower object |
blu12758 | 0:2623af9e8ef3 | 26 | * |
blu12758 | 0:2623af9e8ef3 | 27 | * @return The value of the Sensor |
blu12758 | 0:2623af9e8ef3 | 28 | */ |
blu12758 | 0:2623af9e8ef3 | 29 | uint8_t read(); |
blu12758 | 1:c319e24af8df | 30 | |
blu12758 | 1:c319e24af8df | 31 | /** Follow a line |
blu12758 | 1:c319e24af8df | 32 | * |
blu12758 | 1:c319e24af8df | 33 | * @param l left drive motor |
blu12758 | 1:c319e24af8df | 34 | * @param r right drive motor |
blu12758 | 1:c319e24af8df | 35 | */ |
blu12758 | 1:c319e24af8df | 36 | void followLine(Motor l, Motor r); |
blu12758 | 0:2623af9e8ef3 | 37 | |
blu12758 | 0:2623af9e8ef3 | 38 | protected: |
blu12758 | 1:c319e24af8df | 39 | /* Constants */ |
blu12758 | 0:2623af9e8ef3 | 40 | #define ROTATE_SPEED 100 |
blu12758 | 1:c319e24af8df | 41 | #define MAXSPEED 1 |
blu12758 | 1:c319e24af8df | 42 | |
blu12758 | 1:c319e24af8df | 43 | /* Attributes */ |
blu12758 | 1:c319e24af8df | 44 | DigitalIn array[8]; |
blu12758 | 0:2623af9e8ef3 | 45 | DigitalIn _ir1; |
blu12758 | 0:2623af9e8ef3 | 46 | DigitalIn _ir2; |
blu12758 | 0:2623af9e8ef3 | 47 | DigitalIn _ir3; |
blu12758 | 0:2623af9e8ef3 | 48 | DigitalIn _ir4; |
blu12758 | 0:2623af9e8ef3 | 49 | DigitalIn _ir5; |
blu12758 | 0:2623af9e8ef3 | 50 | DigitalIn _ir6; |
blu12758 | 0:2623af9e8ef3 | 51 | DigitalIn _ir7; |
blu12758 | 0:2623af9e8ef3 | 52 | DigitalIn _ir8; |
blu12758 | 0:2623af9e8ef3 | 53 | |
blu12758 | 0:2623af9e8ef3 | 54 | |
blu12758 | 0:2623af9e8ef3 | 55 | }; |
blu12758 | 0:2623af9e8ef3 | 56 | |
blu12758 | 0:2623af9e8ef3 | 57 | #endif |