Search the Blog

Thursday, August 15, 2019

Arduino code for reading the color of any object.

RGB Colour Intensity Reading of Any Object

Sensor Name:- TCS3200

Tis post have the code for reading the color intensity RGB color of any object.

To demonstarte this i use a color sensor and ardunio uno board

Arduino code for reading the color of any object.

All Project of Arduino UNO Board

Pin Details:-
   Pin 4 Ardunio uno board is connect to RED line of Sensor 
   Pin 5 Ardunio uno board is connect to GREEN line of Sensor
   Pin 6 Ardunio uno board is connect to BLUE line of Sensor

Arduino Uno Board Pin Diagram


#define Red 4
#define Green 5
#define Blue 6
char inputs [20];
char oldInputs [20];

void setup()
{
  Serial.begin(9600);
}
void getInputs()
{
sprintf(inputs,"SS:%03X:%03X:03X",analogRead(Red),analogRead(Green),analogRead(Blue));
}

TCS3200 Sensor


void loop()
{
getInputs();
if(strcmp(inputs,oldInputs)!=0)
      {
      strcpy(oldInputs,inputs);
      Serial.println(inputs);
      }
      if(Serial.available())
      {
      int ind=0;
      char buff[5];
      while(Serial.available())
      {
        unsigned char c=Serial.read();
        buff[ind]=c;
        if(ind++>4)
        break;
        }
      }
}

See Also-

Check Also This post:-SQL BETWEEN OPERATOR Programming Logic and Code with Syntax


No comments:

Post a Comment

Translate