Parallax ColorPal 28380 only green led inside lights up !

SO ive got the code from the colorpal / parallax site and all running fine on arduino uno rev3 board wired at 5v as per instructions and using the default code supplied (bit wierd serial stuffs but hey) and am i right in thinking the internal led is rgb and should strobe through all colours. Mine seems stuck on green and when testing i get no flux in the red value, but some on green and blue - even with a bright red bit of fabric in front.

Does this code work with newer Arduino 1 + serial and if not does anyone know any mods - or is my sensor perhaps a bit duff ?

If anyone knows how i could poll the internal rgb on the sensor i could manually make it blink red, green blue i could test if it worked.

Yeah,colour sensing.. quite tricky

/* ColorPal Sensor Example for Arduino
  Author: Martin Heermance, with some assistance from Gordon McComb
  This program drives the Parallax ColorPAL color sensor and provides
  serial RGB data in a format compatible with the PC-hosted 
  TCS230_ColorPAL_match.exe color matching program.
*/

#include <SoftwareSerial.h>

const int sio = 2;			// ColorPAL connected to pin 2
const int unused = 255; 		// Non-existant pin # for SoftwareSerial
const int sioBaud = 4800;
const int waitDelay = 200;

// Received RGB values from ColorPAL
int red;
int grn;
int blu;

// Set up two software serials on the same pin.
SoftwareSerial serin(sio, unused);
SoftwareSerial serout(unused, sio);

void setup() {
  Serial.begin(9600);
  reset();				  // Send reset to ColorPal
  serout.begin(sioBaud);
  pinMode(sio, OUTPUT);
  serout.print("= (00 $ m) !"); // Loop print values, see ColorPAL documentation
  serout.end();			  // Discontinue serial port for transmitting

  serin.begin(sioBaud);	        // Set up serial port for receiving
  pinMode(sio, INPUT);
}

void loop() {
  readData();
}  

// Reset ColorPAL; see ColorPAL documentation for sequence
void reset() {
  delay(200);
  pinMode(sio, OUTPUT);
  digitalWrite(sio, LOW);
  pinMode(sio, INPUT);
  while (digitalRead(sio) != HIGH);
  pinMode(sio, OUTPUT);
  digitalWrite(sio, LOW);
  delay(80);
  pinMode(sio, INPUT);
  delay(waitDelay);
}

void readData() {
  char buffer[32];
  
  if (serin.available() > 0) {
    // Wait for a $ character, then read three 3 digit hex numbers
    buffer[0] = serin.read();
    if (buffer[0] == '

) {
      for(int i = 0; i < 9; i++) {
        while (serin.available() == 0);    // Wait for next input character
        buffer[i] = serin.read();
        if (buffer[i] == '


![Screen shot 2014-02-25 at 22.23.12.png|1280x800](upload://wrzJ0K3LkK8Wmhcv0RDlvR1BknB.png))               // Return early if $ character encountered
          return;
      }
      parseAndPrint(buffer);
      delay(50);
    }
  }
}

// Parse the hex data into integers
void parseAndPrint(char * data) {
  sscanf (data, "%3x%3x%3x", &red, &grn, &blu);
  char buffer[32];
  sprintf(buffer, "R%4.4d G%4.4d B%4.4d", red, grn, blu);
  Serial.println(buffer);
}

If the LEDs weren't changing you would get the same reading for all three. Perhaps the LEDs are changing faster than you can see. I know that doesn't explain why the RED reading doesn't seem responsive. You could try doing the sensing manually to slow things down to see if the R, G and B LEDs all work:

  serout.print("= (00 $ R p14 s G p14 s B p14 s) !"); // Loop print values, see ColorPAL documentation

The "p14" means pause for about 100 mS (0x14 = 20 * 5 = 100). This should give you time to see the LEDs blinking.

Each 's' prints out the 3-hex-digit value. To get the same values as 'm' you should print out the ambient intensity (color X) and subtract that from the other three readings:

  serout.print("= (00 $ X p14 s R p14 s G p14 s B p14 s) !"); // Loop print values, see ColorPAL documentation

Thanks ill give this a try just to see if they are actually working.

:slight_smile:

Ill report back