HELP: m3pi and reflection sensors

20 Feb 2012

Good day all, First, I posted this to the mbed forum but I guess it fits better here.

I am trying to write a simple code that will return and store, in a txt file, the values of the five reflection sensors. I included m3pimaze.h library (http://mbed.org/users/jonmarsh/libraries/m3pimaze/lngdpc) which should allow me to do exactly that using readsensor(int *sensor). The problem is that, when I open the txt file, the returned values are 0, all the time, even if I change the surface (black/white) beneath the sensors. This is the code I am currently using:

#include "mbed.h"
#include "m3pimaze.h"

m3pi m3pi(p23,p9,p10);
LocalFileSystem local("local");

int main() {
    FILE *fp = fopen("/local/out.txt", "w");
    int n;
   
    for(n=0; n<10; n++){
        int  sensor[5];
        m3pi.readsensor(sensor);
        fprintf(fp, "S1: %i S2: %i S3: %i S4: %i S5: %i\n", sensor[0],sensor[1],sensor[2],sensor[3],sensor[4]);
        wait(1);
    }
    fclose(fp);
    
}

Do you guys know what am I doning wrong?

Thank you in advance.

All the best, Igor