example program that makes use of the LineSensors library to read a reflectance sensor array.
Dependencies: LineSensors
Revision 0:20cf5a047c5e, committed 2014-10-15
- Comitter:
- jmar11
- Date:
- Wed Oct 15 20:37:04 2014 +0000
- Commit message:
- First working commit.
Changed in this revision
LineSensors.lib | Show annotated file Show diff for this revision Revisions of this file |
line_sensors_to_serial_24.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 20cf5a047c5e LineSensors.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LineSensors.lib Wed Oct 15 20:37:04 2014 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/Texas-State-IEEE-Robotics/code/LineSensors/#a45634860f11
diff -r 000000000000 -r 20cf5a047c5e line_sensors_to_serial_24.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/line_sensors_to_serial_24.cpp Wed Oct 15 20:37:04 2014 +0000 @@ -0,0 +1,37 @@ +#include "mbed.h" +#include "LineSensors.h" + +Serial pc(USBTX, USBRX); +bool detect[8][3]; +LineSensors sensors(PTB8, PTB9, PTB10, PTB11, PTE2, PTE3, PTE4, PTE5, + PTC11, PTC10, PTC6, PTC5, PTC4, PTC3, PTC0, PTC7, + PTC9, PTC8, PTA5, PTA4, PTA12, PTD4, PTD5, PTA13); + +int main() { + pc.baud(115200); + pc.printf("\fPlease put all the sensors over white and press <enter>\n\r"); + pc.getc(); + + sensors.setThreshold(); + + pc.printf("here1\n\r"); + + pc.printf("The values of the line sensors will be shown shortly\n\r0 == white 1 == black\n\n\r"); + + wait(3); + + while(1){ + sensors.lineDetect(detect); + pc.printf("\f"); + for(int j = 0; j < 3; j++){ + for(int i = 0; i < 8; i++){ + if(detect[i][j]){ + pc.printf("1 "); + } + else{ + pc.printf("0 "); + } + } + } + } +} \ No newline at end of file