Sie sind auf Seite 1von 52

MICROCONTROLLER BASED

DESIGN

PROJECT REPORT
CAR PARKING SYSTEM USING AURDINO

Submitted by: Bassim Faridy150649


Aden Salim 150661
BEMTS 4-B
Submitted to:
ENGR UMER FAROOQ

Dated: 6TH MAY, 2017

pg. 1
DEPARTMENT OF
MECHATRONICS
Abstract

Not finding a parking space for you sometimes is indeed a critical issue. An
important appointment might be missed. Time will be wasted and more money
will be spent. Criticism and inconvenience are more likely to happen. So, parking
monitoring is an important solution. It has many practical advantages. It can
arrange the passage of vehicles inside the parking area in addition to avoiding
contention. It can reduce the suffering of sick and disabled people looking for a
parking space. It is a good denote to such part of the society. It is like providing
them with the smile and hope that helps them to overcome their disability. This
project can provide information about the future need to make more parking
spaces, also has many uses such as security issues and data base. The project
consists of four main stages, the first stage is turning the LEDs ON/OFF when the
cars enters or leaves the parking slot respectively. The second main stage is
showing it on the TFT Screen whether the parking is full or empty. The third is
using Wi-Fi Module ESP 8266 we show it on the webpage the no of parking slots
empty/full. And the Last stage is we do data logging using SD card to get the
history of a specific car.

pg. 2
Acknowledgements
This research for the project was partially supported by Sir Omer Farooq. We
thank our colleagues who provided insight and expertise that greatly assisted the
project research, although they may not agree with all of the conclusions of this
project.
We would also like to show our gratitude to the lab engineers and senior class
mates for sharing their pearls of wisdom with us during the course of this project
research. We are also immensely grateful to our families for their comments and
support, although any errors are our own and should not tarnish the reputations
of these esteemed persons.

pg. 3
TABLE OF CONTENTS:

Abstract
Page 2

Acknowledgements
Page 3

Chapter 1 Description of Project


1.1: Project Definition
Page: 6
1.2: Project Objectives.
Page: 6
1.3: Project Specification
Page: 6
1.4: Background or Problem
Page: 7
Chapter 2 Microcontroller/Materials Used:
2.1: Arduino Microcontroller.
Page: 8

pg. 4
2.2: Introduction about Microcontroller
Page: 9
2.3: Arduino Properties, Schematic Diagram
Page: 11
And Power
2.4: Other Materials
Page: 15

Chapter 3 Implementation

3.1: Block Diagram


Page: 26
32: Flowcharts/ Codes
Page: 27
3.3: Simulation of Project
Page: 44
Chapter 4 Project Budget

4.1: Budget
Page: 45
Chapter 5 Project Schedule
5.1: Schedule
Page: 46

Chapter 6 Conclusion:

6.1: Conclusion.
Page: 46

pg. 5
Reference Page:47

Chapter 1: Description of Project

1.1 Project Definition


Design a project of parking monitoring and control system to count the number of
automobiles entering and leaving a parking, provide information about free
parking spaces, create data base to provide statistics about each car entering and
leaving the parking space. This system uses efficient sensors and display circuits to
withstand the surrounding environment. The system will be powered form power
utility available to supply the system components with required supply for
Ultrasonic sensors, TFT display, Arduino, stepper motor, and data base computer.

pg. 6
1.2 Project Objectives
Design an efficient parking system to provide statistical information.
Saving peoples time in finding parking lots.
Learn about energy impact on environment and our role as engineers to offer
solutions; saving energy of automobiles which in turns reduces CO2 emissions and
other harmful gases; hence better green environment.

1.3 Project Specifications


Main marketing features or specifications are:
Low power consumption.
High quality sensor and long life TFT Screen.
Very clear display and efficient controller.
Easy to install and maintain.
Easily designed system to minimize the cost.

1.4 Background or Problem


Making a parking monitoring system especially in Pakistan will be significantly
useful due to the increasing usage of parking lot as population and buildings
increase more and more which indicates that there is really lack of parking and a
large amount of traffic that look for free parking spaces. However, this would be
time consuming for people to keep searching and also there is an environmental
issue since the automobiles is emitting CO2 which is a major factor in affecting
environment. In order to deal with the problems of the metropolitan areas, there
is a need to develop advanced solutions for efficient parking space management
especially at airports, malls, universities, and any large parking lots that are used
heavily.

pg. 7
Chapter 2 Microcontroller/ Gathering Materials

2.1 Arduino Microcontroller

pg. 8
It's an open-source physical computing platform based on a simple
microcontroller board, and a development environment for writing software for
the board. Arduino can be used to develop interactive objects, taking inputs from
a variety of switches or sensors, and controlling a variety of lights, motors, and
other physical outputs.

2.2 Introduction about Microcontrollers


The controller is the core system of the project or any electrical circuit since it acts
like the brain that takes decisions and receives and sends output accordingly. The
controlling function in this project shall use the microcontroller rather than digital
IC's. In fact, it is really a good chance to learn about microcontroller and how to
program and design microcontroller based circuits since almost all controlling
functions in electronic devices are made using microcontrollers. Also it gives
flexibility in changing programs or modify or enhance the functionality easily since
all it requires changing the program and downloading it to chip whereas in digital
IC's we have to change the physical hardware configuration to meet the required
result which will be time consuming in addition to complexity.

However, there are several types of microcontrollers in the market. The selection
of the microcontroller was based in how common it is in market and availability.
Also, it depended on the size of the program memory, RAM and the clock
frequency (speed), how many I/O it can accommodate as well as interrupts.

pg. 9
Basically, a microcontroller is a device which integrates a number of the
components of a microprocessor system onto a single microchip and optimized to
interact with the outside world through on-board interfaces. So, it is in fact a little
gadget that houses a microprocessor, ROM (Read Only Memory), RAM (Random
Access Memory), I/O (Input Output functions), and various other specialized
circuits all in one package.

On the other hand, a microprocessor is normally optimized to co-ordinate the


flow of information between separate memory and peripheral devices which are
located outside it. Connections to a microprocessor include address, control and
data busses that allow it to select one of its peripherals and send to or retrieve
data from it. Because a microcontrollers processor and peripherals are built on
the same silicon, the devices are self-contained and rarely have any bus structures
extending outside their packages

Arduino Mega:
The Arduino Mega is a microcontroller board based on
the ATmega1280 (datasheet). It has 54 digital input/output pins (of which 14 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 a AC-to-DC adapter or
battery to get started. The Mega is compatible with most shields designed for the
Arduino Duemilanove or Diecimila.

Arduino UNO:
Arduino/Genuino Uno is a microcontroller board based on the ATmega328P
(datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM
outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power
jack, an ICSP header and a reset button. It contains everything needed to support

pg. 10
the microcontroller; simply connect it to a computer with a USB cable or power it
with a AC-to-DC adapter or battery to get started.. You can tinker with your UNO
without worrying too much about doing something wrong, worst case scenario
you can replace the chip for a few dollars and start over again.
"Uno" means one in Italian and was chosen to mark the release of Arduino
Software (IDE) 1.0. The Uno board and version 1.0 of Arduino Software (IDE) were
the reference versions of Arduino, now evolved to newer releases. The Uno board
is the first in a series of USB Arduino boards, and the reference model for the
Arduino platform; for an extensive list of current, past or outdated boards see the
Arduino index of boards.

2.3 Arduino Properties, Schematic Diagram, and Power

Specifications and Features of Arduino Mega 2560


Summary
Microcontroller ATmega1280
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 54 (of which 15 provide PWM output)
Analog Input Pins 16
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 128 KB of which 4 KB used by bootloader
SRAM 8 KB
EEPROM 4 KB

pg. 11
Clock Speed 16 MHz

The power pins are as follows:

VIN. The input voltage to the Arduino board when it's using an external
power source (as opposed to 5 volts from the USB connection or other regulated
power source). You can supply voltage through this pin, or, if supplying voltage via
the power jack, access it through this pin.

5V. The regulated power supply used to power the microcontroller and
other components on the board. This can come either from VIN via an on-board
regulator, or be supplied by USB or another regulated 5V supply.

3V3. A 3.3 volt supply generated by the on-board FTDI chip. Maximum
current draw is 50 mA.

GND. Ground pins.

Input and Output


Each of the 54 digital pins on the Mega can be used as an input or output,
using pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5
volts. Each pin can provide or receive a maximum of 40 mA and has an internal
pull-up resistor (disconnected by default) of 20-50 kOhms. In addition, some pins
have specialized functions:

Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX) and
16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX) TTL
serial data. Pins 0 and 1 are also connected to the corresponding pins of the FTDI
USB-to-TTL Serial chip.

External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19


(interrupt 4), 20 (interrupt 3), and 21 (interrupt 2). These pins can be configured
to trigger an interrupt on a low value, a rising or falling edge, or a change in value.
See the attachInterrupt() function for details.

pg. 12
PWM: 2 to 13 and 44 to 46. Provide 8-bit PWM output with
the analogWrite() function.

SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI


communication, which, although provided by the underlying hardware, is not
currently included in the Arduino language. The SPI pins are also broken out on
the ICSP header, which is physically compatible with the Duemilanove and
Diecimila.

LED: 13. There is a built-in LED connected to digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it's off.

I2C: 20 (SDA) and 21 (SCL). Support I2C (TWI) communication using the Wire
library (documentation on the Wiring website). Note that these pins are not in the
same location as the I2C pins on the Duemilanove or Diecimila.

The Mega has 16 analog inputs, each of which provide 10 bits of resolution (i.e.
1024 different values). By default they measure from ground to 5 volts, though is
it possible to change the upper end of their range using the AREF pin and
analogReference() function.

There are a couple of other pins on the board:

AREF. Reference voltage for the analog inputs. Used with analogReference().

Reset. Bring this line LOW to reset the microcontroller. Typically used to add
a reset button to shields which block the one on the board.

pg. 13
Schematic

Specifications and Features of Arduino UNO


Technical specs
Microcontroller ATmega328P
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limit) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
PWM Digital I/O Pins 6
Analog Input Pins 6
DC Current per I/O Pin 20 mA
DC Current for 3.3V Pin 50 mA
32 KB (ATmega328P)
Flash Memory
of which 0.5 KB used by bootloader
SRAM 2 KB (ATmega328P)
EEPROM 1 KB (ATmega328P)
Clock Speed 16 MHz
LED_BUILTIN 13
Length 68.6 mm
Width 53.4 mm
Weight 25 g
The power pins are as follows:

pg. 14
Vin. The input voltage to the Arduino/Genuino board when it's using an
external power source (as opposed to 5 volts from the USB connection or other
regulated power source). You can supply voltage through this pin, or, if supplying
voltage via the power jack, access it through this pin.

5V.This pin outputs a regulated 5V from the regulator on the board. The
board can be supplied with power either from the DC power jack (7 - 12V), the
USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the
5V or 3.3V pins bypasses the regulator, and can damage your board. We don't
advise it.

3V3. A 3.3 volt supply generated by the on-board regulator. Maximum


current draw is 50 mA.

GND. Ground pins.

IOREF. This pin on the Arduino/Genuino board provides the voltage


reference with which the microcontroller operates. A properly configured shield
can read the IOREF pin voltage and select the appropriate power source or enable
voltage translators on the outputs to work with the 5V or 3.3V.

pg. 15
Schematic

2.4 Other Materials

TFT Screen

A thin-film-transistor liquid-crystal display (TFT LCD) is a variant of a liquid-crystal


display (LCD) that uses thin-film transistor (TFT) technology to improve image
qualities such as addressability and contrast. A TFT LCD is an active-matrix LCD, in
contrast to passive-matrix LCDs or simple, direct-driven LCDs with a few segments.
TFT LCDs are used in appliances including television sets, computer
monitors, mobile phones, handheld video game systems, personal digital
assistants, navigation systems and projectors.[1]

pg. 16
TFT LCDs are also used in car instrument clusters because they allow the driver to
customize the cluster, as well as being able to provide a skeuomorphic, analog-like
display with digital elements.

Wi-Fi Module ESP 8266

The ESP8266 Wi-Fi Module is a self-contained SOC with integrated TCP/IP protocol
stack that can give any microcontroller access to your Wi-Fi network. The ESP8266
is capable of either hosting an application or offloading all Wi-Fi networking
functions from another application processor. Each ESP8266 module comes pre-
programmed with an AT command set firmware, meaning, you can simply hook
this up to your Arduino device and get about as much Wi-Fi-ability as a Wi-Fi
Shield offers (and thats just out of the box)! The ESP8266 module is an extremely
cost effective board with a huge, and ever growing, community.
This module has a powerful enough on-board processing and storage capability
that allows it to be integrated with the sensors and other application specific
devices through its GPIOs with minimal development up-front and minimal
loading during runtime. Its high degree of on-chip integration allows for minimal
external circuitry, including the front-end module, is designed to occupy minimal
PCB area. The ESP8266 supports APSD for VoIP applications and Bluetooth co-
existence interfaces, it contains a self-calibrated RF allowing it to work under all
operating conditions, and requires no external RF parts.

Features:

pg. 17
802.11 b/g/n

Wi-Fi Direct (P2P), soft-AP

Integrated TCP/IP protocol stack

Integrated TR switch, baling, LNA, power amplifier and matching network

Integrated PLLs, regulators, DCXO and power management units

+19.5dBm output power in 802.11b mode

Power down leakage current of <10uA

1MB Flash Memory

Integrated low power 32-bit CPU could be used as application processor

SDIO 1.1 / 2.0, SPI, UART

STBC, 11 MIMO, 21 MIMO

A-MPDU & A-MSDU aggregation & 0.4ms guard interval

Wake up and transmit packets in < 2ms

Standby power consumption of < 1.0mW (DTIM3)

Hardware Connections

pg. 18
The hardware connections required to connect to the ESP8266 module are fairly
straight-forward but there are a couple of important items to note related to
power:

The ESP8266 requires 3.3V powerdo not power it with 5 volts.


The ESP8266 needs to communicate via serial at 3.3V and does not have 5V
tolerant inputs, so you need level conversion to communicate with a 5V
microcontroller like most Arduinos use.
So we will use this power supply as it will give 3.3 Volts when it is supplied 5V.

Ultrasonic Sensor

pg. 19
An Ultrasonic sensor is a device that can measure the distance to an object by
using sound waves. It measures distance by sending out a sound wave at a specific
frequency and listening for that sound wave to bounce back. By recording the
elapsed time between the sound wave being generated and the sound wave
bouncing back, it is possible to calculate the distance between the sonar sensor
and the object.

Diagram of the basic ultrasonic sensor operation

Since it is known that


sound travels through air
at about 344 m/s (1129
ft/s), you can take the time
for the sound wave to return and multiply it by 344 meters (or 1129 feet) to find
the total round-trip distance of the sound wave. Round-trip means that the sound
wave traveled 2 times the distance to the object before it was detected by the

pg. 20
sensor; it includes the 'trip' from the sonar sensor to the object AND the 'trip'
from the object to the Ultrasonic sensor (after the sound wave bounced off the
object).

MQ-2 Smoke Sensor

The MQ-2 smoke sensor is sensitive to smoke and to the following flammable
gases:
LPG
Butane
Propane
Methane
Alcohol
Hydrogen
The resistance of the sensor is different depending on the type of the gas.
The smoke sensor has a built-in potentiometer that allows you to adjust the
sensor sensitivity according to how accurate you want to detect gas.

MQ-2 sensor

pg. 21
Sensor Pin-out details

JUMPER WIRES

Jumper wires are used for making connections between items on your breadboard
and your Arduinos header pins.
There are three types of jumper wires:
Male to Male.

Male to Female.

Female to Female.

pg. 22
Stepper Motor

pg. 23
A stepper motor or step motor or stepping motor is a brushless DC electric
motor that divides a full rotation into a number of equal steps. The motor's
position can then be commanded to move and hold at one of these steps without
any feedback sensor (an open-loop controller), as long as the motor is carefully
sized to the application in respect to torque and speed.
Switched reluctance motors are very large stepping motors with a reduced pole
count, and generally are closed-loop commutated.

BREADBOARD
A breadboard is a construction base for prototyping of electronics. In the 1970s
the solderless breadboard (AKA plug board, a terminal array board) became
available. Because the solderless breadboard does not require soldering, it is
reusable. This makes it easy to use for creating temporary prototypes and
experimenting with circuit design. For this reason, solderless breadboards are
also extremely popular with students and in technological education .

pg. 24
Buzzers
A buzzer or beeper is an audio signaling device,[1] which may
be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and
beepers include alarm devices, timers, and confirmation of user input such as a
mouse click or keystroke. Piezo buzzer is an electronic device commonly used to
produce sound. Light weight, simple construction and low price make it usable in
various applications like car/truck reversing indicator, computers, call bells etc.
Piezo buzzer is based on the inverse principle of piezo electricity discovered in
1880 by Jacques and Pierre Curie. It is the phenomena of generating electricity
when mechanical pressure is applied to certain materials and the vice versa is also
true. Such materials are called piezo electric materials. Piezo electric materials are
either naturally available or manmade. Piezo ceramic is class of manmade
material, which poses piezo electric effect and is widely used to make disc, the
heart of piezo buzzer. When subjected to an alternating electric field they stretch
or compress, in accordance with the frequency of the signal thereby producing
sound.

pg. 25
SD CARD MODULE
The Arduino SD Card Shield is a simple solution for transferring data to and
from a standard SD card. The pinout is directly compatible with Arduino, but
can also be used with other microcontrollers. It allows you to add mass storage
and data logging to your project.

pg. 26
pg. 27
CHAPTR 3: IMPLEMENATION

3.1 Block Diagram

TFT Display Buzzers Web Page

Ultrasonic Sensor Arduino Mega Led Lights

RELAY MODULE

MQ 2 Smoke Sensor

Wi-Fi Module
SD CARD MODULE
ESP8266

pg. 28
3.2 Flow charts / Codes
For Servo Motor/ SSD Display
Code:
/*ParkingL02.pde

Arduining.com 08 JUL 2012

Code used in the production of the Youtube material.

*/

#include <Servo.h>

Servo myservo; // create servo object to control a servo

#define ServoM 12 //Connected to the servo motor.

#define Bright 11 //servo library disable PWM on pins 9 and 10.

#define Exit 9 //Pin connected to the EXIT button.

#define In 8 //Pin connected to the IN button.

#define BarLow 8 //Low position of the barrier.

#define BarUp 80 //Up position of the barrier.

#define CAPACITY 9 //Capacity of the parking lot.

#define INTEN 90 //Display intensity %

//Pins conections to segments (cathodes).

#define segA 0

#define segB 1

#define segC 2

#define segD 3

#define segE 4

#define segF 5

pg. 29
#define segG 6

//Array with the segments to represent the decimal numbers (0-9).

byte segments[10] = {

// pgfedcba <--- segments

B00111111, // number 0

B00000110, // number 1

B01011011, // number 2

B01001111, // number 3

B01100110, // number 4

B01101101, // number 5

B01111101, // number 6

B00000111, // number 7

B01111111, // number 8

B01101111 // number 9

};

void setup(){

myservo.attach(ServoM); // attaches the servo.

pinMode(Exit, INPUT); // set "EXIT" button pin to input

pinMode(In, INPUT); // set "IN" button pin to input

digitalWrite(Exit, HIGH); // Connect Pull-Up resistor.

digitalWrite(In, HIGH); // Connect Pull-Up resistor.

pinMode(segA,OUTPUT);

pinMode(segB,OUTPUT);

pinMode(segC,OUTPUT);

pinMode(segD,OUTPUT);

pinMode(segE,OUTPUT);

pg. 30
pinMode(segF,OUTPUT);

pinMode(segG,OUTPUT);

pinMode(Bright,OUTPUT);

analogWrite(Bright,255*INTEN/100);

myservo.write(BarLow); //Barrier in the low position

// delay(1000);

int Available= 9; // Number of places available.

//================================================================

void loop(){

Display(Available);

if(digitalRead(In)==0)

if(Available != 0){

Available--;

myservo.write(BarUp);

delay(3500);

myservo.write(BarLow);

if(digitalRead(Exit)==0)

if(Available != CAPACITY){

Available++;

myservo.write(BarUp);

delay(3500);

myservo.write(BarLow);

pg. 31
}

/*-------------------------------------------------------------------

Put the segments according to the number.

--------------------------------------------------------------------*/

void Display(int number){

byte segs = ~segments[number]; //"~" is used for commom anode.

digitalWrite(segA, bitRead(segs, 0) );

digitalWrite(segB, bitRead(segs, 1) );

digitalWrite(segC, bitRead(segs, 2) );

digitalWrite(segD, bitRead(segs, 3) );

digitalWrite(segE, bitRead(segs, 4) );

digitalWrite(segF, bitRead(segs, 5) );

digitalWrite(segG, bitRead(segs, 6) );

pg. 32
Flowchart

START

Car is at the barrier

YES
Does SSD Car Cannot Enter
shows 5
number

NO

Car Enters

Car Parkes

pg. 33
For Car Parking System
Code:
#include "SPI.h"

#include "Adafruit_GFX.h"

#include "Adafruit_ILI9340.h"

#if defined(__SAM3X8E__)

#undef __FlashStringHelper::F(string_literal)

#define F(string_literal) string_literal

#endif

// These are the pins used for the UNO

// for Due/Mega/Leonardo use the hardware SPI pins (which are different)

#define _sclk 24

#define _miso 22

#define _mosi 26

#define _cs 32

#define _dc 28

#define _rst 30

// Using software SPI is really not suggested, its incredibly slow

Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);

#define ledB1 40

#define ledR1 41

#define ledB2 42

#define ledR2 43

pg. 34
// defines pins numbers

#define IN4 4

const int trigPin = 5;

const int echoPin = 6;

const int trigPin1 = 7;

const int echoPin1 = 8;

// defines variables

long duration;

int distance = 0;

int distance1= 0;

void setup() {

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

pinMode(trigPin1, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin1, INPUT); // Sets the echoPin as an Input

pinMode(4, OUTPUT);

pinMode(ledB1, OUTPUT);

pinMode(ledR1, OUTPUT);

pinMode(ledB2, OUTPUT);

pinMode(ledR2, OUTPUT);

Serial.begin(9600); // Starts the serial communication

tft.begin();

Serial.begin(9600);

pg. 35
//Serial.print(F("Screen fill "));

// Serial.println(testFillScreen());

delay(50);

void loop() {

//testText();

tft.fillScreen(ILI9340_BLACK);

tft.setCursor(0, 0);

tft.println();

tft.setTextColor(ILI9340_GREEN);

//tft.setTextSize(3);

//tft.println("TEST COMPLETE");

tft.setTextSize(2);

tft.println();

tft.setTextSize(3);

tft.println("Distance=");

tft.setTextSize(1);

tft.println();

tft.setTextSize(3);

tft.println(distance);

if (distance >20)//&&(distance > 0))

digitalWrite(IN4, HIGH); // turn the LED on (HIGH is the voltage level)

tft.setTextSize(3);

tft.println("parking Empty");

digitalWrite(ledB1, HIGH);

digitalWrite(ledR1,LOW);

pg. 36
else if(distance <20 )//&&(distance < 150))

digitalWrite(IN4, HIGH); // turn the LED on (HIGH is the voltage level)

tft.setTextSize(3);

tft.println("parking full");

digitalWrite (ledR1, HIGH);

digitalWrite(ledB1, LOW);

delayMicroseconds(10);

// Clears the trigPin

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin, HIGH);

// Calculating the distance

distance= duration*0.034/2;

// Prints the distance on the Serial Monitor*/

Serial.print("Distance: ");

Serial.println(distance); //distance is the returned integer, it is the distance in cm

tft.setTextSize(2);

tft.println("");

tft.setTextSize(3);

tft.println("Distance=");

tft.setTextSize(3);

tft.println(distance1);

pg. 37
if (distance1 >20)//&&(distance > 0))

digitalWrite(IN4, HIGH); // turn the LED on (HIGH is the voltage level)

tft.setTextSize(3);

tft.println("parking Empty");

digitalWrite(ledB2, HIGH);

digitalWrite(ledR2,LOW);

else if(distance1 <20 )//&&(distance < 150))

digitalWrite(IN4, HIGH); // turn the LED on (HIGH is the voltage level)

tft.setTextSize(3);

tft.println("parking full");

digitalWrite (ledR2, HIGH);

digitalWrite(ledB2, LOW);

delayMicroseconds(10);

// Clears the trigPin1

digitalWrite(trigPin1, LOW);

delayMicroseconds(2);

// Sets the trigPin1 on HIGH state for 10 micro seconds

digitalWrite(trigPin1, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin1, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin1, HIGH);

pg. 38
// Calculating the distance

distance1= duration*0.034/2;

// Prints the distance on the Serial Monitor*/

Serial.print("Distance: ");

Serial.println(distance1); //distance is the returned integer, it is the distance in cm

delay(500);

//unsigned long testText() {}

unsigned long testFillScreen() {

tft.fillScreen(ILI9340_GREEN):}

Flowchart

START

YES
Distance > Car Parking is Empty
20?
GREEN LED ON

NO

Car Parking Full Show it on the TFT


RED LED ON Screen

pg. 39
Code for Wi-Fi Module ESP 8266

#include <SoftwareSerial.h>

#define DEBUG true

//SoftwareSerial Serial1(2,3); // make RX Arduino line is pin 2, make TX Arduino line is pin 3.
// This means that you need to connect the TX line from the esp to the
Arduino's pin 2
// and the RX line from the esp to the Arduino's pin 3
void setup()
{
Serial.begin(115200);
Serial1.begin(115200); // your esp's baud rate might be different
Serial.print("test");

sendData("AT+RST\r\n",2000,DEBUG); // reset module


sendData("AT+CWMODE=2\r\n",1000,DEBUG); // configure as access point
sendData("AT+CIFSR\r\n",1000,DEBUG); // get ip address
sendData("AT+CIPMUX=1\r\n",1000,DEBUG); // configure for multiple connections
sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG); // turn on server on port 80
}

void loop()
{

pg. 40
if(Serial1.available()) // check if the esp is sending a message
{
Serial.print("test");

while(Serial1.available())
{
// The esp has data so display its output to the serial window
char c = Serial1.read(); // read the next character.
Serial.write(c);
}

if(Serial1.find("+IPD,"))
{
delay(1000);

int connectionId = Serial1.read()-48; // subtract 48 because the read() function returns


// the ASCII decimal value and 0 (the first decimal number) starts at 48

String webpage = "<h1>Hello PAKISRAN </h1>&lth2>World!</h2><button>LED1</button>";

String cipSend = "AT+CIPSEND=";


cipSend += connectionId;
cipSend += ",";
cipSend +=webpage.length();
cipSend +="\r\n";

sendData(cipSend,1000,DEBUG);

pg. 41
sendData(webpage,1000,DEBUG);

webpage="<button>LED2</button>";

cipSend = "AT+CIPSEND=";
cipSend += connectionId;
cipSend += ",";
cipSend +=webpage.length();
cipSend +="\r\n";

sendData(cipSend,1000,DEBUG);
sendData(webpage,1000,DEBUG);

String closeCommand = "AT+CIPCLOSE=";


closeCommand+=connectionId; // append connection id
closeCommand+="\r\n";

sendData(closeCommand,3000,DEBUG);
}
}
}

String sendData(String command, const int timeout, boolean debug)


{
String response = "";

Serial1.print(command); // send the read character to the Serial1

pg. 42
Serial.print(command);
long int time = millis();

while( (time+timeout) > millis())


{
while(Serial1.available())
{

// The esp has data so display its output to the serial window
char c = Serial1.read(); // read the next character.
response+=c;
Serial.print(response);
}
}

if(debug)
{
Serial.print(response);
}

return response;
}

Code for MQ2 Sensor with Buzzer


#include <SD.h>

pg. 43
#include <SPI.h>

#include <DS3231.h>

File myFile;

DS3231 rtc(SDA, SCL);

int pinCS = 53; // Pin 10 on Arduino Uno

void setup() {

Serial.begin(9600);

pinMode(pinCS, OUTPUT);

// SD Card Initialization

if (SD.begin())

Serial.println("SD card is ready to use.");

} else

Serial.println("SD card initialization failed");

return;

rtc.begin();

void loop() {

Serial.print(rtc.getTimeStr());

Serial.print(",");

Serial.println(int(rtc.getTemp()));

myFile = SD.open("test.txt", FILE_WRITE);

if (myFile) {

myFile.print(rtc.getTimeStr());

myFile.print(",");

pg. 44
myFile.println(int(rtc.getTemp()));

myFile.close(); // close the file

// if the file didn't open, print an error:

else {

Serial.println("error opening test.txt");

delay(3000);

Oscilloscope Readings

pg. 45
Data Logging for SD Card Module
#include <SD.h>

#include <SPI.h>

File myFile;

int pinCS = 53; // Pin 10 on Arduino Uno

void setup() {

Serial.begin(9600);

pinMode(pinCS, OUTPUT);

// SD Card Initialization

if (SD.begin())

Serial.println("SD card is ready to use.");

} else

Serial.println("SD card initialization failed");

return;

pg. 46
// Create/Open file

myFile = SD.open("test.txt", FILE_WRITE);

// if the file opened okay, write to it:

if (myFile) {

Serial.println("Writing to file...");

// Write to file

myFile.println("Testing text 1, 2 ,3...");

myFile.close(); // close the file

Serial.println("Done.");

// if the file didn't open, print an error:

else {

Serial.println("error opening test.txt");

// Reading the file

myFile = SD.open("test.txt");

if (myFile) {

Serial.println("Read:");

// Reading the whole file

while (myFile.available()) {

Serial.write(myFile.read());

myFile.close();

else {

Serial.println("error opening test.txt");

pg. 47
}

void loop() {

// empty

3.4 Simulation
Proteus for Arduino MEGA

pg. 48
Proteus for Arduino UNO:

pg. 49
Chapter 4: Project Budget

Materials Costs

1) Arduino MEGA RS 1200

2) Arduino UNO RS 600

3) Jumper Wires RS 1000

4) Breadboard RS 300

5) Vero board RS 300

6) Wi-Fi Module ESP 8266 RS 500

7) TFT Screen RS 1500

8) Ultrasonic Sensor RS 750

9) MQ-2 Sensor RS 500


10) Thermopolis RS 400
11) Stepper Motor RS 300
12) 7 Segment Display RS 250
Total RS 7600

pg. 50
Chapter 5: Project Schedule

Week 1 ---------------------- Mind Mapping


Week 2 ---------------------- Buying the materials
Week 3 --------------------- Checking/ Implementation of things and then
integration
Week 4 -------------------- Fabrication of Project

Chapter 6: Conclusion
The line following robot project challenged the group to cooperate, communicate,
and expand understanding of electronics, mechanical systems, and their integration
with programming. The successful completion of every task demonstrated the
potential of mechatronics systems and a positive group dynamic. Smarter versions
of line followers are used to deliver mails within office building and deliver
medications in a hospital. This technology has been suggested for running buses
and other mass transit systems and may end up as a part of autonomous cars
navigating the freeway. It will be very helpful to solve problem for parking system
in Pakistan.

pg. 51
References
https://www.youtube.com/watch?v=ONaXuAc1Lm4
http://www.instructables.com/id/Arduino-Parking-Sensor/
https://arduining.com/2012/10/13/arduino-parking-lot-filled/
http://www.instructables.com/id/Distance-Sensor-with-LEDs-and-buzzer/
https://create.arduino.cc/projecthub/nolan-mathews/connect-to-blynk-using-esp8266-as-arduino-uno-
wifi-shield-m1-46a453
https://create.arduino.cc/projecthub/KaustubhAgarwal/smart-parking-bdfa99
http://www.whatimade.today/esp8266-easiest-way-to-program-so-far/
http://download.arduino.org/products/UNOWIFI/0A-ESP8266-Datasheet-EN-v4.3.pdf

pg. 52

Das könnte Ihnen auch gefallen