0% found this document useful (0 votes)
69 views15 pages

Ce Lab Project

The document describes a project to control the movement of an autonomous vehicle using color sensors. The vehicle will stop when it detects the color red and move when it detects green. It will continue its previous state if no color is detected. An Arduino mega will process input from TCS3200 color sensors and control DC motors via an L298N motor driver. Required components include the Arduino, motors, motor driver, color sensors, breadboard, power supply and wires. The document provides schematics, calculations, descriptions of the components and how they will work together.

Uploaded by

Fahad Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views15 pages

Ce Lab Project

The document describes a project to control the movement of an autonomous vehicle using color sensors. The vehicle will stop when it detects the color red and move when it detects green. It will continue its previous state if no color is detected. An Arduino mega will process input from TCS3200 color sensors and control DC motors via an L298N motor driver. Required components include the Arduino, motors, motor driver, color sensors, breadboard, power supply and wires. The document provides schematics, calculations, descriptions of the components and how they will work together.

Uploaded by

Fahad Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

CONTROL ENGINEERING

ME – 339
DE 40 – ME-A
PROJECT REPORT
TITLE: MOVEMENT CONTROL OF AUTONOMOUS VEHICLE USING
COLOUR SENSORS

GROUP MEMBERS:
M ALI FAHAD REG # 280803
UMAR SHERAZ REG # 280807

SUBMITTED TO:
LE HASSAN MEHMOOD
INTRODUCTION
In this project we will control the movement of autonomous vehicle using colour sensors. Motion of car will be
controlled by use of colour sensors to decide whether it has to stop or move. Here, we will use 2 colours RED
and GREEN. If sensor detects red colour then car will stop automatically and if it detects green colour then it
will start moving and third case if there is no colour detection it will continue its previous state either moving
or stop. We will be using arduino for the processing purpose that will take input from the sensors and then
according to the installed program it will take decisions as above mentioned.

COMPONENTS REQUIRED
 Arduino Mega
 DC Motors
 L298N Motor Driver Module
 TCS3200 (RGB + Clear) Color Sensor Module 
 Breadboard
 Power supply 
 Connecting wires 

SCHEMATIC DIAGRAM
CALCULATIONS
In schematic diagram we have used signal generator instead of tcs3200 colour sensor due to unavailability of
libraries of sensor. This signal generator will produce the corresponding frequencies of the lights which will be
acting as an input for microcontroller and processed further for motor controls.

The below frequencies are the actual frequencies ranges of the light colours but our controller is 8-bit so it will
be converted into 0 – 255 during data logging.

RED LIGHT

 Wavelength: 564–580 nm 

Frequency: 531546911.347518 - 516883548.275862 MHz

GREEN LIGHT

Wavelength: 534–545 nm

Frequency: 561409097.37827 - 550077904.587156 MHz


ARDUINO MEGA 2560
The Arduino Mega 2560 is a microcontroller board based on the ATmega2560 . It has 54 digital
input/output pins (of which 15 can be used as PWM outputs), 16 analog inputs, 4 UARTs (hardware
serial ports), a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a
reset button. It contains everything needed to support the microcontroller; simply connect it to a
computer with a USB cable or power it with an AC-to-DC adapter or battery to get started. The
Mega 2560 board is compatible with most shields designed for the Uno and the former boards
Duemilanove or Diecimila.

PINOUT DIAGRAM
 
FEATURES & SPECIFICATIONS

Microcontroller ATmega2560

Operating Voltage 5V

Input Voltage (recommended) 7-12V

Input Voltage (limit) 6-20V

Digital I/O Pins 54 (of which 15 provide PWM output)

Analog Input Pins 16

DC Current per I/O Pin 20 mA

DC Current for 3.3V Pin 50 mA

Flash Memory 256 KB of which 8 KB used by boot loader

SRAM 8 KB

EEPROM 4 KB

Clock Speed 16 MHz

LED_BUILTIN 13

Length 101.52 mm

Width 53.3 mm

Weight 37 g

L298N MOTOR DRIVER MODULE

This L298N Motor Driver Module is a high power motor driver module for driving DC and Stepper Motors. This

module consists of an L298 motor driver IC and a 78M05 5V regulator. L298N Module can control up to 4 DC

motors, or 2 DC motors with directional and speed control.


L298N Motor Driver Module

L298N MODULE PIN CONFIGURATION

Pin Name Description

IN1 & IN2 Motor A input pins. Used to control the spinning direction of Motor A

IN3 & IN4 Motor B input pins. Used to control the spinning direction of Motor B

ENA Enables PWM signal for Motor A

ENB Enables PWM signal for Motor B

OUT1 & OUT2 Output pins of Motor A

OUT3 & OUT4 Output pins of Motor B

12V 12V input from DC power Source

5V Supplies power for the switching logic circuitry inside L298N IC

GND Ground pin


L298N Motor Driver Module Pinout

L298 MODULE FEATURES & SPECIFICATIONS

 Driver Model: L298N 2A


 Driver Chip: Double H Bridge L298N
 Motor Supply Voltage (Maximum): 46V
 Motor Supply Current (Maximum): 2A
 Logic Voltage: 5V
 Driver Voltage: 5-35V
 Driver Current:2A
 Logical Current:0-36mA
 Maximum Power (W): 25W
 Current Sense for each motor
 Heat sink for better performance
 Power-On LED indicator

Brief about L298N Module:

The L298N Motor Driver module consists of an L298 Motor Driver IC, 78M05 Voltage Regulator, resistors,

capacitor, Power LED, 5V jumper in an integrated circuit.


78M05 Voltage regulator will be enabled only when the jumper is placed. When the power supply is less than

or equal to 12V, then the internal circuitry will be powered by the voltage regulator and the 5V pin can be

used as an output pin to power the microcontroller. The jumper should not be placed when the power supply

is greater than 12V and separate 5V should be given through 5V terminal to power the internal circuitry.
ENA & ENB pins are speed control pins for Motor A and Motor B while IN1& IN2 and IN3 & IN4 are direction
control pins for Motor A and Motor B.
Internal circuit diagram of L298N Motor Driver module is given below:

Applications of L298N Module

 Drive DC motors.
 Drive stepping motors
 In Robotics
TCS3200 COLOR SENSOR MODULE

This Arduino compatible TCS3200 color sensor module consist of a TAOS TCS3200 RGB sensor chip and 4 white
LEDs. The main part of the module is the TCS3200 chip which is a Color Light-to-Frequency Converter. The
white LEDs are used for providing proper lighting for the sensor to detect the object colour correctly. This chip
can sense a wide variety of colours and it gives the output in the form of corresponding frequency. This
module can be used for making colour sorting robots, test strip reading, colour matching tests etc.

The TCS3200 chip consists of an 8 x 8 array of photodiodes. Each photodiode have either a red, green, or blue
filter, or no filter. The filters of each color are distributed evenly throughout the array to eliminate location
bias among the colors. An internal circuit includes an oscillator which produces a square-wave output whose
frequency is proportional to the intensity of the chosen color.

PIN CONFIGURATION
PIN PIN  
NAME NUMBER DESCRIPTION

GND 4 Power supply ground. All voltages are reference to the ground.

VCC 5 Supply voltage

OE 3 Enable for FO  (Active low)

OUT 6 Output frequency

S0, S1 1, 2 Select lines for output frequency scaling

S2, S3 7,8 Select lines for photodiode type.

 
WORKING (We will be using only red and green colour lights)
The sensor has four different types of filter covered diodes. In the 8 x 8 array of photodiodes, 16 photodiodes
have Red filters, 16 have Blue filters, 16 have Green filters and the rest 16 photodiodes are clear with no
filters. Each type can be activated using the S2, S3 selection inputs. Since each photodiodes are coated with
different filters each of them can detect the corresponding colours. For example, when choosing the red filter,
only red incident light can get through, blue and green will be prevented. By measuring the frequency, we get
the red light intensity.  Similarly, when choose other filters we can get blue or green light.
We can also set the frequency scaling option by using the S0, S1 select lines. Normally, in Arduino 20%
frequency scaling is used.

S0 S1 OUTPUT FREQUENCY SCALING(f0)

L L Power down

L H 2%

H L 20%

H H 100%
S2 S3 PHOTODIODE TYPE

 L L RED

L H BLUE

H L CLEAR (NO FILTER)

H H GREEN

 
FEATURES AND SPECIFICATIONS

 Input voltage: (2.7V to 5.5V)


 Interface: Digital TTL
 High-resolution conversion of light intensity to frequency
 Programmable colour and full-scale output frequency
 No need of ADC(Can be directly connected to the digital pins of the microcontroller)
 Power down feature
 Working temperature: -40oC to 85oC
 Size: 28.4x28.4mm(1.12x1.12")

HOW TO USE THE MODULE PIN CONFIGURATION


TCS3200 color sensor module can be used to detect the colous with the help of a microcontroller. Actually,
the microcontroller is measuring the output frequency from the 6th pin.
 
To determine the color of an object, we’ve to measure the frequency from 6th pin when each filter is
activated.
Set both S2 and S3 to LOW, measure the frequency. Now we get the intensity of RED component in the object.
Set S2 to LOW and S3 to HIGH in order to get the intensity of BLUE component in the object.
Set both S2 and S3 to HIGH and get the intensity of GREEN component in the object.
Compare the frequencies of the three components to get the actual colour of the object.
TIP: In Arduino, we can use the ‘pulseIn’ command to get the frequency variations.

e.g.:
digitalWrite(S2, LOW);
digitalWrite(S3, LOW); //Activating photodiode with red filter
red = pulseIn(outpin, LOW);

Here we get the value corresponding to the red color component of the object color.
Similarly, we’ve to activate each photodiodes by changing the S2 and S3 states and read the corresponding
values of green and blue colour components of the object colour.
For a Red object we get an approximate value of red=16, green=53 and blue=45. This may vary from ambient
light and experiment setup. For good results, it’s better to cover the object and sensor from ambient light.
 

Programming Logic

 First set the input pins as input and output pins as output. No need to use analog pins.
 Set S0 and S1 to high or low to set desired frequency scaling.
 In loop, activate each filters by setting S2 and S3 to HIGH or LOW and measure output frequency ‘fo’
from 6th pin to get corresponding colour intensity. Compare frequencies of each colour to determine the
colour of the object.

CODE

//Include the library


#include <tcs3200.h>

/*
Initialize the variables
for colour sensor
*/
int red;
int green;
String sensedColour = "none";
int delayTime = 0;

/*
Initialize the variables
for motor driver
*/
int leftMotorForward = 9;
int leftMotorBackward = 10;
int rightMotorForward = 11;
int rightMotorBackward = 12;

tcs3200 sensor(4, 5, 6, 7, 8); //S0, S1, S2, S3, output pin


void setup() {

/*
Set pin 9, 10, 11
and 12 as output
*/
for (int i = 9; i < 13; i = i + 1) {

pinMode(i, OUTPUT);

red = sensor.colorRead('r', 20); //Scaling the sensor to 20%


green = sensor.colorRead('r',20);
Serial.begin(9600);

void loop() {

readColour();
checkColour();

if (sensedColour == "red") { //If the colour is red…..

delayTime = 2000;
delay(delayTime);
stop(); //A function to stop the car
sensedColour = "none"; //Sets the sensed colour as ‘None’

else if (sensedColour == "green") { //If the colour is green…..

delayTime = 2000;
delay(delayTime);
front(); //Function to move the car
sensedColour = "none"; //Sets the sensed colour as ‘None’

else
sensedColour = "none"; //Sets the sensed colour as ‘None’

}
//function to stop the car
void stop() {
digitalWrite(leftMotorForward, LOW);
digitalWrite(rightMotorForward, LOW);
delay(delayTime);
}

//function to move the car

void front() {
digitalWrite(leftMotorForward, HIGH);
digitalWrite(rightMotorForward, HIGH);
delay(delayTime);
}

//function to read the colour


void readColour() {

red = sensor.colorRead('r'); //reads colour value for red


green = sensor.colorRead('g'); //reads colour value for green

//Prints the values on the serial monitor


Serial.print("R = ");
Serial.println(red);
Serial.print("G = ");
Serial.println(green);
Serial.println(" ");
delay(10);

//sets the colour that is sensed


void checkColour() {

if (red > green and red > 8) { //If the colour is red......

sensedColour = "red"; //Sets the value of this variable to “red”

else if (green > red and green > 8) { //If the colour is green......

sensedColour = "green"; //Sets the value of this variable to “green”


}

else
sensedColour = "none";
}
Videos Links:
https://drive.google.com/file/d/1jQYAjZev3v51XJWsCZtDBYd8_JdW6zSv/view?usp=sharing
https://drive.google.com/file/d/1VZ3YN9MN2b2orc-iajPcIXylmWISNnfo/view?usp=sharing

References

https://components101.com/tcs3200-color-sensor-module

https://www.everythingrf.com/rf-calculators/wavelength-to-frequency

https://www.google.com/search?sxsrf=ALeKk00VeZf9z0EWDbhhhY9sajWfI959ag
%3A1611237509808&ei=hYgJYN7rMOXA8gKYqre4Dw&q=red+and+green+light+frequencies+for+colour+senso
r&oq=red+and+green+light+frequencies+for+colour+sensor&gs_lcp=CgZwc3ktYWIQAzIECAAQRzIECAAQRzIEC
AAQRzIECAAQRzIECAAQRzIECAAQRzIECAAQRzIECAAQR1DZ8wNYw7IEYJm5BGgAcAN4AIABAIgBAJIBAJgBAKAB
AaoBB2d3cy13aXrIAQjAAQE&sclient=psy-ab&ved=0ahUKEwiewq67l63uAhVloFwKHRjVDfcQ4dUDCA0&uact=5

https://www.hackster.io/shreyas_arbatti/color-controlled-car-using-tcs3200-color-sensor-64fd35

You might also like