Go Down

Topic: HDJD-S822 Color Sensor Code? (Read 5072 times) previous topic - next topic

PaulS

Quote
what should i do to make it better?

Now, we know what sensor you are using, but not how you have connected it to the Arduino. Feel free to volunteer any other info we might need, too.

zhirantaha

i just connected by jumber wire and breadboard

PaulS

Quote
i just connected by jumber wire and breadboard

Well, that's certainly enough detail to be sure that you wired it correctly. The only other thing I can think of then is that maybe you should have used duct tape.

PeterH

You could just check for the red, green and blue intensities being similar to the figures you get from the paper samples.

For example:
Code: [Select]

if((red < 150) && (green > 100) && (green < 200) && (blue > 200))
{
  Serial.println("Red");
}


The RGB values you describe don't seem to correspond to the colour of the paper that you say produced them so you probably have your sensor wired incorrectly or the channels swapped over, but since you seem to be getting consistent values for a given colour you can use those to tell when that colour is present.
I only provide help via the forum - please do not contact me for private consultancy.

zhirantaha

thanks for all replay but i have a question about the range
does anyone know more about this sensor technically??

zhirantaha

i try again but it still give's wrong value while i did the wire connection better?
Please anyone help me!

hey,

i am working on this sensor quite long and i have these observations to make:

1) The smd led must be high for better results.
2) The light room affects too much to the results. So if you do your expirements in your lab, outdoors simple your sensor can't work.(expects of a moody day)
3) Bcoz you use the breakout i suppose you solder header pins before do the programming part. If you just use jumper wires throught the holes every time you break the circuit and rebuild it you will receive different results, so the code(the limits as written before) is useless.

p.s. The soldering way it could have different results to anyone  so noone can give you a ready sketch bcoz it will not work exactly the same to you.
excuz my english...

Xenobius

Hello,

I am at the same exact  situation that you are in however I noticed 2 things.

1. If you disconnect the colour sensor from the arduino, you still get rubbish values. I think the arduino needs pull downs on Analog. Does that make sense?

2. The Analog pins are 10 bit which means you will get from 0 to 1023 however the code multiplies this by different values. I think ultimatelly you need to get them from 0 to 255 in order to have true RGB... does that make sense?

Thanks

Go Up