
Ausgabe 18.08.2017
Copyright by Joy-IT
9
3
TCS3200 Color Sensor
void
TSC_WB
(
int
Level0,
int
Level1)
//White balance
{
g_count
=
0
;
g_flag
++
;
TSC_FilterColor(Level0, Level1);
Timer1.setPeriod(
1000000
);
}
void
setup
()
{
TSC_Init();
Serial.begin(
9600
);
Timer1.initialize();
Timer1.attachInterrupt(TSC_Callback);
attachInterrupt(
0
, TSC_Count, RISING);
delay(
4000
);
for
(
int
i
=0
; i
<3
; i
++
)
Serial.println(g_array[i]);
g_SF[
0
]
=
255.0/
g_array[
0
];
//R-Value
g_SF[
1
]
=
255.0/
g_array[
1
] ;
//G-Value
g_SF[
2
]
=
255.0/
g_array[
2
] ;
//B-Value
Serial.println(g_SF[
0
]);
Serial.println(g_SF[
1
]);
Serial.println(g_SF[
2
]);
}
void
loop
()
{
g_flag
=
0
;
for
(
int
i
=0
; i
<3
; i
++
)
Serial.println(
int
(g_array[i]
*
g_SF[i]));
delay(
4000
);
}