Go Down

Topic: Can't read Atlas Scientific colour detector (Read 4 times) previous topic - next topic

phil88

Thanks

this give me this...

Code: [Select]
#include <SoftwareSerial.h>

SoftwareSerial mySerial(2, 3); 

void setup() 
{
  Serial.begin(38400);
  Serial.println("Start color sensor");

  // set the data rate for the NewSoftSerial port
  mySerial.begin(38400);
  mySerial.print('C');
}

void loop()
{
  if (mySerial.available())
  {
    unsigned char c = mySerial.read(); // <------------ added unsigned char
    Serial.print("<"); 
    Serial.print(c, DEC); 
    Serial.print(">");
    if (c == ',') Serial.println(); // split the R G and B
    if (c == 13) Serial.println(); // extra newline
   

  }
      delay(1000);
}



I also added a delay just to see what I was getting from the sensor in one loop. the resulting data is somelike like:

Code: [Select]
<51>

10 seconds of running the serial monitor, i get something like:

Code: [Select]
b,Start color sensor
<49><56><44>
<177><147><148><152><156><134><49>

robtillaart

<49><56><44> is in ascii 183 which looks like a very valid value

<177><147><148><152><156><134><49> are non sensical ...

I don't understand the output.. think...
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

michinyon

Try changing the color and see what happens.

phil88

hmm,

not getting a difference when putting into a completely black area (0,0,0)

I did notice tho, when I removed the sensor from the arduino I still continue to receive readings... that cant be good right?

phil88

did a quick test with the default code for serial communication and tested against a black surface and got a reading of (0,0,0) so sensor seems to be responding correctly... but then entering the code above I dont receive any 0's 

Go Up