The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by Ayu Natasha, 2020-11-27 23:28:58

Lab Sheet Task 2 Color Sensor

Lab sheet Task 2

Keywords: Sensor Trainer Kit

POLITEKNIK SULTAN ABDUL HALIM MU’ADZAM SHAH
JABATAN KEJURUTERAAN MEKANIKAL

SENSOR TRAINER KIT LABSHEET

TASK 2 COLOR SENSOR

Objectives

At the end of the lab student should be able to:

1. Students will know the correct way to program Color Sensor (TCS3200).
2. Students will be able to transfer an output to Blynk’s application.
3. Students will be able to learn more about Color Sensor (TCS3200) sensor’s

specification.
4. Students will be able to assemble circuit Color Sensor (TCS3200).

Description and Background

The TCS3200 color sensor can detect a wide variety of colors based on
their wavelength. This sensor is specially useful for color recognition
projects such as color matching, color sorting, test strip reading and much
more. The Color Sensor is a complete color detector. It consists of a
TAOS TCS3200 RGB sensor chip and 4 white LEDs. It can detect and
measure a nearly limitless range of visible colors to a certain degree.

Hardware

1. Color Sensor (TCS3200)

2. NodeMCU ESP266
3. Colour paper (green,blue,red)
4. Jumper Wire
5. Laptop

6. Handphone

7. Breadboard

Software

1. Blynk
2. Arduino IDE

Code

#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#define S0 D6
#define S1 D7
#define S2 D3
#define S3 D4
#define sensorOut D5

int red = 0;
int green = 0;
int blue = 0;

char auth[] = "HiqLFpOlUX2ssNwOFJSbzXLMp_W53o77";
char ssid[] = "KimK";
char pass[] = "123456789";

String colour;

void setup()

{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);

pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);

pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
//Setting frequency-scaling

digitalWrite(S0, HIGH);
digitalWrite(S1, HIGH);

}

void loop()
{
digitalWrite(S2, LOW);
digitalWrite(S3, LOW);
red = pulseIn(sensorOut, digitalRead(sensorOut) == HIGH ? LOW : HIGH);
digitalWrite(S3, HIGH);
blue = pulseIn(sensorOut, digitalRead(sensorOut) == HIGH ? LOW : HIGH);
digitalWrite(S2, HIGH);
green = pulseIn(sensorOut, digitalRead(sensorOut) == HIGH ? LOW : HIGH);

if (red < blue && red < green && red < 20)
{
Serial.println(" Red Color");
colour="RED_COLOUR";
}

else if (blue < red && blue < green)
{
Serial.println(" Blue Color");
colour="BLUE_COLOUR";
}

else if (green < red && green < blue)
{
Serial.println(" Green Color");
colour="GREEN_COLOUR";
}

Blynk.virtualWrite(V6, colour);

delay(500);
}

Circuit Diagram

Procedures:
1. Firstly, take a jumper wire and connect S3 Color Sensor to D4 NodeMCU board.
2. Next, take a new jumper wire and connect S2 Color Sensor to D3 NodeMCU board.

3. Then, take another one jumper wire and connect OUT Color Sensor to D5 NodeMCU
board.

4. Take a new jumper wire and connect VCC Color Sensor to 3V NodeMCU board.

5. Next, take other jumper wire and connect S0 Color Sensor to D6 NodeMCU board.

6. Then, take a jumper wire and connect S1 Color Sensor to D7 NodeMCU board.

7. Lastly, take another jumper wire and connect GND Color Sensor to GND NodeMCU board
to complete the circuit.

8. Open and create the new project at blynk

9. Write name Color Sensor at project name.
10. Swipe to the left and looking for the widget box to find LCD

11. Select LCD and set the LCD to make an output.

12. After finish connecting the circuit, open the Arduino IDE application to program the Color
Sensor.

9. Then, insert the code into the sketch and save as “tcs3200.c” before pressing verify and
upload.

10. After the code successfully verified and uploaded, click the serial monitor to open to see
the result.


Click to View FlipBook Version