example program that makes use of the LineSensors library to read a reflectance sensor array.

Dependencies:   LineSensors

line_sensors_to_serial_24.cpp

Committer:
jmar11
Date:
2014-10-15
Revision:
0:20cf5a047c5e

File content as of revision 0:20cf5a047c5e:

#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 ");
                }
            }
        }
    }
}