
Ausgabe 18.08.2017
Copyright by Joy-IT
7
3
3. Usage & example code
Below you can see a code example for the color sensor. Please copy the complete code to your
Arduino.
TCS3200 Color Sensor
#include <TimerOne.h>
#define S0 6
#define S1 5
#define S2 4
#define S3 3
#define OUT 2
int
g_count
=
0
;
int
g_array[
3
];
int
g_flag
=
0
;
float
g_SF[
3
];
void
TSC_Init
()
{
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(OUT, INPUT);
digitalWrite(S0, LOW);
digitalWrite(S1, HIGH);
}
void
TSC_FilterColor
(
int
Level01,
int
Level02)
{
if
(Level01
!=
0
)
Level01
=
HIGH;
if
(Level02
!=
0
)
Level02
=
HIGH;
digitalWrite(S2, Level01);
digitalWrite(S3, Level02);
}