PDA

View Full Version : How i can use the tcs230 with pic



Omidkk
- 26th February 2009, 11:16
Hi
I have problem with Tcs230 color sensor this sensor have frequency output how i can measure that?
I'm use Pic16f877a & Pic Basic pro
Thanks

aratti
- 26th February 2009, 12:18
This snipet has been copied from parallax and should work with pic. Use 4MHz resonator or change Define setting if different clock will be used.


Define OSC = 4

DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 25 ' 9600 Baud @ 4MHz, 0,16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically


EN con 1
A0 con 2
S0 con 3
S1 con 4
S2 con 5
S3 con 6
nLED con 7

pRED con 12
pGREEN con 6
pBLUE con 5

Pinx var (pic pin connected to the output)
RED var word
GREEN var word
BLUE var word

Start: low A0
high S0
high S1
low nLED
high EN

MainLp: gosub Color
debug "R", dec3 RED
debug " G", dec3 GREEN
debug " B", dec3 BLUE
debug cr
goto MainLp

Color: low S2
low S3
count pinx, pRED, RED
high S3
count pinx, pBLUE, BLUE
high S2
count pinx, pGREEN, GREEN
return
end

Al.

buketselen
- 27th December 2011, 16:59
:
ı wonder the same question with you.ıf you succed your project could you send me it too.