ข้อมูล
น้ำหนัก
บาร์โค้ด
ลงสินค้า
อัพเดทล่าสุด
รายละเอียดสินค้า

เซนเซอร์อ่านค่าสี GY-31 TCS230 TCS3200 color sensor color recognition module color sensing module

Specification
Chip: TCS230
Input Voltage: 3V ~ 5V
Best Detection Range: 10mm
High-resolution conversion of light intensity to frequency
Programmable colour and full-scale output frequency
Communicate directly with a microcontroller
Low-profile surface mount package
PCB Size (L x W): Approx. 1.2 x 0.95 inch

Power supply pins:

  • 2x GND
  • 2x VCC
  • 5V

The pins in the control unit:

  • S0
  • S1
  • S2
  • S3
  • OUT
  • LED

 

 



Code:

 

// TCS230 pins connected to Arduino

//int s0 = D3; esp8266

//int s1 = D4;

//int s2 = D5;

//int s3 = D6;

//int out = D7;

 

int s0 = 2; //nano

int s1 = 3;

int s2 = 4;

int s3 = 5;

int out = 6;

 

// Variables

int red = 0;

int green = 0;

int blue = 0;

 

void setup()

{

  Serial.begin(115200);

  pinMode(s0, OUTPUT);

  pinMode(s1, OUTPUT);

  pinMode(s2, OUTPUT);

  pinMode(s3, OUTPUT);

  pinMode(out, INPUT);

 

  digitalWrite(s0, HIGH);

  digitalWrite(s1, HIGH);

 

 

}

 

void loop()

{

  color();

  Serial.print(" R");

  Serial.print(red, DEC);

  Serial.print(" G");

  Serial.print(green, DEC);

  Serial.print(" B");

  Serial.print(blue, DEC);

 

delay(600);

  

  if (red < blue && red < green && red <= 13)

  {  

      if (red <=10 && green <=10 && blue <=10){ 

     Serial.println("WHILE");   

  } else{

   Serial.println(" -> (Red Color)"); 

  }

}  

else if (blue < red && blue <=10 )   

  {  

      if (red <=10 && green <=10 && blue <= 10){

     Serial.println("WHILE");  

  }else {

   Serial.println(" -> (Blue Color)");   }

  }  

  else if (red > green && green > blue && green > 11 )  

  {  

    if (red <= 10 && green <=10 && blue <= 10){

     Serial.println("WHILE");   

  } else{

   Serial.println(" -> (Green Color)");  } 

  }  

  else{

  Serial.println();  

  }

}

 

void color()

{

  digitalWrite(s2, LOW);

  digitalWrite(s3, LOW);

  //count OUT, pRed, RED

  red = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);

  digitalWrite(s3, HIGH);

  //count OUT, pBLUE, BLUE

  blue = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);

  digitalWrite(s2, HIGH);

  //count OUT, pGreen, GREEN

  green = pulseIn(out, digitalRead(out) == HIGH ? LOW : HIGH);

}

:ค่าสีที่อ่านได้ แต่ละตัวอย่างแต่ละที่ จะต่างกันไปเล็กน้อย ตามสีที่อ่าน



เงื่อนไขอื่นๆ
Tags

วิธีการชำระเงิน

บมจ. ธนาคารกรุงไทย สาขาโรงไฟฟ้าบางปะกง ออมทรัพย์
ธนาคารกรุงเทพ จำกัด (มหาชน) สาขาบิ๊กซี ฉะเชิงเทรา 2 ออมทรัพย์
บมจ. ธนาคารกรุงไทย สาขาบิ๊กซี ฉะเชิงเทรา 2 ออมทรัพย์
พร้อมเพย์ สาขา- -
Scan this!
สนธยา ใจผ่อง
063-xxxxxx-8
Accept All Banks | รับเงินได้จากทุกธนาคาร
พูดคุย-สอบถาม