


Setting Blue filtered photodiodes to be read digitalWrite(S2, LOW) print(frequency) //printing RED color frequency Serial.

Printing the value on the serial monitor Serial. Setting Green filtered photodiodes to be read digitalWrite(S2, HIGH) Setting red filtered photodiodes to be read digitalWrite(S2, LOW) Setting frequency-scaling to 20% digitalWrite(S0, HIGH) */ # define S0 4 # define S1 5 # define S2 6 # define S3 7 # define sensorOut 8 int frequency = 0 The same procedure goes for the two other colors, we just need to adjust the control pins for the appropriate color. Using the Serial.print() function we will print the result on the serial monitor. Then using the “pulseIn()” function we will read the output frequency and put it into the variable “frequency”. For that purpose we will set the two control pins S2 and S3 to low logic level. In the loop section, we will start with reading the red filtered photodiodes. Here we also need to set the frequency-scaling, for this example I will set it to 20%, and start the serial communication for displaying the results in the Serial Monitor. In the setup section we need to define the four control pins as outputs and the sensor output as an Arduino input. TCS230 Color Sensor Source Codeĭescription: First we need to define the pins to which the sensor is connected and define a variable for reading the frequency. As an Amazon Associate I earn from qualifying purchases. Breadboard and Jump Wires ……… Amazon / Banggood / AliExpressĭisclosure: These are affiliate links.Arduino Board …………………………… Amazon / Banggood / AliExpress.You can get the components needed for this Arduino tutorial from the links below:
