The Dream Team
/
first_test
Pop lock n drop it
linepos.cpp@7:d0c19729e7fd, 2014-05-22 (annotated)
- Committer:
- vsal
- Date:
- Thu May 22 12:51:22 2014 +0000
- Revision:
- 7:d0c19729e7fd
Vinces code
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
vsal | 7:d0c19729e7fd | 1 | #include "mbed.h" |
vsal | 7:d0c19729e7fd | 2 | #include "m3pi_ng.h" |
vsal | 7:d0c19729e7fd | 3 | #include "DigitalIn.h" |
vsal | 7:d0c19729e7fd | 4 | |
vsal | 7:d0c19729e7fd | 5 | |
vsal | 7:d0c19729e7fd | 6 | m3pi hue; |
vsal | 7:d0c19729e7fd | 7 | |
vsal | 7:d0c19729e7fd | 8 | |
vsal | 7:d0c19729e7fd | 9 | |
vsal | 7:d0c19729e7fd | 10 | float myLine(void) |
vsal | 7:d0c19729e7fd | 11 | { |
vsal | 7:d0c19729e7fd | 12 | int sensors[5]; |
vsal | 7:d0c19729e7fd | 13 | hue.calibrated_sensor(sensors); |
vsal | 7:d0c19729e7fd | 14 | float leftSen, rightSen, midSen; |
vsal | 7:d0c19729e7fd | 15 | leftSen = sensors[1] / 1000; |
vsal | 7:d0c19729e7fd | 16 | rightSen = sensors[3] / 1000; |
vsal | 7:d0c19729e7fd | 17 | midSen = sensors[2] / 1000; |
vsal | 7:d0c19729e7fd | 18 | return rightSen - leftSen; |
vsal | 7:d0c19729e7fd | 19 | } |
vsal | 7:d0c19729e7fd | 20 | |
vsal | 7:d0c19729e7fd | 21 | int linepos() |
vsal | 7:d0c19729e7fd | 22 | { |
vsal | 7:d0c19729e7fd | 23 | while(1) |
vsal | 7:d0c19729e7fd | 24 | { |
vsal | 7:d0c19729e7fd | 25 | hue.printf("%f", myLine()); |
vsal | 7:d0c19729e7fd | 26 | } |
vsal | 7:d0c19729e7fd | 27 | |
vsal | 7:d0c19729e7fd | 28 | } |