Pages: 1 [2]   Go Down
Author Topic: HDJD-S822 Color Sensor Code?  (Read 4415 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Sulaymaniyah-Kurdistan-Iraq
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
stay foolish - stay hungry
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i just connected by jumber wire and breadboard
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 617
Posts: 49463
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12630
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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.
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Sulaymaniyah-Kurdistan-Iraq
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
stay foolish - stay hungry
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Sulaymaniyah-Kurdistan-Iraq
Offline Offline
Jr. Member
**
Karma: 0
Posts: 90
stay foolish - stay hungry
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 28
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Pages: 1 [2]   Go Up
Jump to: