Professional Documents
Culture Documents
Sử Dụng Cảm Biến Màu Tcs3200 Để Phân Biệt Màu Sắc
Sử Dụng Cảm Biến Màu Tcs3200 Để Phân Biệt Màu Sắc
BO CO
O LNG CM BIN
Nhm 12
TI: S DNG CM BIN MU TCS3200 PHN
BIT MU SC
GV: NGUYN KIM SUYN
SVTH: NGUYN VN BO
L QUC LU
V TH THU HNG
TRN MINH NHT
BI BO CO:
S DNG CM BIN MU TCS3200
PHN BIT MU SC
3.Tnh nng :
+Chuyn i cng nh sng thnh tn s c phn gii cao.
+Lp trnh la chn b lc mu sc khc nhau v dng tn s xut ra.
+D dng giao tip vi vi iu khin.
+in p u vo 2.7-5.5V.
4. Nguyn l hot ng:
-Cu to cm bin TCS3200 gm 2 khi nh hnh v pha di:
Tn s u ra c
rng
xung 50% v t l
RS
RW
E
D0
D1
D2
D3
D4
D5
D6
D7
7
8
9
10
11
12
13
14
1
2
3
vcc +5v
4
5
6
VSS
VDD
VEE
LM016L
SIM?
vcc +5v
AREF
ATMEL
www.arduino.cc
blogembarcado.blogspot.com
DIGITAL (PWM~)
SIMULINO
ANALOG IN
A0
A1
A2
A3
A4
A5
POWER
A0
A1
A2
A3
A4
A5
ATMEGA328P
5V
GND
13
12
~11
~10
~9
8
ARDUINO
RESET
7
~6
~5
4
~3
2
TX > 1
RX < 0
13
12
11
10
9
8
7
6
5
4
3
2
1
0
VCC
S0
VCC
S2
S1
S3
LED
OUT
GND
GND
SIMULINO UNO
int red;
int green;
int blue ;
/*
// TCS230 color recognition sensor
Color Sensor
-----------
Arduino
--------
VCC
5V
GND
GND
s0
s1
s2
12
s3
11
OUT
OE
10
GND
*/
const int s0 = 8;
const int s1 = 9;
const int s2 = 12;
const int s3 = 11;
const int out = 10;
void setup()
{
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print(" COLOR SENSOR ");
lcd.setCursor(1,1);
lcd.print(" TCS3200 ");
delay(3000);
lcd.setCursor(0,0);
lcd.print("
NHOM 12 ");
lcd.setCursor(1,1);
lcd.print("BAO LUU HUONG NHAT");
for(int x=0; x < 3; x++)
{
lcd.noDisplay();
delay(500);
lcd.display();
delay(300);
}
for(int x=0; x<14; x++) {
lcd.scrollDisplayLeft(); // cuon man hinh sang trai
delay(500);
}
Serial.begin(9600);
pinMode(s0, OUTPUT);
pinMode(s1, OUTPUT);
pinMode(s2, OUTPUT);
pinMode(s3, OUTPUT);
pinMode(out, INPUT);
digitalWrite(s0, HIGH);
digitalWrite(s1, HIGH);
lcd.clear();
}
void loop()
{
color();
Serial.print("R Intensity:");
Serial.print(red, DEC);
Serial.print(" G Intensity: ");
Serial.print(green, DEC);
Serial.print(" B Intensity : ");
Serial.print(blue, DEC);
if (red < blue && red < green && red < 20 && red >8)
{ Serial.println(" - (Red Color)");
lcd.setCursor(0,0);
lcd.print(" SENSOR-TCS3200 ");
lcd.setCursor(0,0);
lcd.print(" SENSOR-TCS3200 ");
lcd.setCursor(1,1);
lcd.print(" NO Color ");
delay (1000);
}
}
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);
}
Ht./.