How do I use the IR sensors to detect specific colors?
Khiem Nguyen
Posts: 4
I need help and fast, since I have a competition in 3 weeks at John Hopkins University, I'm suppose to build a boebot that can detect dark spots on a 3x3 (feet) cardboard box. Dark spots has a radius of two inches. Only problem is thus far I've been using the wrong sensor trying to detect it. I basically used photo resistors trying to detect these dark spots, since my friend suggested me to use them, but after I read about the photo resistors I found out it can only detect various intensity of shadows, so I'm back to square two (I already figured out movements!). My teacher bought my group this package.
http://www.parallax.com/detail.asp?product_id=28132
http://www.parallax.com/images/prod_jpg/28132.jpg
My last option is to use the infrared sensor to detect a specific color on the ground, if it detects that specific color, the Boebot would light up an LED but I'm not quite sure how get the infrared to search for a specify color. I know infrared sensor detect certain wavelengths to detect colors, 400nm is purple, so I guess I need a lower wavelength to detect darkspots on the ground, but how am I suppose to do that?
If you guys know an easier method please tell me? I want to at least build a robot that can detect darkspots and lose, then detect nothing at all.
http://www.parallax.com/detail.asp?product_id=28132
http://www.parallax.com/images/prod_jpg/28132.jpg
My last option is to use the infrared sensor to detect a specific color on the ground, if it detects that specific color, the Boebot would light up an LED but I'm not quite sure how get the infrared to search for a specify color. I know infrared sensor detect certain wavelengths to detect colors, 400nm is purple, so I guess I need a lower wavelength to detect darkspots on the ground, but how am I suppose to do that?
If you guys know an easier method please tell me? I want to at least build a robot that can detect darkspots and lose, then detect nothing at all.
Comments
I don't see how IR LEDs will help, since they are typically used with sensing high contrast - such as black on white. no reflection or reflection. If it's dark spots on white background (or reflective at least) IR's are the best choice.
Anyone have other thoughts?
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Perform an Employer's Survey of Electronic Technologies Graduates· - Click here!
Personal Links with plenty of BASIC Stamp info
and SelmaWare Solutions - StampPlot - Graphical Data Acquisition and Control
What you want to do is FREQOUT to the IR emitter at 38KHz, and immediately read the IR receiver pin to see if it's low (saw signal) or high (no signal).
The back dots should absord the IR, so no reflection, input = 1
The cardboard (white I hope?) will reflect the IR, input = 0.
Read through the Boe-Bot texts, there's many good examples and explainations in there on using IR eyes.
PS: You can generally run down Radio shack and buy IR LEDs and the IR Tv Receiver modules.
Good luck!
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Perform an Employer's Survey of Electronic Technologies Graduates· - Click here!
Personal Links with plenty of BASIC Stamp info
and SelmaWare Solutions - StampPlot - Graphical Data Acquisition and Control
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Perform an Employer's Survey of Electronic Technologies Graduates· - Click here!
Personal Links with plenty of BASIC Stamp info
and SelmaWare Solutions - StampPlot - Graphical Data Acquisition and Control
I took your advice using the IR sensor to distinguish between black and white colors, though I'm not sure if I coded what you told me to right. The IR kept detecting objects instead of colors..... well here's my code:
' {$STAMP BS2}
' {$PBASIC 2.5}
irDetectLeft VAR Bit
irDetectRight VAR Bit
counter VAR Word
DEBUG "Testing piezospeaker.."
FREQOUT 4, 2000, 3000
DEBUG CLS,
"IR DETECTORS", CR,
"Left Right", CR,
"
"
DO
FREQOUT 8, 1, 30000
irDetectLeft = IN9
FREQOUT 2, 1, 30000
irDetectRight = IN0
'If irDetect = 1, IR detect Black
'If irDetect = 0, IR detect White
IF (irDetectLeft = 1) THEN
HIGH 10
ELSE
LOW 10
ENDIF
IF (irDetectRight = 1) THEN
HIGH 1
ELSE
LOW 1
ENDIF
DEBUG CRSRXY, 2, 3, BIN1 irDetectLeft,
CRSRXY, 9, 3, BIN1 irDetectRight
PAUSE 100
LOOP
The IR's are made for object detection, but they can also be used for line following and such.· Make sure the dark spots you use are not reflective - like a flat (not glossy) black ink or paper.
Also, you can increase the size of the resistor to the irLED to reduce its output to cut down on the reflection.· It takes a little playing around to find a combination that of resistors and distance from the floor that works well.
-Martin
·