Jesmi MiniProject

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 31

Embedded System Programming

(4CS016)
Arduino Color Detector

Report on Mini Project

University Id :2331905

Module leader : Dr. Sarah Slater

Lecturer : Uday Kandel

Student Name : Ankit Bogati

Word Count 2500

Group : L4CG2

Submission date :
Abstract:

To detect and identify multiple colors, this color detector sensor project makes use of simple
electronic components. A microprocessor device like Arduino with the help of color sensor that
processes the color data and outputs what comes out on an LCD screen connects to a color
sensor. The report that is included in this project covers schematics, circuit diagrams, and
source code as a supplement to more complete details about this project
Acknowledgment:

My heartful appreciation goes out to Nabin Acharya, my tutor, and the team leading the
embedded systems module for giving us the opportunity to work on some delightful projects. The
assignment not only offered us a great opportunity to learn, but it further educated us on a broad
variety of subjects.
1. Color Detection System:

This mini-project is a cocktail mixer that automatically makes the drink for the user
with a click of a button. I was inspired to make this project after seeing similar
projects on youtube. The drinks are mixed with the help of 12V DC water pumps
which are set high or low by the Arduino which receives signals from the Bluetooth
module. The project is simple and is very beneficial in the modern day as it saves
time and increases efficiency. Sometimes, humans can make mistakes while mixing
drinks but this project doesn’t make any errors as it mixes a specific amount of drink.

1|Page
2. Components Used in the project:

2.1 Arduino UNO: Arduino is an open-source electronics platform based on easy-


to-use hardware and software. Arduino boards are able to read inputs. We can
set instructions to the microcontroller of the board by sending a set of instructions
using the Arduino programming language. Arduino has been the brains of
thousands of projects over the years. Teachers and students use it to build low-
cost scientific instruments which are used to prove chemistry and physics
principles or to get started with programming and robotics. Arduino programming
is similar to C++ language which is a widely used object-oriented programming
language. To date, many variations of Arduino boards have been manufactured
like Arduino Uno(R3), Arduino Nano, Arduino micro, Lilypad Arduino board,
Arduino mega, Arduino zero, etc.

For this project, Arduino Uno(R3) has been used which is the best board to get
started with electronics and coding. Arduino UNO is a microcontroller board
based on the ATmega328P. It has 14 digital input/output pins (of which 6 can be
used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator, 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.
(Arduino, 2022)

2.2 4-channel relay module: The 4-channel relay module is a convenient board
that can be used to control high voltage, a high current load such as motor,
solenoid valves, lamps, and AC load. It is designed to interface with a
microcontroller such as Arduino, PIC and etc. It contains four 5V relays,
associated components, and isolating components which makes interfacing with
a microcontroller easy with minimum components and connections.

2|Page
The module contains the following pins:

Pin Number Pin Name Description

1 GND Ground connection

2 IN1 Input to activate relay 1

3 IN2 Input to activate relay 2

4 IN3 Input to activate relay 3

5 IN4 Input to activate relay 4

6 Vcc Power supply for the relay


module

7 Vcc Power supply for selection


Jumper

8 JD-Vcc Alternate power pin for the


relay module

3|Page
Figure 1: 4-Channel Relay Module

The switching transistors act as a buffer between the relay coils that require high
currents, and the inputs which don’t draw much current. They amplify the input
signal so that they can drive the coils to activate the relays. The freewheeling diodes
prevent voltage spikes across the transistors when the relay is turned off since the
coils are an inductive load. The indicator LEDs glow when the coil of the respective
relay is energized, indicating that the relay is active. The optocouplers form an
additional layer of isolation between the load being switched and the inputs.

2.3 Bluetooth module HC-05: HC-05 is a Bluetooth module that is designed for wireless
communication It is an easy-to-use Bluetooth SPP (Serial Port Protocol) module, designed
for a transparent wireless serial connection setup. Its communication is via serial

4|Page
communication which makes an easy way to interface with the controller or PC. HC-05
Bluetooth module provides a switching mode between master and slave mode which
means it is able to use neither receiving nor transmitting data. (elctronicwings, 2022)

Figure 2: HC-05 module

5|Page
The description and functionality of each pin in the module:

Pin Description Function

VCC +5v Connect to +5V

GND Ground Connect to ground

TXD Serial signal sending pin Connect with the


MCU’s(Microcontroller)
RXD pin

RXD Serial signal receiving pin Connect with the MCU’s


TXD pin

KEY Mode switch input It is used to bring Bluetooth


module into AT commands
mode. If the key pin is set to
high, then this module will
work in command mode.
Otherwise, by default, it is in
data mode.

6|Page
STATE Shows connected or not It tells whether module is
connected or not.

For the project, the module is used to communicate between the application and the
Arduino.

2.4 Water pump 12V DC: 12V DC water pump refers to an electric water pump built
by a 12V dc motor. It uses centrifugal force generated by a high-speed rotating impeller
to lift, transfer or boost water, coolant, fuel, food-grade liquid, etc.

A DC pump is a brushless pump motor or brushed pump motor powered by a dc power


supply, or battery. It is used to pressurize, transport or circulate fluids like water, oil, or
acid and alkali liquids in various application systems or machines.

Compared with AC water pumps, DC water pump has advantages of low price, safety,
high efficiency, low noise, portable, etc. As a low voltage electric water pump, DC water
pumps are widely used as a dc booster pump, dc submersible pump, dc solar pump, or
dc circulation pump for applications that require safety, quiet, and low power
consumption. (voyopumps, 2022)

2.5 Resistors: Resistors are one of the most widely used components in electronic
circuits. As their name indicates they resist the flow of electricity, and this function is key
to the operation of most circuits.

Resistance is one of the key factors used in electrical and electronic circuits. Resistance
is the property of materials to resist the flow of electricity, and it is governed by Ohm's

7|Page
Law. The unit or resistance is the Ohm, which is denoted by the Greek letter Omega(Ω)
and resistor values may be seen quoted in terms of Ohms(Ω), thousands of Ohms or
kilohms(kΩ), and millions of Ohms or megohms(MΩ).

2.6 Capacitors: A capacitor is a device for storing electrical energy, consisting of two
conductors in close proximity and insulated from each other. A simple example of such
a storage device is the parallel-plate capacitor. If positive charges with total charge +Q
are deposited on one of the conductors and an equal amount of negative charge −Q is
deposited on the second conductor, the capacitor is said to have a charge Q.

8|Page
3. Working Principle, Circuit Diagram and Schematics:

The project is controlled by an application that has been built into the phone using
MIT app inventor which is a easy to use website that helps make apps. The
application simply has some buttons that when clicked perform specific functions.
The RXD and TXD pins of the HC-05 is connected to the TX and RX pins of the
Arduino to transfer TTL(Transistor-Transistor Logic) serial data.

Arduino:

Min Vin = 3V

Min Vout = 4.1V

HC-05:

Max Vin = 4.2V

Min Vout = 3.1V

The maximum input voltage that the Arduino can supply to the HC-05 is 4.1V.
Comparing that to the maximum voltage input that the HC-05 can take i.e. 4.2V, the
voltage supplied to the HC-05 can be very high which can damage the module. So,
a 1k ohm resistor is used to lower the voltage so that the data can be transferred
safely to the Bluetooth module.

The Arduino is connected with the 4-channel relay module which receives a signal to
either turn on or off the circuit. The IN1, IN2, and IN3 are connected to the Arduino.
Each pin of the relay has a separate circuit that is turned on or off by the signal
received by the Arduino. The following diagram shows the schematic of the relay
module:

9|Page
Figure 3: Schematic of 4 channel Relay Module

There is an electromagnet in each key of the relay module which is turned on when
electricity is passed which completes the circuit and current is passed to the 12V DC
pumps.

10 | P a g e
Figure 4: Circuit Diagram of the project

11 | P a g e
The figure above clearly shows all the connections done in the project. Capacitors of
1 microfarad charge has been used as sometimes due to the radio frequency noise
of the brushes of the DC motor will cause the Bluetooth module to disconnect.

Figure 5: Schematic diagram of the circuit

The above schematic shows the connections of different components used in the
circuit. Some electrical components were not available in the Tinkercad application
so different components having similar connections has been used to draw the

12 | P a g e
schematic diagram. A 741 operational amplifier has been used instead of the HC-
0Bluetoothth module and Relay SPDT has been used instead of the 4-channel relay
module. To make the schematic connections clear, only a single motor representing
a 12V DC motor. There is a capacitor connected between the connections in the
motor. Here, only a single motor is shown but the project uses 3 motors. The
connections Bluetooth module and the 4-channel relay module are different from the
ones shown in the schematic above as those were not available in the application.
Also, the 9V battery is representing an AC to DC adapter used in the project.

First of all, a signal is sent to the Arduino through the RX and TX pins whenever the
user clicks any specific button in the application built into the phone. The Arduino
then communicates with a 4-channel relay module and switches on or off the circuit
according to the instructions sent by the Arduino program. The motor then draws
current whenever the switch is on in the relay. The Arduino code has been written in
a way that the motors operate for specific milliseconds for mixing different drinks.

13 | P a g e
4. Code:

14 | P a g e
15 | P a g e
// Done by Jeron Rajak

//Uni-Id: 2228148

int Vodka = 8; //pin that will control water pump 1

int Sprite = 9; //pin that will control water pump 2

int LemonJuice = 10; //pin that will control water pump 3

int state = 0; // variable declared to later check the serial connection

int TimeBetweenPours = 500; //after a particular drink is selected in the cocktail mixer
app, there is a 0.5 second delay

void setup() {

Serial.begin(9600);

Serial.println("The bluetooth gates are open #Connect to hc-05 from any other
bluetooth with key 1234");

//set pin 8, 9, 10 to output pins to drive the relay module

pinMode(8, OUTPUT);

pinMode(9, OUTPUT);

pinMode(10, OUTPUT);

// The relay module is of a "LOW true" board. Setting the relays to initially low will
turn on all the pumps. So, it is set high

digitalWrite(8, HIGH);

digitalWrite(9, HIGH);

16 | P a g e
digitalWrite(10, HIGH);

void loop() {

if(Serial.available() > 0) { // check if the data is coming from the serial port

state = Serial.read(); // reads the data from the serial port

Serial.println(state);

//cocktails

//vodka sprite

if (state == 'a') {// if vodka sprite button is selected in the cocktail app then this
statement will be executed

Serial.println("Vodka sprite in the making");

Mix(5000, 5000, 0); // vodka and sprite is turned on for 5 seconds

// vodka lemon

if(state == 'b') { //if vodka lemon button is selected in the cocktail app then this
statement will be executed

Serial.println("Vodka lemon in the making");

Mix(5000, 0, 5000); // vodka and lemon is turned on for 5 seconds

17 | P a g e
//lemon

if(state == "d") {//if lemon button is selected in the cocktail app then this statement will
be executed

Serial.println("lemon juice in the making");

Mix(0, 0, 5000);// lemon is turned on for 5 seconds

//testing and maintainence options

//set-up vodka

if(state == 'q') { //if set-up vodka button is selected in the cocktail app then this
statement will be executed

Serial.println("set- up vodka");

Mix(3000, 0, 0);// vodka is turned on for 3 seconds

// set-up sprite

if(state == 'v') {//if set-up sprite button is selected in the cocktail app then this statement
will be executed

Serial.println("set- up sprite");

Mix(0, 3000, 0);// Sprite is turned on for 3 seconds

//set-up lemon

18 | P a g e
if(state == 'r') {//if set-up lemon button is selected in the cocktail app then this
statement will be executed

Serial.println("set- up lemon");

Mix(0, 0, 3000); //Lemon is turned on for 3 seconds

//cleaning

if(state == 't') {//if cleaning button is selected in the cocktail app then this statement
will be executed

Serial.println("Cleaning");

Mix(5000, 5000, 5000); // all three drinks are turned on for 5 seconds

//making a function that will take delaytime of the drinks as parameters

void Mix(int DelayTimeVodka, int DelayTimeSprite, int DelayTimeLemon){

state = 0;

delay(800);//after the drink is selected there is 0.8 second delay

digitalWrite(Vodka, LOW);// setting pin 1 low

delay(DelayTimeVodka);

digitalWrite(Vodka, HIGH);

delay(TimeBetweenPours);// 0.5 second delay

digitalWrite(Sprite, LOW);// setting pin 2 low

delay(DelayTimeSprite);

19 | P a g e
digitalWrite(Sprite, HIGH);

delay(TimeBetweenPours);// 0.5 second delay

digitalWrite(LemonJuice, LOW);// setting pin 3 low

delay(DelayTimeSprite);

digitalWrite(LemonJuice, HIGH);

delay(TimeBetweenPours);// 0.5 second delay

Serial.println("Drink is done");

state = 0;

The Arduino code waits to get a signal from the cocktail app. If the user clicks on the
vodka sprite button then the bluetooth sends the signal ‘97’ i.e. ‘a’ in asci code to the
Arduino which checks the ascii code to be performed.

Figure 6: Cocktail app code block

After the button is clicked the following if statement is executed and water pump 1 and
water pump 2 starts pouring liquid for 5 seconds each at once.

20 | P a g e
Figure 7: Arduino code performed when Vodka Sprite button is clicked

The cocktail application is made using the MIT App Inventor website which is a free and
easy to use service that makes it easy to build any application.

Figure 8: Cocktail App

21 | P a g e
5. Testing:

The project required many electrical components so each component had to tested
before using in the actual project.

Figure 9: Testing of Bluetooth module

At first, the Bluetooth module had to be tested. All the connections were made
according to the schematic as shown in figure 4. The Bluetooth module successfully
connected to my phone.

Then, the 4-Channel relay module had to tested. Initially I only connected IN1 of the
module and supplied the motors with 12V DC. This was done to see if the relay
module
22 | P a g e
is properly functioning. Using a test code later, all four IN pins started to work and i
started working on connecting all the water pump motors.

Figure 9: 4-Channel Relay Module testing

Then, all the components were assembled together and connected as shown in figure
4. After connecting all the jumper wires, and connecting all the motors with relays the
project looked like the figure below before testing with the Arduino code.

23 | P a g e
Figure 10: Project before connecting with the code

24 | P a g e
6. Conclusion:

The project is working properly and is able to mix 3 different types of drinks. The
project can be expanded with the addition of more motors using an 8-channel or a
16-channel relay module. The application was easily built using the MIT Inventor
App and the app communicates with the Arduino properly but the connection takes
time and also the buttons in the app have to be pressed continuously to send serial
data to the Arduino.

I got inspired to make this project from a YouTube video, the creator of the video
was making various different types of drinks using 8 water pumps with an 8-Channel
relay module. The project seemed interesting and challenging at the same time.
There were other various projects based on making cocktails using Arduino. There
were many advanced projects similar to this. Maybe this project could have been
done in that way but that would have required many other components and it would
be quite expensive to do so. The most challenging part of this project was to execute
the working of each component as any mistake while making the project would have
resulted in damage to the components.

25 | P a g e
7. References:

Arduino, 2022. Arduino Uno R3. [Online]


Available at: https://docs.arduino.cc/hardware/uno-rev3
[Accessed 27 Aug 2022].

elctronicwings, 2022. Bluetooth Module HC-05. [Online]


Available at:
https://www.electronicwings.com/sensors-modules/bluetooth- module-hc-
05-
[Accessed 27 Aug 2022].

voyopumps, 2022. DC Water Pump. [Online]


Available at: https://www.vovyopump.com/dc-water-
pump/#:~:text=12V%20DC%20water%20pump%20refers,is%20very%20conveni ent%20to
%20use.
[Accessed 27 Aug 2022].

26 | P a g e

You might also like