An example PID line following program
Fork of m3pi_LineFollower_PID by
Diff: main.cpp
- Revision:
- 1:c0b4f4f6952e
- Parent:
- 0:78f9794620a3
--- a/main.cpp Thu May 12 11:48:56 2011 +0000 +++ b/main.cpp Wed Jun 15 15:18:23 2016 +0000 @@ -3,8 +3,10 @@ m3pi m3pi; +DigitalIn m3pi_IN[] = {(p12)}; + // Minimum and maximum motor speeds -#define MAX 1.0 +#define MAX 0.8 #define MIN 0 // PID terms @@ -27,9 +29,13 @@ float previous_pos_of_line = 0.0; float derivative,proportional,integral = 0; float power; - float speed = MAX; + float speed = 0.6; + m3pi_IN[0].mode(PullUp); while (1) { + while (m3pi_IN[0]==0){ + m3pi.stop(); + } // Get the position of the line. current_pos_of_line = m3pi.line_position();