Parallax COLORPAL

16 Mar 2011

The following code works with the Parallax color sensor COLORPAL (#28380) I didn't reset the device.

SerialHalfDuplex RGB_master(p9, p10); // this is the color sensor

In the code

 // RGB comm rate
     RGB_master.baud(2400);
     RGB_master.format(8,Serial::None,2); 

 // To Read and format as 24 bit RGB in 32 bits
     RGB_master.putc('=');
     RGB_master.putc('m');
     RGB_master.putc('!');
     
     c1=RGB_master.getc(); // R
     if((c1-'A') >= 0) color = c1-'A'; else color = c1-'0';
     color = color << 4;
     c1=RGB_master.getc();
     if((c1-'A') >= 0) color += c1-'A'; else color += c1-'0';
     color = color << 4;
     c1=RGB_master.getc();  // discard since we have 8 bits of color
     
     
     c1=RGB_master.getc(); // G
     if((c1-'A') >= 0) color += c1-'A'; else color += c1-'0';
     color = color << 4;
     c1=RGB_master.getc();
     if((c1-'A') >= 0) color += c1-'A'; else color += c1-'0';
     color = color << 4;
     c1=RGB_master.getc(); // discard since we have 8 bits of color
     
     c1=RGB_master.getc(); // B
     if((c1-'A') >= 0) color += c1-'A'; else color += c1-'0';
     color = color << 4;
     c1=RGB_master.getc();
     if((c1-'A') >= 0) color += c1-'A'; else color += c1-'0';
     color = color << 4;
     c1=RGB_master.getc(); // discard since we have 8 bits of color

As time permits, I will wrap and put in a library

13 Aug 2011

Hello. I was wondering, how did you find the color accuracy of this sensor?