Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
The following code works with the Parallax color sensor COLORPAL (#28380) I didn't reset the device.
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 colorAs time permits, I will wrap and put in a library