Pages: [1]   Go Down
Author Topic: logical error in code - color detection using arduino  (Read 448 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey I have taken this code for the adjd-s311 color detection chip from the sparkfun website (https://www.sparkfun.com/products/10656). I incurred two problems in this code -

1. This code doesn't give stable values of RGB. For example - If I calibrate it using a white environment, it gives one set of values but if i calibrate or detect color again using the same environment (without changing anything and by just pressing the key again after a few seconds), it gives me a different set of values. These two values are not even close to each other.

2. I want to get a hexadecimal value as my output instead of the RGB values. I have tried changing "DEC" to "HEX" in all "Serial.print" commands but that didn't work. I also tried incorporating a separate decimal to hex conversion function but even that didn't work.

Please help me with this code. I am not able to progress further in my project because of this code. Thanks in advance.

Arduino code: https://www.sparkfun.com/datasheets/Sensors/Imaging/adjd_s311_cr99_example.pde
Logged

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

Quote
2. I want to get a hexadecimal value as my output instead of the RGB values. I have tried changing "DEC" to "HEX" in all "Serial.print" commands but that didn't work. I also tried incorporating a separate decimal to hex conversion function but even that didn't work.
"That didn't work" has to be just about the lamest statement anyone could possibly make. The code, wherever YOUR code is, does something. You want it to do something. All we know is that those two somethings are not the same thing. No clue what either something is, though.

I don't suppose that it is important how the device is connected to the Arduino.
Logged

East Anglia (UK)
Offline Offline
Faraday Member
**
Karma: 114
Posts: 4267
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You have 2 different problem caused by 2 (or more) errors somewhere in your code and/or connections to the sensor.

1.  Sounds like a wiring problem.  Please describe or illustrate how you have the sensor connected.
2.  What 'didn't work' ?  No output, wrong output, what ?
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

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

1.  the hookup:
  ADJD-S311 Breakout ------------- Arduino
  ----------------------------------------
      LED ---------------------------D2
      3.3V -------------------------3.3V
      GND -------------------------- GND
      SCL -------------------------- A5
      SDA -------------------------- A4
      GND -------------------------- GND 
      SLP --------------------- Not connected
      CLK --------------------- Not connected

2. it's not showing any hexadecimal value. it gives a 5 digit value which is not a hexadecimal value of the rgb obtained.
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 303
Posts: 26354
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
it gives a 5 digit value which is not a hexadecimal value of the rgb obtained.
Is "it" the code that you haven't posted?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3032
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A suggestion to people posting code,    don't post a .pde file.   
Logged

Offline Offline
Faraday Member
**
Karma: 62
Posts: 3032
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try this experiment.  Get something which is red,  or green.   Try to measure the colour.

It's possible that you are not communicating with the device at all,   and just generating random numbers.

On the other hand, it is possible that it is working properly,   and your expectations of the result of
the colour "white" are unrealistic.   We are used to knowing that a piece of ordinary paper,  for example,
is "white",   although its actual colour that a sensor would read will vary a lot depending on the sort
of lights that you have.
Logged

Pages: [1]   Go Up
Jump to: