COLOR SENSOR

 COLOR SENSOR

                               The color sensor is used to recognize the color of an object.  It provides red, green, blue and clear (RGBC) light sensing for precise color measurement, determination, and discrimination. The light sensor works by shining a white light at an object and then recording the reflected color. It can also record the intensity of the reflection (brightness). Through red, green and blue color filters the photodiode converts the amount of light to current. We can interface color sensor with Arduino to recognize the color of objects.


Application:

  • To detect color and separate vegetables in market.
  • To separate colored materials in textile.
  • To separate raw materials based on color in manufacturing industries.

Sample Project With Arduino:

                                                   In this we going to detect the different types of color using the color sensor.

Materials required:

  • Color sensor
  • Arduino UNO
  • Jumper wires

Circuit:


Code:

#define S0 4

#define S1 5

#define S2 6

#define S3 7

#define sensorOut 8

int frequency = 0;

void setup() {

  pinMode(S0, OUTPUT);

  pinMode(S1, OUTPUT);

  pinMode(S2, OUTPUT);

  pinMode(S3, OUTPUT);

  pinMode(sensorOut, INPUT);  // Setting frequency-scaling to 20%

  digitalWrite(S0, HIGH);

  digitalWrite(S1, LOW);

  Serial.begin(9600);

}

void loop() {   // Setting red filtered photo diodes to be read

  digitalWrite(S2, LOW);

  digitalWrite(S3, LOW);   // Reading the output frequency

  frequency = pulseIn(sensorOut, LOW);   // Printing the value on the serial monitor

  Serial.print("R= ");  //printing name

  Serial.print(frequency);    //printing RED color frequency

  Serial.print("  ");

  delay(100);   // Setting Green filtered photodiodes to be read

  digitalWrite(S2, HIGH);

  digitalWrite(S3, HIGH);   // Reading the output frequency

  frequency = pulseIn(sensorOut, LOW);  // Printing the value on the serial monitor

  Serial.print("G= ");  //printing name

  Serial.print(frequency);  //printing RED color frequency

  Serial.print("  ");

  delay(100);  // Setting Blue filtered photodiodes to be read

  digitalWrite(S2, LOW);

  digitalWrite(S3, HIGH);  // Reading the output frequency

frequency = pulseIn(sensorOut, LOW);  // Printing the value on the serial monitor

  Serial.print("B= ");  //printing name

  Serial.print(frequency);  //printing RED color frequency

  Serial.println("  ");

  delay(100);

}


Comments

Popular posts from this blog

Voice Record & Playback Module

GSM Sim800L

GPS