Anda di halaman 1dari 37

SMART WAITER

Department of Mechanical Engineering


Bangladesh University of Engineering and Technology
Dhaka-1000

Course No: ME 362


Course Title: Instrumentation and Measurement Sessional
Group No: C26

ACCOMPLISHED BY
NURUZZAMAN SAKIB (1210156)
TANZEEL KABIR (1210163)
SUNANDA KUMAR SAHA (1210170)
MD AL-HASAN MRIDHA (1210177)

Date of Submission: 13.12.2015


Copyright by Bangladesh University of Engineering and Technology. All rights reserved. This
book however can be used by BUET to reproduce any of the module or the whole robot, reuse
the code and design for further implementation, improvisation or as study material in any form.
Acknowledgement

First of all we would like to thank our Almighty Creator for the completion of our first team
project as undergraduate students of Bangladesh University of Engineering and Technology. This
project contains contribution of many great people. Without their helps, their inspiration and
their guidance this project may not have seen light. We take this opportunity to express our
profound gratitude and deep regards to our respected teachers

a) Dr. M. A. Rashid Sarkar (Professor, Dept. of ME, BUET)


b) Aminul Islam Khan (Assistant Professor, Dept. of ME, BUET)
c) Anup Saha (Lecturer, Dept. of ME, BUET)
d) Partha Kumar Das (Lecturer, Dept. of ME, BUET)

The blessings, help and guidance given by them time to time shall carry us a long way in the
journey of our life on which we are about to embark.

We express our sincere gratitude to the Mechanical Engineering Department for providing us
such an opportunity for implementing the ideas in our mind.

And we also thank all those, whose name may have not been mentioned here, but they were at
our side all along.
Abstract

Robot is a device that automatically performs complicated and often repetitive tasks, it is built on
mechanism guided by automatic controls. In this course we wanted to make Smart Waiter as
our project because we were eager to make something related to robotics and has vast usefulness
in our practical life. Our intention was to build something which is not popular yet, but has a
good chance to be applied in our daily life. The Smart Waiter is an exceptional autonomous robot
which has the ability to follow a designated path like a pathfinder with the help of IR sensor
arrays and reach its intended destination. It is an Arduino based robotic design implemented to
seek out and detect its required destination and perform its deliberate tasks with precision and
accuracy. It has a simple mechanical design with simple mechanism with which performing the
necessary tasks become easier. Due to its design parameters, it also requires less power and draw
less current which allows us to work with the robot safely. Moreover, it also adds to the safety to
its environment and the people around it. We have mainly designed it for the modern offices for
food serving and file transfer purpose. But with proper improvement, modification and
improvisation we can convert it into a complete Office Assistant which will be able to do various
official tasks. Even it can also be implemented in digital restaurants as waiter which will give the
restaurant a modern and digital look.
Table of Contents

Chapter Page No
1. Introduction
1.1. Background ..... 3
1.2. Definition .... 3
2. Proposed Methodology
2.1. Approach ..4
2.2. Design Analysis ....... 4
2.2.1 Mechanical Components .... 5-6
2.2.1.1 Acrylic Sheet .... 5
2.2.1.2 Wheel .... 5
2.2.1.3 Motor .... 6
2.2.1.4 Aluminium Angle ..... 6
2.2.1.5 Clamp ... 6
2.2.2 Electrical Components ..... 7-10
2.2.2.1 Arduino Uno ..... 7
2.2.2.2 Motor Driver .....7
2.2.2.3 DC-DC Voltage Booster ....... 8
2.2.2.4 Bluetooth Module ..... 8
2.2.2.5 LCD Display .....9
2.2.2.6 Reflective Optical Sensor ..... 9
2.2.2.7 Battery ...... 10
2.2.2.8 Vero Board ... 10
2.2.3 Components Used for Connections .... 11
2.2.4 Softwares Used ....... 11
2.3. Basic Working Principal ...... 12
2.4. Circuit Diagram ....... 12
2.5. Screenshot of Android Application . 13
3. Solution Validation, Analysis of Data, Results
3.1 Solution Validation ...... 14
3.2 Analysis of Data ... 14
3.3 Result 14
4. Limitations, Conclusion and Recommendations
4.1 Limitations .. 15
4.2 Conclusion ...... 15
4.3 Recommendations ... 15

References ...................................................................................................................... 16

Appendix
6.1 Arduino Code 17-31
6.2 Android Application Code ........ 32-33

5
Chapter 1

Introduction

This course of Level-3, Term-1 of Mechanical Engineering Department of Bangladesh


University of Engineering and Technology gave us a chance to practice all the knowledge and
skills which we already have gained along the academic session in solving practical life
problems through a project in order to be an efficient and a good engineer.

1.1Background:
In Bangladesh, many offices which have good quality and standard to its credentials sometimes
lose its charismatic reputation and business status because of certain facts overlooked by their
entrepreneurs. Facts such as time maintained quality service, human errors during service, lack
of systematic approach are critical. Now-a-days it has become very expensive to keep a smart
and learned waiter or a service boy in the offices as they have to be paid a fair amount of salary.
Keeping this in view, we designed our robot Smart Waiter which is pretty cheap to maintain
and can do the task of an office boy without any faults. This also gives a nice and digital look to
the offices. This idea of using artificial devices can reduce human errors and give more accuracy
to the proses. This idea is getting popular increasingly in different parts of the world. For
example, in China many restaurants are using robots to take order and serve foods. All this things
inspired us to go for this project.

1.2Definition:
Smart Waiter is a robot which takes the order from the user along with his table number via
Bluetooth signal and execute that order by basic line following mechanism. It can also transfer
official files from one table to another in the same way. Here we used an application for
smartphones to give the order for food and file transfer.

6
Chapter 2

Proposed Methodology

2.1 Approach:
We designed a digital waiter for modern offices which takes the order of a task from a table via
Bluetooth signal using an android application and completes that task by basic line following
mechanism.

2.2 Design Analysis:


In this project the components we used can be categorized into two main classes. One is the outer
mechanical components which make the chassis of our project. And other is the electrical
components which make the circuit to run the robot. We also used an android application to give
the order to the robot. A complete overview of our project is given below:

Fig.2.1. The complete view of the robot

7
2.2.1 Mechanical Components
The mechanical parts of this project are as follow:
2.2.1.1 Acrylic Sheet:
Two acrylic sheets of 4 x 5 with a thickness of 3 mm are used as the base and tray of our
robot.

Fig.2.2. Acrylic Sheet

2.2.1.2 Wheel:
We used two pololu wheels as our rear wheels. These custom-designed white plastic wheels have
rubber tires measuring 1.6 in diameter and these wheels fit the outer shaft of our micro metal
gear motors. We also used two 3/8 pololu ball caster as our front wheels.

8
Fig.2.3. Wheel with Rubber Tire and Caster Ball

2.2.1.3 Motor:
We used two micro metal gear motors of 12V,300rpm to run the rear wheels. We connected the
outer shaft of the motors into the hub of the rear wheels.

Fig.2.4. Micro Metal Gear Motor

2.2.1.4 Aluminium Angle:


We used aluminium angles to support the tray from the base.

Fig.2.5. Aluminium Angle

2.2.1.5 Clamp:
We used two clamps to set the motors in the base of the robot.

9
Fig.2.6. Clamp

2.2.2 Electrical Components:


The electrical components of this project are as follow:
2.2.2.1 Arduino Uno:
We used an Arduino Uno to execute the functions. It 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 quartz crystal, a USB connection, a power jack, an ICSP header and a
reset button. It contains everything to support the microcontroller. It can be connected to a
computer with a USB cable or can be powered with an AC-to-DC adapter or a battery.

Fig.2.7. Arduino Uno

2.2.2.2 Motor Driver:


We have used a L298N motor driver to drive the DC gear motors. This module is based on
L298N high voltage, high current dual full bridge driver which can be used to drive two DC
motors using standard logic level signal control. This module integrates a built-in 5V power
supply.

10
Fig.2.8. L298N Motor Driver

2.2.2.3 DC-DC Voltage Booster:


As our LiPo battery was of 11.1V and we used motors of 12V we used a DC-DC voltage booster
to boost up the battery voltage. This is a breakboard boost converter which can convert as low as
3.7V to as high as 34V. We always kept the input voltage lower than the output voltage.
Otherwise it would have burnt the circuit.

Fig.2.9. DC-DC Voltage Booster

2.2.2.4 Bluetooth Module:


As our robot gets the order from the user via Bluetooth signals we used a Bluetooth module to
get that signal. We used HC-05 Bluetooth Module. This works as a serial (RX/TX) pipe. Any
serial stream from 9600 to 115200bps can be passed seamlessly from any computer/mobile to the
target. The remote unit can be powered from 3.3V up to 6V from battery attachment. It has a
range of 10 meters (30 feet).

11
Fig.2.10. HC-05 Bluetooth Module

12
2.2.2.5 LCD Display:
We used a 16x2 LCD (Liquid Crystal Display) display in our robot to show the order status of
the user. This is a flat display that uses the light modulating properties of liquid display. The
LCD panel consists of 16 columns and 2 rows. It can show up to 16 characters in 2 lines.

Fig.2.11. 16x2 LCD Display

2.2.2.6 Reflective Optical Sensor:


As our robot completes an order by basic line following mechanism we used six TCRT5000
Reflective Optical Sensors for doing that. The TCRT5000 is a reflective sensor which include an
infrared emitter and phototransistor in a leaded package which blocks visible light.

Fig.2.12. Reflective Optical Sensor

13
2.2.2.7 Battery:
We used a 11.1V-1000mah three cell LiPo battery as power source. It is a lithium polymer
battery or more correctly lithium-ion polymer battery. It is a rechargeable battery of lithium-ion
technology in pouch format.

Fig.2.13. Battery

2.2.2.8 Vero Board:


We used solderable vero board for interconnecting the electrical components. It gave us the
freedom of not using complicated PCB boards.

Fig.2.14. Vero Board

14
2.2.3 Components Used for Connections:
We used different types of things for connecting the mechanical and electrical components to
make chassis and circuit of the robot. The list of these items are as follow:
Jump Wires (Male to male, male to female, female to female)
Connecting Wires
Glue Gun (For joining electrical components with the acrylic sheet)
Both Sided Tape
Nut and Bolts
Highter
Soldering Iron

Fig.2.15. Components Used for Connection

2.2.4 Software Used:


The softwares we used during this project are:
Solidworks
Arduino
MIT App Inventor
Fritzing

15
2.3 Basic Working Principle:
First of all the user has to connect his smartphone with the robot via Bluetooth. Then he can give
the task mentioning his table number using the android application. When the robot gets the task
via Bluetooth signal it starts from its waiting zone for executing that task by basic line following
mechanism. For this purpose we have used TCRT5000 Reflective Optical Sensors. It can sense
the reflected light from the surface and sends the value to the Arduino board where the value is
compared with the calibrated value. Using this the Arduino sends command to the Motor Driver
which turns on or off the motors according to the command. We have designed the code in such a
way that the robot will only follow the black line and avoid other lines. To turn left or right it has
to sense the infrared transmitter that lies beside the road, than it will find the black branch of the
road. At the end of the track when the robot will sense the white surface it will stop in front of
the counters and table. We have used 5s delay in every stoppage. So the robot will stop for five
seconds in front of the counters and the tables for loading and unloading purpose. We have used
a LCD display to show the order status. After all the tasks the robot will come back to its waiting
zone and wait for the next task.

2.4 Circuit Diagram:

Fig.2.16 Complete Circuit Diagram

16
2.5 Screenshot of Android Application:

Fig.2.17. Android Application

17
Chapter 3

Solution Validation, Analysis of Data, Results

3.1 Solution Validation:


Our mechanical part worked well although there was a slight variation in the speed of the two
motors. After some trial and error and using PWM we managed to solve that problem. We
worked on establishing wireless serial communication with the robot using Bluetooth device. We
worked with different smartphones and we got a very positive result. Our robot responded to
each and every device.

3.2 Analysis of Data:


Our robot was quite good in line following. We used six TCRT5000 Reflective Optical Sensors
in this case. It follows the track quite smoothly and without any error.
We used Bluetooth device to send the order to the robot. The Bluetooth device which we used
has a range of round about 10 meters which is quite satisfactory.
The android application which we designed for the users is very simple and easy to use. Its size
is only 1.35 MB and can easily be installed in any android device of any version.

3.3 Results:
The results we got from the tests were very positive and encouraging. The robot first take the
order from the android application and there by execute the order instantly without any vital
error. We performed it with different android devices and got the same results. The positive side
of this project can be summed up like this:
Bluetooth control mode gives the freedom to give order from anywhere within the range.
The mechanical design is very light and there is no sharp edge in the body which adds to
the safety of the people around it.
The android application is very simple and small in size and can be easily installed in any
android device.
The mechanical and electrical components which we used are not very expensive which
makes this project cost effective.

18
Chapter 4

Limitations, Conclusion and Recommendations

4.1 Limitations:
We tried our level best to add maximum features to our project Smart Waiter. But still there are
some limitations in our project.
There is no robotic arm in the robot. So the loading and unloading processes have to be
done manually.
The range of the Bluetooth module is round about 10 meters (30 feet). Anyone out of this
range will not be able to connect with the robot.
At a time only one person can connect with the robot and give the order.
If battery voltage become very low the booster dont work correctly.

4.2 Recommendations:
To draw the end of this discussion, we can simple say that there is always room for
improvement. The further improvements which can be done are as follow:
Robotic arm can be added to the robot, so that the robot itself can pick up things without
the help of human being.
For bigger range Wi-Fi module can be used instead of Bluetooth module.
By improving the application and the code we can add more features to the Smart
Waiter which will turn it into a complete Office Assistant.
By improving the mechanical design, adding some extra safety precautions and using
some extra electrical components we can implement this idea in restaurants also.

4.3 Conclusion:
To complete the project we gave our best effort and as a result got this outcome. Our course
teachers were very encouraging and inspirational. Their proper guideline and our hard work
made this project possible. Though there are some limitations in the project, these can be avoided
by further improvement.
This course ME 362 was quite a different and exciting course for us. It gave us the opportunity to
express our talent. This course taught us how to tackle with practical life problems and how to
overcome them. After all this was a great experience for all of us.

19
References

1. http://ai2.appinventor.mit.edu/
2. https://www.techshopbd.com/
3. http://playground.arduino.cc/
4. https://www.youtube.com/watch?v=MkKC8sjx3z0&ab_channel=ForceTronics

20
Appendix

6.1 Arduino Code:


#define L_Dir_1 2
#define L_Dir_2 4
#define L_Speed 3
#define R_Dir_1 5
#define R_Dir_2 7
#define R_Speed 6
#define LBSpeed 130
#define RBSpeed 135
#include<LiquidCrystal.h>
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
int i,j,tp[5];
bool c=0,state=0;
////////////////////////////////////////////////////////
int sensor[6] = {0};
int black[6] = {0, 0, 0, 0, 0, 0};
int white[6] = {1050, 1050, 1050, 1050, 1050, 1050};
int avg[6] = {0};
float error=0,prevError=0;
int Kp = 8 , Kd = 95;//9,95
int crossing = 0;
int counter = 0;
int Order_Path[7][12]=

{
-1,1,2,-1,1,5,0,0,0,0,0,0, //Tea=0
0,2,0,5,0,0,0,0,0,0,0,0, //Biscuit=1

21
1,-1,2,1,-1,5,0,0,0,0,0,0, //Coffee=2
-1,1,2,-1,-1,2,0,5,0,0,0,0, //Tea & Biscuit=3
-1,1,2,-1,0,-1,2,1,-1,5,0,0, //Tea & Coffee=4
0,2,-1,-1,2,1,-1,5,0,0,0,0, //Biscuit & Coffee=5
-1,1,2,-1,-1,2,-1,-1,2,1,-1,5 //Tea, Biscuit & Coffee=6
};
int Table_Path[4][7]=
{
0,1,2,-1,5,0,0, //Table 01=0
0,-1,2,1,5,0,0, //Table 02=1
0,0,1,2,-1,0,5, //Table 03=2
0,0,-1,2,1,0,5 //Table 04=3
};
int File_Table_Path[12][8]=
{
1,2,0,2,1,5,0,0, //Table 01>>02 == 0
1,2,1,1,2,-1,0,5, //Table 01>>03 == 1
1,2,1,-1,2,1,0,5, //Table 01>>04 == 2
-1,2,0,2,-1,5,0,0, //Table 02>>01 == 3
-1,2,-1,1,2,-1,0,5, //Table 02>>03 == 4
-1,2,-1,-1,2,1,0,5, //Table 02>>04 == 5
0,1,2,-1,-1,2,-1,5, //Table 03>>01 == 6
0,1,2,-1,1,2,1,5, //Table 03>>02 == 7
0,1,2,0,2,1,0,5, //Table 03>>04 == 8
0,-1,2,1,-1,2,-1,5, //Table 04>>01 == 9
0,-1,2,1,1,2,1,5, //Table 04>>02 == 10
0,-1,2,0,2,-1,0,5 //Table 04>>03 == 11
};
int path[20]={0};
//////////////////////////////////////////////////////////////////

22
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5,OUTPUT);
pinMode(7,OUTPUT);
for(i=0;i<5;i++){
tp[i]=0;
}
lcd.begin(16, 2);
lcd.clear();
delay(25);
lcd.setCursor(5, 0);
lcd.print("ME-362");
delay(50);
lcd.setCursor(2, 1);
lcd.print("SMART WAITER");
delay(50);
delay(1450);
calibration();
delay(1500);
}
void loop() {
delay(30);
String txt;
String tptxt;
String filename;
int orr=0,l=0;
while(Serial.available()){
txt += char(Serial.read());

23
}
l=txt.length();
if(l>5){
for(i=0;i<5;i++){
tptxt +=txt[i];
}
for(i=5;i<l;i++){
filename += txt[i];
}
c=1;
}
else if(l>0 && l<=5){
for(i=0;i<5;i++){
tptxt +=txt[i];
}
c=0;
}
if(l){
orr = tptxt.toInt();
for(i=4;i>=0;i--){
tp[i]=orr%10;
orr/=10;
}
if(((tp[0]||tp[1]||tp[2])&& tp[3])||(tp[3]&& tp[4] && l>5)){
state=1;
Serial.write(" Successful ");
}
else {
Serial.write(" Try Again! " );
for(i=0;i<5;i++){

24
tp[i]=0;
}
}
}
////////////////////////////////////////////////////////////////////////////////////////
if(state){
lcd.clear();
delay(50);
lcd_write();
/////////////////////////////////////////Path////////////////////////////////////////
if( c==0){
if(tp[0]>0 && tp[1]==0 && tp[2]==0) i=0;
else if(tp[0]==0 && tp[1]>0 && tp[2]==0) i=1;
else if(tp[0]==0 && tp[1]==0 && tp[2]>0) i=2;
else if(tp[0]>0 && tp[1]>0 && tp[2]==0) i=3;
else if(tp[0]>0 && tp[1]==0 && tp[2]>0) i=4;
else if(tp[0]==0 && tp[1]>0 && tp[2]>0) i=5;
else if(tp[0]>0 && tp[1]>0 && tp[2]>0) i=6;
for(j=0;j<12;j++) {
if(Order_Path[i][j]!=5){
path[j]=Order_Path[i][j];
}
else break;
}
for(i=0;i<7;i++){
path[j]=Table_Path[tp[3]-1][i];
j++;
}
}
else if( c==1 ){

25
lcd.setCursor(9, 0);
lcd.print(filename);
delay(50);
if(tp[4]==1 && tp[3]==2) j=0;
else if(tp[4]==1 && tp[3]==3) j=1;
else if(tp[4]==1 && tp[3]==4) j=2;
else if(tp[4]==2 && tp[3]==1) j=3;
else if(tp[4]==2 && tp[3]==3) j=4;
else if(tp[4]==2 && tp[3]==4) j=5;
else if(tp[4]==3 && tp[3]==1) j=6;
else if(tp[4]==3 && tp[3]==2) j=7;
else if(tp[4]==3 && tp[3]==4) j=8;
else if(tp[4]==4 && tp[3]==1) j=9;
else if(tp[4]==4 && tp[3]==2) j=10;
else if(tp[4]==4 && tp[3]==3) j=11;
for(i=0;i<8;i++) {
path[i]=File_Table_Path[j][i];
}
}
/////////////////////////////////////Order//////////////////////////////////
counter=-1;
if( c==1){
One80_Turn();
}
while(1) {
sensor_reading();
if(path[counter]==5) {
delay(25);//40
wheel(-200,-200);
delay(20);

26
wheel(0,0);
delay(500);
break;
}
else {
if(crossing==1) {
counter += 1;
if (path[counter] == 1) R_Turn();
else if (path[counter] == -1) L_Turn();
else if (path[counter] == 2) One80_Turn();
while(crossing==1) {
wheel(200,200);
sensor_reading();
}
}
else LineFollow();
}
}
///////////////////////////////////////////////////////////////////////////////////
delay(1000);
for(i=0;i<5;i++){
tp[i]=0;
}
lcd.clear();
delay(25);
lcd.setCursor(5, 0);
lcd.print("ME-362");
delay(50);
lcd.setCursor(2, 1);
lcd.print("SMART WAITER");

27
delay(50);
state = 0;
counter=-1;
}
}
void calibration()
{
wheel(80, -80);
int s[6] = {0};
while (millis() < 5000) {
for (i = 0; i < 6; i++) {
s[i] = analogRead(i);
if (s[i] > black[i]) black[i] = s[i];
if (s[i] < white[i]) white[i] = s[i];
}
}
for (i = 0; i < 6; i++) {
avg[i] = (( black[i] + white[i] )/1.8);
}
wheel(0, 0);
delay(500);
}
void sensor_reading() {
int s[6] = {0};
for (i = 0; i < 6; i++) {
s[i] = analogRead(i);
if (s[i] > avg[i]) sensor[i] = 1;
else sensor[i] = 0;
}
for (i = 0; i < 5; i++) {

28
if (s[i] > black[i]) s[i] = black[i];
if (s[i] < white[i]) s[i] = white[i];
s[i]=map(s[i],white[i],black[i],0,20);
}
/////////////////////////////////////Intersection//////////////////////////////
if (sensor[0] == 1 && sensor[1] == 1 && sensor[2] == 1 && sensor[3] == 1 && sensor[4] ==
1) error = 0 , crossing = 1;
///////////////////////////////////Line Follow///////////////////////////////
else {
int sum = 0;
int avrg=0;
sum = ((s[0] * 5) + (s[1] * 10) + (s[2] * 20)+(s[3] * 30)+(s[4] * 35));
if (sum == 0) error = 0;
else
{
avrg = sum / (s[0] + s[1] + s[2] + s[3] + s[4]);
error = avrg - 20;
}
crossing=0;
}
}
void wheel(int l, int r)
{
if (l > 0) {
digitalWrite(L_Dir_1, HIGH);
digitalWrite(L_Dir_2, LOW);
}
else if (l < 0) {
digitalWrite(L_Dir_1, LOW);
digitalWrite(L_Dir_2, HIGH);

29
}
else if (l == 0) {
digitalWrite(L_Dir_1, LOW);
digitalWrite(L_Dir_2, LOW);
}
if (r > 0) {
digitalWrite(R_Dir_1, HIGH);
digitalWrite(R_Dir_2, LOW);
}
else if (r < 0) {
digitalWrite(R_Dir_1, LOW);
digitalWrite(R_Dir_2, HIGH);
}
else if (r == 0) {
digitalWrite(R_Dir_1, LOW);
digitalWrite(R_Dir_2, LOW);
}
l = abs(l);
r = abs(r);
if (l > 240) l = 240;
if (r > 240) r = 240;
analogWrite(L_Speed, l);
analogWrite(R_Speed, r);
}
void LineFollow() {
sensor_reading();
float variation = ( Kp * error + Kd * ( error - prevError ) ) ;
wheel( LBSpeed + int(variation), RBSpeed - int(variation) );
prevError = error;
}

30
void L_Turn() {
sensor_reading();
while(sensor[5]!=1){
wheel(100,100);
sensor_reading();
}
wheel(-150,-150);
delay(20);
wheel(0,0);
delay(200);
wheel(-150,150);
delay(250);
sensor_reading();
while(sensor[1]!=1){
wheel(-150,150);
sensor_reading();
}
wheel(150,-150);
delay(30);
wheel(0,0);
delay(100);
fixPos();
wheel(0,0);
delay(200);
sensor_reading();
}
void R_Turn() {
sensor_reading();
while(sensor[5]!=1){
wheel(100,100);

31
sensor_reading();
}
wheel(-150,-150);
delay(20);
wheel(0,0);
delay(200);
wheel(150,-150);
delay(250);
sensor_reading();
while(sensor[3]!=1){
wheel(150,-150);
sensor_reading();
}
wheel(-150,150);
delay(30);
wheel(0,0);
delay(100);
fixPos();
wheel(0,0);
delay(200);
sensor_reading();
}
void One80_Turn() {
delay(60);
wheel(-150,-150);
delay(20);
wheel(0,0);
delay(5000);
wheel(150,-150);
delay(600);

32
sensor_reading();
while(sensor[3]!=1){
wheel(150,-150);
sensor_reading();
}
wheel(-150,150);
delay(30);
wheel(0,0);
delay(100);
fixPos();
wheel(0,0);
delay(200);
sensor_reading();
}
void fixPos() {
wheel(0, 0);
prevError = 0;
sensor_reading();
int lt = 0;
while (1)
{
sensor_reading();
if ((abs(error)<=5)) break;
if ((error < -5) && (abs(error) <= 15))
{
wheel(-80,80);
lt = 1;
}
else if ((error > 5) && (abs(error) <= 15))
{

33
wheel(100,-100);
lt = -1;
}
}
if(lt==-1) wheel(-100,100);
else if(lt==1) wheel(80,-80);
delay(20);
wheel(0, 0);
delay(50);
}
void lcd_write(){
lcd.clear();
if(c==0){
lcd.setCursor(2, 0);
lcd.print("#Table No:0");
delay(50);
lcd.setCursor(0, 1);
lcd.print("T:0");
delay(50);
lcd.setCursor(6, 1);
lcd.print("B:0");
delay(50);
lcd.setCursor(12, 1);
lcd.print("C:0");
delay(50);
lcd.setCursor(13, 0);
lcd.print(tp[3]);
delay(50);
lcd.setCursor(3, 1);
lcd.print(tp[0]);

34
delay(50);
lcd.setCursor(9, 1);
lcd.print(tp[1]);
delay(50);
lcd.setCursor(15, 1);
lcd.print(tp[2]);
delay(50);
}
if(c==1){
lcd.setCursor(2, 0);
lcd.print("F-Code:");
delay(50);
lcd.setCursor(0, 1);
lcd.print("From:0");
delay(50);
lcd.setCursor(11, 1);
lcd.print("To:0");
delay(50);
lcd.setCursor(6, 1);
lcd.print(tp[4]);
delay(50);
lcd.setCursor(15, 1);
lcd.print(tp[3]);
delay(50);
}
}
6.2 Android Application Code:

35
36
37

Anda mungkin juga menyukai