Bukit Mertajam, Penang

Getting Started with Colour Sensor Module (SN-COLOUR-MOD)

Last Updated on 21 June 2017

This article is written by internship student Tan Khim Huang


INTRODUCTION

The Colour Sensor Module (SN-COLOUR-MOD) uses a TAOS TCS3200 RGB sensor chip to detect color. This Colour Sensor Module contains four white LEDs that lights up the object in front of it and detects the reflected color via an array of 64 photodiodes, each with either a red, green, or blue filter, or no filter (clear). The sensor outputs its data through an internal oscillator which produces a square-wave output whose frequency is proportional to the intensity of the chosen color.

The Colour Sensor Module can detect and measure a nearly limitless range of visible colors. Applications include test strip reading, sorting by color, ambient light sensing and calibration, and color matching, just to name just a few.

The SN-COLOUR-MOD can be easily interfaced with a wide range of Arduino boards.

 

FEATURES

  • RGB Color detection sensor module
  • Based on TCS3200 sensor
  • Power: (2.7V to 5.5V)
  • Interface: Digital TTL
  • Controllable four super bright white LEDs, via onboard MOSFET.
  • High-Resolution Conversion of Light Intensity to Frequency
  • Programmable Color and Full-Scale Output Frequency
  • Power Down Feature
  • Communicates Directly to Microcontroller

HARDWARE REQUIREMENT

SOFTWARE REQUIREMENT

Arduino IDE

HARDWARE SETUP

Here are the connections between the TCSP3200 and the Arduino:

S0: digital pin 4 (Output frequency scaling selection inputs.)
S1: digital pin 5 (Output frequency scaling selection inputs.)
VCC: 5V
S2: digital pin 7 (Photodiode type selection inputs)
S3: digital pin 6 (Photodiode type selection inputs)
OUT: digital pin 8 (Output frequency)

SAMPLE CODE

int ldrPin = 7;
#define S0 4
#define S1 5
#define S2 6
#define S3 7
#define sensorOut 8

int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;

int redColor = 0;
int greenColor = 0;
int blueColor = 0;

void setup() {
  
  pinMode(S0, OUTPUT);
  pinMode(S1, OUTPUT);
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(sensorOut, INPUT);
  digitalWrite(S0,HIGH);
  digitalWrite(S1,LOW);
  
    Serial.begin(9600);
}

void loop() {
  digitalWrite(S2,LOW);
  digitalWrite(S3,LOW);
  redFrequency = pulseIn(sensorOut, LOW);
  redColor = map(redFrequency, 70,120,255,0);
  Serial.print("R = ");
  Serial.print(redColor);
  delay(100);
  digitalWrite(S2,HIGH);
  digitalWrite(S3,HIGH);
  greenFrequency = pulseIn(sensorOut, LOW);
  greenColor = map(greenFrequency,  100, 199, 255, 0);
  Serial.print(" G = ");
  Serial.print(greenColor);
  delay(100);
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  blueFrequency = pulseIn(sensorOut, LOW);
  blueColor = map(blueFrequency,  38, 84, 255, 0);
  Serial.print(" B = ");
  Serial.print(blueColor);
  delay(100);

  if(redColor > greenColor && redColor > blueColor){
      Serial.println(" - RED detected!");
  }
  if(greenColor > redColor && greenColor > blueColor){
    Serial.println(" - GREEN detected!");
  }
  if(blueColor > redColor && blueColor > greenColor){
    Serial.println(" - BLUE detected!");
  }
}

REFERENCES

 

VIDEO

Note: For further inquiry, please visit our technical forum as we seldom check the comment here. ?

Related Posts

Leave a comment