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.
Revision 11:b550167f5278, committed 2020-02-13
- Comitter:
- jamesheavey
- Date:
- Thu Feb 13 16:08:34 2020 +0000
- Parent:
- 10:0dec82280040
- Commit message:
- Changed the library so that read_line only uses the middle 3 sensors preventing right turn error when straight is available
Changed in this revision
m3pi.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/m3pi.cpp Tue Feb 04 14:55:06 2020 +0000 +++ b/m3pi.cpp Thu Feb 13 16:08:34 2020 +0000 @@ -344,16 +344,16 @@ { // calculate weighted average unsigned int value = - (0*values[0]+1e3*values[1]+2e3*values[2]+3e3*values[3]+4e3*values[4])/ - (values[0]+values[1]+values[2]+values[3]+values[4]); + (0*values[1]+1000*values[2]+2000*values[3])/ + (values[1]+values[2]+values[3]); // scale to between -1.0 and 1.0 - float position = (int(value) - 2000)/2000.0; + float position = (int(value) - 1000)/1000.0; float is_on_line = false; // loop through and check if any sensor reading is above the threshold - for (int i = 0; i<5; i++) { + for (int i = 1; i<4; i++) { if (values[i] > 500) { is_on_line = true; }