tag:blogger.com,1999:blog-31281734358696174462024-03-05T13:38:04.165-08:00Android Processing Arduinokithttp://www.blogger.com/profile/15380200496091540455noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-3128173435869617446.post-66730818170669165522014-08-24T17:02:00.000-07:002014-08-24T17:04:42.288-07:00Augmented Reality <div style="text-align: justify;">
It has been a long time i didn't update my blog. I've done some big and small project between this periods and i gonna post it here gradually :)</div>
<div style="text-align: justify;">
<br /></div>
<br />
<div style="text-align: justify;">
Today I'm gonna share about a image processing applications. This is one of my assignment during my diploma studies. I'm using Processing to write this application and most of the codes are referring from this <a href="http://www.creativeapplications.net/processing/augmented-reality-with-processing-tutorial-processing/"><span style="color: blue;">website</span></a>. I just do some modifications on the code, add more features, and implement it with the live camera view. You will need to download the NyArtoolkit and also GsVideo for Processing to perform this function.</div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
The original code should display the cube on the markers detected in the live camera. I modified the program to recognized few markers and display different patterns on each of it at one time. If you wish to displace more and different pattern you just need to Google for different pattern or shape code and put it into the Processing. Also, in this Augmented reality application, I added few rows of codes so that i can edit the scales of the pattern shown in the screen in the live camera. </div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
Below are the code i'm using for this application with the demo video:</div>
<div style="text-align: justify;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.blogger.com/video.g?token=AD6v5dw9xmS4xemKuXkmSrZkTeXe8XrUIh3ls7G2Z5gmQUb1Xo30lymBtrpcPYcb9u5xiCB2s3AZeOQJV2p70uPhUw' class='b-hbp-video b-uploaded' frameborder='0'></iframe></div>
<div style="text-align: justify;">
<br /></div>
<div style="text-align: justify;">
<pre style="text-align: start; white-space: pre-wrap; word-wrap: break-word;">// Processing + NyARToolkit + GSVideo = Argumeneted reality
import java.io.*; // for the loadPatternFilenames() function
import processing.opengl.*; // for OPENGL rendering
import jp.nyatla.nyar4psg.*; // the NyARToolkit Processing library
import codeanticode.gsvideo.*; // the GSVideo library
// the full path to the camera_para.dat file
String camPara = "C:/Users/kit/Documents/Processing/libraries/nyar4psg/data/camera_para.dat";
// the full path to the .patt pattern files
String patternPath = "C:/Users/kit/Documents/Processing/libraries/nyar4psg/patternMaker/examples/ARToolKit_Patterns";
// the dimensions at which the AR will take place.
int arWidth = 640;
int arHeight = 360;
// the number of pattern markers (from the complete list of .patt files) that will be detected, here the first 10 from the list.
int numMarkers = 10;
float scales = 1.0;
float mS = 0.2;
GSCapture cam;
MultiMarker nya;
float[] scaler = new float[numMarkers];
color[] colors = new color[numMarkers];
PVector rot, speed;
void setup() {
size(1280, 720, OPENGL); // the sketch size
cam = new GSCapture(this, 1280, 720); // initializing the webcam capture at a specific resolution
cam.start(); // start capturing
noStroke(); // turn off stroke for the rest of this sketch
// create a new MultiMarker at a specific resolution (arWidth x arHeight), with the default camera calibration and coordinate system
nya = new MultiMarker(this, arWidth, arHeight, camPara, NyAR4PsgConfig.CONFIG_DEFAULT);
// set the delay after which a lost marker is no longer displayed. by default set to something higher, but here manually set to immediate.
nya.setLostDelay(1);
String[] patterns = loadPatternFilenames(patternPath);
rot = new PVector(random(TWO_PI), random(TWO_PI), random(TWO_PI)); // random x, y, z rotation
speed = new PVector(random(-mS, mS), random(-mS, mS), random(-mS, mS)); // random x, y, z speed (within maxSpeed boundaries)
// for the selected number of markers, add the marker for detection
for (int i=0; i<numMarkers; i++) {
nya.addARMarker(patternPath + "/" + patterns[i], 80);
scaler[i] = random(0.8, 1.9); // scaled a little smaller or bigger
colors[i] = color(random(255), random(255), random(255), 160); // random color, always at a transparency of 160
}
}
void draw() {
if (cam.available()) {
cam.read();
background(cam); // a background call is needed for correct display of the marker results
// create a copy of the cam image at the resolution of the AR detection to avoid error
PImage cSmall = cam.get();
cSmall.resize(arWidth, arHeight);
nya.detect(cSmall); // detect markers in the image
drawShapes();
println("Scale : " + scales);
}
}
// this function draws correctly placed 3D boxes on top of detected markers
void drawShapes() {
// set the AR perspective uniformly, this general point-of-view is the same for all markers
nya.setARPerspective();
// set the text alignment (full centered) and size (big)
textAlign(CENTER, CENTER);
textSize(20);
for (int i=0; i<numMarkers; i++) {
// checking exist marker
if ((!nya.isExistMarker(i))) { continue; }
if(i==0) //MARKER NUMBER 0
{
// get the Matrix for this marker and use it (through setMatrix)
setMatrix(nya.getMarkerMatrix(i));
scale(1, -1); // turn things upside down, for text display
scale(scales); //decide the size of the boxes
translate(0, 0, 20); // translate the box by half (20, draw frm marker) of it's size (40,draw in air)
//move up 20 from the base marker
lights(); // turn on some lights,makes the box color nicer
stroke(0); // give the box a black stroke/line
fill(colors[i]); // fill color
box(40); // the box
noLights(); // turn off the lights
translate(0, 0, 20.1); // translate to just slightly above the box (to prevent OPENGL uglyness)
noStroke();
fill(255, 50);
rect(-20, -20, 40, 40); // display a transparent white rectangle right above the box
translate(0, 0, 0.1); // translate to just slightly above the rectangle (to prevent OPENGL uglyness)
fill(0);
text("" + i, -20, -20, 40, 40); // display the ID of the box in black text centered in the rectangle
}
if (i == 3) //MARKER NUMBER 3
{
// get the Matrix for this marker and use it (through setMatrix)
setMatrix(nya.getMarkerMatrix(i));
scale(scales); //decide the size of the boxes
translate(0, 0, 20); // translate the sphere by half (20, draw frm marker) of it's size (40,draw in air)
//move up 20 from the base marker
lights(); // turn on some lights,makes the box color nicer
stroke(colors[i]); //no line needed
fill(255,160); // fill color
sphere(20); // the box
//noStroke();
}
if (i == 5) //MARKER NUMBER 5
{
colorMode(RGB, 1); //set color mode to 1 only for easy fill color for the matrix
rot.add(speed); // always keep rotating
// get the Matrix for this marker and use it (through setMatrix)
setMatrix(nya.getMarkerMatrix(i));
translate(0, 0, 30); // translate the sphere by half (20, draw frm marker) of it's size (40,draw in air)
// rotate the cube in 3 dimensions
rotateX(rot.x);
rotateY(rot.y);
rotateZ(rot.z);
scale(scales*10);
// a cube made out of 6 quads
// the 1 range can be used for both the color and the coordinates as a result of color range and scale (see earlier)
beginShape(QUADS);
fill(0, 1, 1); vertex(-1, 1, 1);
fill(1, 1, 1); vertex( 1, 1, 1);
fill(1, 0, 1); vertex( 1, -1, 1);
fill(0, 0, 1); vertex(-1, -1, 1);
fill(1, 1, 1); vertex( 1, 1, 1);
fill(1, 1, 0); vertex( 1, 1, -1);
fill(1, 0, 0); vertex( 1, -1, -1);
fill(1, 0, 1); vertex( 1, -1, 1);
fill(1, 1, 0); vertex( 1, 1, -1);
fill(0, 1, 0); vertex(-1, 1, -1);
fill(0, 0, 0); vertex(-1, -1, -1);
fill(1, 0, 0); vertex( 1, -1, -1);
fill(0, 1, 0); vertex(-1, 1, -1);
fill(0, 1, 1); vertex(-1, 1, 1);
fill(0, 0, 1); vertex(-1, -1, 1);
fill(0, 0, 0); vertex(-1, -1, -1);
fill(0, 1, 0); vertex(-1, 1, -1);
fill(1, 1, 0); vertex( 1, 1, -1);
fill(1, 1, 1); vertex( 1, 1, 1);
fill(0, 1, 1); vertex(-1, 1, 1);
fill(0, 0, 0); vertex(-1, -1, -1);
fill(1, 0, 0); vertex( 1, -1, -1);
fill(1, 0, 1); vertex( 1, -1, 1);
fill(0, 0, 1); vertex(-1, -1, 1);
endShape();
colorMode(RGB, 255);
}
}
// reset to the default perspective
perspective();
}
// this function loads .patt filenames into a list of Strings based on a full path to a directory (relies on java.io)
String[] loadPatternFilenames(String path) {
File folder = new File(path);
FilenameFilter pattFilter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.toLowerCase().endsWith(".patt");
}
};
return folder.list(pattFilter);
}
void keyPressed() {
if (key == 'z' && scales < 2.0) {
// scales = 1.5;
scales = scales + 0.1;
}
else if(key == 'x' && scales > 0.7) {
scales = scales -0.1;
//scales = 0.8;
}
}</pre>
</div>
kithttp://www.blogger.com/profile/15380200496091540455noreply@blogger.com0tag:blogger.com,1999:blog-3128173435869617446.post-61111027139414248582013-12-26T02:27:00.000-08:002013-12-26T02:28:31.678-08:00Sorry about the video of the Bluetooth control robot, I'm too busy with my final year project recently :p Just dug out the video from some old files, enjoy:) <span style="color: red;">Youtube</span> <span style="color: red;">Link</span>: <a href="http://www.youtube.com/watch?v=9LkPpOZ8nhk&feature=youtube_gdata"><span style="color: blue;">Bluetooth Controlled robot video</span></a>kithttp://www.blogger.com/profile/15380200496091540455noreply@blogger.com0tag:blogger.com,1999:blog-3128173435869617446.post-43067148253915053292013-04-15T00:17:00.001-07:002013-04-15T00:17:19.280-07:00Use Android smartphone to control two wheels robot with Arduino via Bluetooth<span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: large;"><span style="line-height: 18px;"><b>3) Android programming part using Processing</b></span></span><div>
<span style="font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: medium;"><span style="line-height: 18px;"><b><br /></b></span></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 18px;">For the programming for my android smart phone, I've tried using few ways to establish the bluetooth connection between Arduino and my smart phone. I've tried to use few library to do the programming part, like sweetbt and btserial library</span><span style="line-height: 115%;">, but these two libraries don’t function well as
my smart phone could not successfully connect to the device via Bluetooth. The btserial library can be download at this<span style="color: #0b5394;"> <a href="https://github.com/arduino/BtSerial"><span style="color: #0b5394;"><b>website</b></span></a></span></span></span><span style="font-family: Arial, Helvetica, sans-serif; line-height: 115%;"> but the .jar file is seem to be missing and waiting for rebuild.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 115%;"><br /></span></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 115%;">So
I tried to change to eclipse, although I manage to download the application
into my smart phone(sony Xperia X10i), but the coding for eclipse is much more harder compared
to processing as I totally don’t have the basic for android programming it
will be very hard for me to use the eclipse. So I try to find another
alternative way to do the android programming. But lastly, I managed to find a
library named <b>Ketai</b>, for processing, which works perfectly to communicate with
the Arduino Bluetooth shield via Bluetooth, and the coding is much easier than
eclipse.</span><span style="line-height: 18px;"> </span></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 18px;"><br /></span></span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><span style="line-height: 18px;">You can download the Ketai library from this website and place it in your sketch "library" file : </span></span><a href="https://code.google.com/p/ketai/downloads/list"><b><span style="color: #0b5394;">https://code.google.com/p/ketai/downloads/list</span></b></a><br /><br /><span style="font-family: Arial, Helvetica, sans-serif;">Before download the codes into your android smartphone via processing, pls do enable the sketch permission of <b>BLUETOOTH</b> and <b>BLUETOOTH ADMIN</b> via the "Android" tab. If you forgot to tick this 2 things, the apps downloaded into your smart phone cannot be launched.</span></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSjk7A1tRg-hUHbHUpkkhIHedO0B9qvj90DJmsjHlpIbcTEfKWJXE_XzY_ZkwddPZlFGrQq0q7rR-K774UE6yMQ8KRFEtKC9YbvxJaLG5CwAj-DskhBu2ccPGEt5KG_xwJgpuPJKRIMdIT/s1600/1.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhSjk7A1tRg-hUHbHUpkkhIHedO0B9qvj90DJmsjHlpIbcTEfKWJXE_XzY_ZkwddPZlFGrQq0q7rR-K774UE6yMQ8KRFEtKC9YbvxJaLG5CwAj-DskhBu2ccPGEt5KG_xwJgpuPJKRIMdIT/s400/1.PNG" width="333" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif;">I've edited the code base on this <span style="color: #0b5394;"><a href="http://prof-takaya.blogspot.com/2013/02/connecting-android-and-arduino-by.html"><b><span style="color: #0b5394;">original codes</span></b></a>,</span> and it is very helpful for me:)</span><div class="MsoNormal">
<span style="line-height: 115%;"><span style="font-family: Arial, Helvetica, sans-serif;">Below will be the final coding of the android
processing code with implemented <b>Ketai</b> <b>library</b> function:</span></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">//required for BT enabling on startup<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">import android.content.Intent;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">import android.os.Bundle;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">import ketai.net.bluetooth.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">import ketai.ui.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">import ketai.net.*;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">PFont fontMy;
//declaring font <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">boolean bReleased = true; //no permament sending when finger is tap<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">KetaiBluetooth bt; //
Create object from BtSerial class<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">boolean isConfiguring = true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">String info = "";<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">KetaiList klist;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">ArrayList devicesDiscovered = new ArrayList();
//store in array the discovered device<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">boolean rectOver = false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">int rec = 0;<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">// The following code is required to enable
bluetooth at startup.<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">void onCreate(Bundle savedInstanceState) <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">super.onCreate(savedInstanceState);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">bt = new KetaiBluetooth(this);//create the BtSerial
object that will handle the connection<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">void onActivityResult(int requestCode, int
resultCode, Intent data)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">bt.onActivityResult(requestCode, resultCode, data);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}//to show the discovered device<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">void setup()<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">size(displayWidth, displayHeight); //size of my
phone screen<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">smooth();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">frameRate(10); //the
frame rate of my screen<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">orientation(PORTRAIT); //vertical<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">bt.start(); //start
listening for BT connections<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">isConfiguring = true; //at my phone start select device…<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">fontMy = createFont("SansSerif", 20);
//font size<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">textFont(fontMy);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">void draw()<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">//at app start select device<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">if (isConfiguring)<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">ArrayList names;<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">//create the BtSerial object that will handle the
connection<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">//with the list of paired devices<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">klist = new KetaiList(this,
bt.getPairedDeviceNames());<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">isConfiguring = false; //stop selecting device<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color a = color(255,0,0); //the
color for each button of the interface<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color b = color(255,0,0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color c = color(255,0,0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color d = color(255,0,0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color e = color(165,8,27);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color f = color(165,8,27);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color g = color(165,8,27);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color h = color(165,8,27);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color i = color(18,21,121);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color j = color(255,255,255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color k = color(255,255,255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">color l = color(0,0,0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">update(mouseX, mouseY); //update our finger point at where of the screen<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">background(45,12,137); //background color<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">if((mousePressed)&&(rectOver)&&(rec==1)) //when we click the button’s color
change <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
accordingly with different color code<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ c =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==2))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ d =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==3))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ a =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if ((mousePressed)&&(rectOver)&&(rec==4))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ b =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==5))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ j =
color(74,182,252);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==6))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ k =
color(74,182,252);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==7))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ e =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==8))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ f =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==9))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ g =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==10))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ h =
color(10,237,26);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">else if
((mousePressed)&&(rectOver)&&(rec==11))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{ l =
color(255,255,255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">if ((rec == 2) &&
(rectOver)&&(mousePressed) && (bReleased == true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">// If our finger is on the square, <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'w'}; // send w to arduino
when we click the button 2 <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data);
//send with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false; // send data for
once until next time we click the button again<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">if ((rec == 1) &&
(rectOver)&&(mousePressed) && (bReleased == true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'s'}; // send s to arduino
when we click the button 1<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data); //send
with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec ==
3) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'a'}; // send a to arduino
when we click the button 3<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data); //send
with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec ==
4) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'d'}; // send d to arduino
when we click the button 4<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data);
//send with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec ==
5) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'l'}; // send l to arduino
when we click the button 5(ellipse)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bt.broadcast(data);
//send with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec ==
6) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'k'}; // send k to arduino
when we click the button 6(ellipse)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data); //send
with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec
== 7) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'q'}; // send q to arduino
when we click the button 7<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data);
//send with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec
== 8) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'e'}; // send e to arduino
when we click the button 8<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data);
//send with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec
== 9) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'z'}; // send z to arduino
when we click the button 9<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data); //send
with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec
== 10) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'c'}; // send c to arduino
when we click the button 10<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data); //send
with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if ((rec
== 11) && (rectOver)&&(mousePressed) && (bReleased ==
true)) { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {'t'}; //
send t to arduino when we click the button 3<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data); //send
with bt<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">if((rectOver)&&(mousePressed ==
false)&& (bReleased == false))<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> { //when our finger move up
from the button, send stop command to arduino<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> byte[]
data = {' '}; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
bt.broadcast(data);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> bReleased
= true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(a); //fill
each area of button with the color declared above<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> stroke(162);
//the shape covered with a grey color line<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> triangle(200,250,250,150,300,250);
//draw the triangle with the
coordinates<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(b);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
triangle(200,600,250,700,300,600);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(c);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
triangle(150,375,50,425,150,475);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(d);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> triangle(350,375,450,425,350,475);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(e);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
triangle(425,240,325,290,400,340);
//325<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(f);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
triangle(400,510,325,560,425,610);
//325<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(g);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
triangle(75,240,175,290,100,340); //75<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(h);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">
triangle(100,510,175,560,75,610); //75<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> fill(i);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> stroke(172);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">rect(380,80,70,70); //draw
2 rectangle below the sphere(ellipse)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">rect(380,700,70,70);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">stroke(0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">fill(j);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">ellipse(415,115,85,85); //draw sphere with diameter 85<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">fill(k);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">ellipse(415,735,85,85);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">fill(l);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">stroke(255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">ellipse(25,25,30,30);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">//to print received data and show on screen<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">fill(255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">noStroke();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">textAlign(LEFT); <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">text(info, 20, 104);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">noFill();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">void update(int x, int y) { //to control the flag when we click a button<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if (
overRect(200, 150, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; //left right<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec = 3;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(50, 375, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; //up down<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec = 1;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(350, 375, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
2; //up down<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> ( overRect(200,
600, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; //left right<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
4;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(372,72,85,85) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
5; //for
ellipse 1<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(372,692,85,85) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
6; //for
ellipse 2<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(325, 240, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
7; //up left<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(325, 510, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
8; //up right<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(75, 240, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
9; //btm left<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> (
overRect(75, 510, 100, 100) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
10; //btm right<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else
if<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> ( overRect(10,
10, 30, 30) ) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
true; <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rec =
11; //stop<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> else<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> rectOver =
false; //nothing s
touched on screen<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">boolean overRect(int x, int y, int width, int
height) { // to scan we touch which area<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> if (mouseX
>= x && mouseX <= x+width && <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> mouseY
>= y && mouseY <= y+height)
//to see if the mouse cursor inside rect<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> return
true;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> } else {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> return
false;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"> }<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">void onKetaiListSelection(KetaiList klist)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">String selection = klist.getSelection(); //select the device to connect<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">bt.connectToDeviceByName(selection); //connect to the device<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">klist = null; //dispose
of bluetooth list for now<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">//Call back method to manage data received<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">void onBluetoothDataEvent(String who, byte[] data)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">if (isConfiguring)<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">return;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">//received<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">info += new String(data);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">if(info.length() > 150) //clean the words on screen if string to long<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">info = "";<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">}//END of Android processing coding<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Video will be uploaded soon :)</span></div>
</div>
kithttp://www.blogger.com/profile/15380200496091540455noreply@blogger.com0tag:blogger.com,1999:blog-3128173435869617446.post-40643697475065548622013-04-05T11:11:00.003-07:002013-04-05T11:11:19.162-07:00Use Android smartphone to control two wheels robot with Arduino via Bluetooth<b><span style="font-size: large;">2) Arduino Programming Part</span></b><br />
<br />
For the Arduino programming part, I'm using is Arduino Leonardo. The difference of programming coding of Leonardo with Uno is the "serial" command. If i'm not mistaken, for Leonardo to communicate via Bluetooth the command will be "Serial1.xx" as below. Meanwhile for Uno will be just "Serial.xx".<br />
<br />Before going into Arduino programming part, you have to configure your own Bluetooth module. For example: set the baudrate, name of the Bluetooth device, and password to let your Android device connect to your Bluetooth shield. I'm doing all this setting by using a software called<b> <a href="https://www.google.com.my/search?q=hyperterminal+download&aq=2&oq=hyperterminal&aqs=chrome.2.57j0l3.4937j0&sourceid=chrome&ie=UTF-8"><span style="color: #3d85c6;">hyperterminal</span></a></b>. You can try to configure your bluetooth module first because everyone are using different shield & module so I'm not gonna emphasize on it here, you can always try to google it :) (<a href="https://www.google.com.my/search?q=bluetooth+module+configuration&aq=f&oq=bluetooth+module+configuration&aqs=chrome.0.57j0l2.6677j0&sourceid=chrome&ie=UTF-8#hl=en&sclient=psy-ab&q=bluetooth+module+configuration+using+hyperterminal&oq=bluetooth+module+configuration+using+hyperterminal&gs_l=serp.3...1185.4360.0.4882.20.20.0.0.0.0.154.2022.12j8.20.0...0.0...1c.1.8.psy-ab.QMRSSfNt4j0&pbx=1&bav=on.2,or.r_qf.&bvm=bv.44770516,d.bmk&fp=c2264356cc05774&biw=1366&bih=624"><b><span style="color: #3d85c6;">Bluetooth module configuration</span></b></a>). Also, make sure your computer had installed the correct driver for your own Bluetooth Dongle.<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil8hxi6A-26cr9VJ4D3hIRqmpKBk__dGTXQSw__4aIZYOasVHT_wOQx0_VsB3N6u1EdjnsZ1F1dyc-C88h28lly26bwlpuu4bk9uyXu2-CyZDk9f_zguO9qGKZmfCdax905Ydrph3dlIPM/s1600/DSC_1385.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil8hxi6A-26cr9VJ4D3hIRqmpKBk__dGTXQSw__4aIZYOasVHT_wOQx0_VsB3N6u1EdjnsZ1F1dyc-C88h28lly26bwlpuu4bk9uyXu2-CyZDk9f_zguO9qGKZmfCdax905Ydrph3dlIPM/s320/DSC_1385.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bluetooth Shield, Module and Dongle that I'm using</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<b>Below are the coding for my Arduino Leonardo: </b><br />
<br />
<br />
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">#include <Servo.h> //include servo
function<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">#define BUFFERSIZE 127<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">uint8_t inBuffer[BUFFERSIZE];<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int inLength; // length of data in the
buffer<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int numLoop = 0; // number of times we
looped<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">char val;<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">Servo myservo; //for servo function<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int motor_LF=2; //declaring pin used for
the motor<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int motor_LR=3;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int motor_RF=4;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int motor_RR=5;<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int motor_LPWM = 13; //declaring pwm pin<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">int motor_RPWM = 11;<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">void setup() { <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
Serial1.begin(38400); //baud rate I set for bluetooth module is 38400<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
myservo.attach(9); //my servo at pin 9 as actuator<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
pinMode(motor_LF, OUTPUT); //set pin as output<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
pinMode(motor_LR, OUTPUT);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
pinMode(motor_RF, OUTPUT);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
pinMode(motor_RR, OUTPUT);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
pinMode(motor_LPWM, OUTPUT);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
pinMode(motor_RPWM, OUTPUT);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
motor_reset(); // call function to reset the motor<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">} <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">void loop() {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
// read string if available<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (Serial1.available()) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
inLength = 0;<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
while (Serial1.available()) {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
val = Serial1.read();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
Serial1.print("Arduino received: "); //send the text to the android device<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
Serial1.write(val);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
Serial1.println();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'k') //K <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{ myservo.write(90); } //write the angle of servo should move<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'l') //L <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{ myservo.write(30); }<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'm') ///M <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{ myservo.write(178); }<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'w') //W – Forward motion of motor<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 255); //sending pwm pulses<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 255); //255 will be highest<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 's') //S – Reverse motion<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, HIGH );<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 12pt;">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="text-indent: 12pt;">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'q') //Q - Left Forward<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 128); //slower thn Right PWM but same direction
to turn left<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'e') //E - Right Forward<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 128);
//slower thn left PWM but same direction to turn right<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'z') //Z - Left backward<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 128);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'c') //C - Right backward<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 128);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'a') //A - Spin Left<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 255); //move in same speed but different
direction to spin<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 'd') //D - Spin Right<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, HIGH);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == ' ') //Space – Brake function<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, LOW); //make all the pin LOW to stop the motor<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 255); //both 255 to make the motor stop
immediately<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 255);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
if (val == 't') //T – Reset the motor<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
motor_reset();<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"> <o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">void motor_reset() //reset function<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">{<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_LR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RF, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
digitalWrite(motor_RR, LOW);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_LPWM, 0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">
analogWrite(motor_RPWM, 0);<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;">}//END of arduino code<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt;"><br /></span></div>
<div class="MsoNormal" style="text-align: right;">
<span style="font-family: Times New Roman, serif;">Parts of the coding credits to</span></div>
<div class="MsoNormal" style="text-align: right;">
<span style="font-family: Times New Roman, serif;">Nadrew Chong Jia Ying</span></div>
kithttp://www.blogger.com/profile/15380200496091540455noreply@blogger.com0tag:blogger.com,1999:blog-3128173435869617446.post-36436743594212698012013-04-05T02:28:00.000-07:002013-10-29T09:35:16.860-07:00Use Android smartphone to control two wheels robot with Arduino via Bluetooth <b><span style="font-size: large;">1) Mechanical parts: Make your own two wheels robot!</span></b><br />
<br />
If you still don't have a two wheels robot, you can try to make one with the components below:<br />
<br />
(This components are used in my own robots, you can change it as you like.)<br />
<br />
<div class="MsoListParagraphCxSpFirst" style="text-indent: -18pt;">
</div>
<ul>
<li><span style="font-family: inherit;"><span style="text-indent: -18pt;"><span style="line-height: 18px;"> </span></span><span style="font-size: 7pt; text-indent: -18pt;"> </span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">2
pieces of perspek</span></span></li>
<li><span style="font-family: inherit;"><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;"> <span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">4 PCB stand</span></span></li>
<li><span style="font-family: inherit;"><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;"><span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">Servo
motor</span></span></li>
<li><span style="font-family: inherit;"><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;"><span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">2
gear motors</span></span></li>
<li style="text-indent: -24px;"><span style="line-height: 18px;"><span style="font-family: inherit;"> </span></span><span style="font-size: 16px; line-height: 18px;"> 1 H-Bridge for two motor for two way controlling</span></li>
<li><span style="font-family: inherit;"><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;"><span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">2 wheels</span></span></li>
<li><span style="font-family: inherit;"><span style="text-indent: -18pt;"><span style="line-height: 18px;"> </span><span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">Small
size breadboard</span></span></li>
<li><span style="font-family: inherit;"><span style="text-indent: -18pt;"><span style="line-height: 18px;"> </span><span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">Bluetooth
Receiver Module</span></span></li>
<li><span style="font-family: inherit;"><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;"><span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">Arduino Leonardo</span></span></li>
<li><span style="font-family: inherit; font-size: 12pt; line-height: 115%; text-indent: -18pt;"> 1
piece of 9V battery</span></li>
<li><span style="font-family: inherit; font-size: 12pt; line-height: 115%; text-indent: -18pt;"> Battery
holder</span></li>
<li><span style="font-family: inherit;"><span style="text-indent: -18pt;"><span style="line-height: 18px;"> </span><span style="font-size: 7pt; line-height: normal;"> </span></span><span style="font-size: 12pt; line-height: 115%; text-indent: -18pt;">Rechargeable
batteries (2500mAh)</span></span></li>
</ul>
<div>
<span style="font-family: Times New Roman, serif;"><span style="line-height: 18px;"><br /></span></span></div>
<br />
<br />
<b>Below are the process of making of my own two wheels robot:</b><br />
<br />
<div class="MsoNormal">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Stage
1<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><v:shapetype coordsize="21600,21600" filled="f" id="_x0000_t75" o:preferrelative="t" o:spt="75" path="m@4@5l@4@11@9@11@9@5xe" stroked="f">
<v:stroke joinstyle="miter">
<v:formulas>
<v:f eqn="if lineDrawn pixelLineWidth 0">
<v:f eqn="sum @0 1 0">
<v:f eqn="sum 0 0 @1">
<v:f eqn="prod @2 1 2">
<v:f eqn="prod @3 21600 pixelWidth">
<v:f eqn="prod @3 21600 pixelHeight">
<v:f eqn="sum @0 0 1">
<v:f eqn="prod @6 1 2">
<v:f eqn="prod @7 21600 pixelWidth">
<v:f eqn="sum @8 21600 0">
<v:f eqn="prod @7 21600 pixelHeight">
<v:f eqn="sum @10 21600 0">
</v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:f></v:formulas>
<v:path gradientshapeok="t" o:connecttype="rect" o:extrusionok="f">
<o:lock aspectratio="t" v:ext="edit">
</o:lock></v:path></v:stroke></v:shapetype><v:shape id="Picture_x0020_5" o:spid="_x0000_i1029" style="height: 353.25pt; mso-wrap-style: square; visibility: visible; width: 353.25pt;" type="#_x0000_t75">
<v:imagedata o:title="IMG_2361" src="file:///C:\Users\kit\AppData\Local\Temp\msohtmlclip1\01\clip_image001.jpg">
</v:imagedata></v:shape></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhROEyuy1ckaYysujvV3bsFcI9t2oSgCYsPpe1E_bGPN7aowh9n4LBggyGxVhlNxLH50lLT-dpzZDWzSV2mdOgHON2CB1YWzMotpCwMuupuAe3ZYTHZJHdM1N6mM5oLr5SeWzoLPM70Zk2_/s1600/DSC_1323.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhROEyuy1ckaYysujvV3bsFcI9t2oSgCYsPpe1E_bGPN7aowh9n4LBggyGxVhlNxLH50lLT-dpzZDWzSV2mdOgHON2CB1YWzMotpCwMuupuAe3ZYTHZJHdM1N6mM5oLr5SeWzoLPM70Zk2_/s320/DSC_1323.jpg" width="320" /></a></div>
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">The first prototype of our robot is constructed in a
way that the body of the robot is made out of red plastic cardboard due to the
benefits of its material that is light enabling the robot to go at a higher
pace. Then two 3.3V DC tamiya motor are being used to be built as a part of the
wheels of our robot. These wheels are
being used as they could produce speed up to 18000rpm. But after testing we
found out that Tamiya motor has very low torque. When there are some loads on
the motor it will not move at all. At this stage we are still thinking of the
Pulse wave modulation (PWM) problem. Another testing will be done on Tamiya
motor later. As all the component
(servo motor, 2 tamiya motor, arduino, battery and etc) are being constructed
onto our robot, the plastic cardboard that was used as the body of the robot
could not withstand the amount of weight and it was squashed.<o:p></o:p></span></div>
<div class="MsoNormal">
<br />
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Stage
2<o:p></o:p></span></b></div>
<div class="MsoNormal">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><v:shape id="Picture_x0020_7" o:spid="_x0000_i1028" style="height: 333.75pt; mso-wrap-style: square; visibility: visible; width: 333.75pt;" type="#_x0000_t75">
<v:imagedata o:title="IMG_2372" src="file:///C:\Users\kit\AppData\Local\Temp\msohtmlclip1\01\clip_image002.jpg">
</v:imagedata></v:shape></span></b><b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><o:p></o:p></span></b></div>
<div class="MsoNormal">
<div class="separator" style="clear: both; text-align: center;">
</div>
</div>
<div class="MsoNormal">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO-1sowjlFhVYQ2g4sHK45O96qFHBD2jeG7JCdPdSIPC1KnZG1k2HfGYWw17fabJHU00d9Q7a7TRC-1LPwqEXyKflAsI-lHBua29dNMwUqpAauy_z6SnmNJaUX1tJO0Mr7Ug8Oq9-9UlBy/s1600/Untitled.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="362" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjO-1sowjlFhVYQ2g4sHK45O96qFHBD2jeG7JCdPdSIPC1KnZG1k2HfGYWw17fabJHU00d9Q7a7TRC-1LPwqEXyKflAsI-lHBua29dNMwUqpAauy_z6SnmNJaUX1tJO0Mr7Ug8Oq9-9UlBy/s400/Untitled.jpg" width="400" /></a></div>
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">This is the second prototype of our robot where the
body is being built using perspek. As the red plastic board couldn’t
withstand the weight of the components placed, another material was being used
as the body of the robot. Due to the replacement of a new material as the body
of the robot to sustain more weight, the material seem to withstand the amount
of mass withstand on it but unfortunately it causes the robot to move at a
slower pace due to the mass of perspek is slightly higher than to a plastic
cardboard. Later on we found out that when we send the PWM pulse into the 3.3V tamiya
motor via transistor from Arduino, it really has a very low torque even with
high voltage power supply and full PWM pulses(255).The motor can’t move with
any load so it wasn’t suitable to be used in our mini project anymore.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Stage
3<o:p></o:p></span></b><br />
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span></b></div>
<div class="MsoNormal">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzZNsAnBh6TgN8up5b-eciz_Ulj67v-rLCdp_HXFYIosKN8KVLsUK6bmIp1BwohtKDoBG8Bi4F9xxIlU3hxNJpu4Tqzhg6LRyS2jDY2sNWKWd6OmdeZWfnqklPbMwakTAeStqGSHYxsaeP/s1600/DSC_1324.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzZNsAnBh6TgN8up5b-eciz_Ulj67v-rLCdp_HXFYIosKN8KVLsUK6bmIp1BwohtKDoBG8Bi4F9xxIlU3hxNJpu4Tqzhg6LRyS2jDY2sNWKWd6OmdeZWfnqklPbMwakTAeStqGSHYxsaeP/s320/DSC_1324.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">12V DC motors</td></tr>
</tbody></table>
<br /></div>
<div class="MsoNormal">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJGbY_GXA9w11dvk8hXsJqlagcxAq8RxvcVXFEKrtnaVACx0095rUXMgBUTvVQT0yD0U7k_cbkhEK8Y45QEqClNBXt-9e28b0tRbApcw85qGd_-gEKVSsPukCv7prTTrifTxOPfHLjFvDa/s1600/test3+with+9-12V+DC+motor,+torque+higher+thn+tamiya,+but+still+move+slow,+need+supply+sufficient+voltage+but+will+increase+the+total+weight..jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="320" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjJGbY_GXA9w11dvk8hXsJqlagcxAq8RxvcVXFEKrtnaVACx0095rUXMgBUTvVQT0yD0U7k_cbkhEK8Y45QEqClNBXt-9e28b0tRbApcw85qGd_-gEKVSsPukCv7prTTrifTxOPfHLjFvDa/s320/test3+with+9-12V+DC+motor,+torque+higher+thn+tamiya,+but+still+move+slow,+need+supply+sufficient+voltage+but+will+increase+the+total+weight..jpg" width="240" /></a></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Since 3.3V tamiya DC motors aren’t
suitable to be used in the construction of our robot, it was replaced by a 12V
DC motor instead. This replacement produces higher torque but still the speed
is low hence sufficient voltage needed to be supplied in order for the
robot to move faster. But this affects the total weight of the robot as the
weight increases with the increase in voltage due to more amounts of batteries
were being used. Besides that, our robot design was enhanced by making a few
extra changes to it such as metal strips are being used to hold both the motor
in place, In prevention of short circuit, this metal strips were insulated by
covering it with heat tube.<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br />
<br /></div>
<div class="MsoNormal">
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Stage
4<o:p></o:p></span></b><br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTQl0_RcQkSF-5V7lWewMiYv-2qtIwDM4cqVHMBDs0Ey6vKKOikB7kLJMubdNcgtJO40IrJLMc_u437ULVHlSWARDeScDaFq0vyhOJfBudndC0ZF60yp4sj1ngWiOQdwyRT_EWqh1NrCMH/s1600/DSC_1317.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgTQl0_RcQkSF-5V7lWewMiYv-2qtIwDM4cqVHMBDs0Ey6vKKOikB7kLJMubdNcgtJO40IrJLMc_u437ULVHlSWARDeScDaFq0vyhOJfBudndC0ZF60yp4sj1ngWiOQdwyRT_EWqh1NrCMH/s320/DSC_1317.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Gear motor</td></tr>
</tbody></table>
<b><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span></b></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><v:shape id="Picture_x0020_9" o:spid="_x0000_i1026" style="height: 419.25pt; mso-wrap-style: square; visibility: visible; width: 419.25pt;" type="#_x0000_t75">
<v:imagedata o:title="IMG_2374" src="file:///C:\Users\kit\AppData\Local\Temp\msohtmlclip1\01\clip_image004.jpg">
</v:imagedata></v:shape></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">As we found out that 12V DC motor are also aren’t suitable
to be used in the construction of our robot, it was replaced by a pair of 6V gear
motors. Gear motor can produce higher torque hence enabling the robot to
actually move faster to be compared to previous prototype. This gear motor we
bought comes with stall torque 0.3kg/cm and 440 free run rpm.Also, the weight
of each gear motor only 10 gram as this will make the total weight of the robot
a lot lighter so that it can run faster. The detail of the gear motor can be viewed on the link below: </span><a href="http://www.cytron.com.my/viewProduct.php?pcode=SPG10-30K&name=30:1%20Micro%20Metal%20Gearmotor">http://www.cytron.com.my/viewProduct.php?pcode=SPG10-30K&name=30:1%20Micro%20Metal%20Gearmotor</a><br />
<br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3KKiEzGV4hq20H9F8o-dXnEW9Os5Xf__HEpI6H5TRAPSvw7E7tiGQNuqBIITDijl6NGqn-9AW8LBZnNYJfUlWReXIGizpt1kR2C1M7ZOrDF6XEyCtlT_jWnzYtFsjE2v2pQ8OydFGEKgv/s1600/DSC_1330.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh3KKiEzGV4hq20H9F8o-dXnEW9Os5Xf__HEpI6H5TRAPSvw7E7tiGQNuqBIITDijl6NGqn-9AW8LBZnNYJfUlWReXIGizpt1kR2C1M7ZOrDF6XEyCtlT_jWnzYtFsjE2v2pQ8OydFGEKgv/s320/DSC_1330.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Upper view of the robot</td></tr>
</tbody></table>
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><br /></span>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8OrqDsueP7IKmlzVLt8tsyEncca8kOKa9bnZpCL04bFe9TB4Q7G4osNxaAg3HP98ujVpPLT4Tm7NtRc09pz-QUKBekm9usIOYR6NPhXhvX0if2LHXYe3UUeH8raz42WeaS4jMrc9nQpcG/s1600/DSC_1364.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg8OrqDsueP7IKmlzVLt8tsyEncca8kOKa9bnZpCL04bFe9TB4Q7G4osNxaAg3HP98ujVpPLT4Tm7NtRc09pz-QUKBekm9usIOYR6NPhXhvX0if2LHXYe3UUeH8raz42WeaS4jMrc9nQpcG/s320/DSC_1364.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Back view of the robot</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo0nTObQe40oLJvIdkNMngEnGhrM9gmCyc4V33_ny5TZ2EevWHto6u1QlnlOkXkMAFIN4_Bj3u6xG5lzBv_xNAPw8jt9aIq2VH-7vo_yzLCmIAuAlygu2kOPQzhztmWbuWu28p_4hPeu4V/s1600/DSC_1368.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgo0nTObQe40oLJvIdkNMngEnGhrM9gmCyc4V33_ny5TZ2EevWHto6u1QlnlOkXkMAFIN4_Bj3u6xG5lzBv_xNAPw8jt9aIq2VH-7vo_yzLCmIAuAlygu2kOPQzhztmWbuWu28p_4hPeu4V/s320/DSC_1368.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Side view of the robot</td></tr>
</tbody></table>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-LsT6BPqU73DIjIyKZO_MHFdkqBnWvCfLYZXPQkrYY8_o8cr-9tjA0VWd0pjC0pIY_dj4N0oP39N8Lf7wBr4ULFZdnquiVdmFaJBVFmS0pO2ih2WTi_My40Nk7cVSRZEgIF0UdDq1CPM4/s1600/DSC_1366.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-LsT6BPqU73DIjIyKZO_MHFdkqBnWvCfLYZXPQkrYY8_o8cr-9tjA0VWd0pjC0pIY_dj4N0oP39N8Lf7wBr4ULFZdnquiVdmFaJBVFmS0pO2ih2WTi_My40Nk7cVSRZEgIF0UdDq1CPM4/s320/DSC_1366.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bottom view of the robot(with a caster at lower middle part)</td></tr>
</tbody></table>
<br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;">Moreover, we found out that short
circuit may be occurred due to limited space to place these components on top
of the robot, so we enhance the design of the robot by using a PCB stand to
hold another layer of perspek. With this, we have enough space to place these
components neatly in prevention of short circuit. Moreover, we changed the
actuator design of the robot into a smaller piece of metal as it’s smaller and
suitable to be used for the soccer game competition. To enable the robot to
move faster, we used high amp rechargeable battery (2500mAh). With this, the
gear motor can perform well as expected when all the component are placed on
the robot.<o:p></o:p></span><br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"></span><br />
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"></span></div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfrwVwDTqS11dH3U4-WjhGwYHSNJXkjo6HgEO7UE0BtQYnQRPk66MyZmNgVebkOLeVputzSrDdTrFlFHyb-6jv8RIjisrGGOxW9rRnIh7PRJkSKg2bfTyrxLFKQ9tkdEkHHpLCZFjhRTjD/s1600/DSC_1375.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjfrwVwDTqS11dH3U4-WjhGwYHSNJXkjo6HgEO7UE0BtQYnQRPk66MyZmNgVebkOLeVputzSrDdTrFlFHyb-6jv8RIjisrGGOxW9rRnIh7PRJkSKg2bfTyrxLFKQ9tkdEkHHpLCZFjhRTjD/s320/DSC_1375.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Upper part components(Battery casing, servo motor)</td></tr>
</tbody></table>
<div class="separator" style="clear: both; text-align: center;">
</div>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs1RpUaxL1xoOgoytTb-UHBrjn5M8eKTschMU5O7wN6i8E2L3ArSdVoKXw0vKaI-c5rwVu6WNK5INhsA-8r0SDPVQUVmX8vdzg9xBRH1mXZZuI43ipDd_K_x27LNmGob17US_21BKNbkcR/s1600/DSC_1374.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhs1RpUaxL1xoOgoytTb-UHBrjn5M8eKTschMU5O7wN6i8E2L3ArSdVoKXw0vKaI-c5rwVu6WNK5INhsA-8r0SDPVQUVmX8vdzg9xBRH1mXZZuI43ipDd_K_x27LNmGob17US_21BKNbkcR/s320/DSC_1374.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Lower part components(Small breadboard with wirings, gear motors, Arduino Leonardo)</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj_7v46LlaWNc8_Eknb69GHYG9PMQtRAILnTDSWGjNgSAGQYlfFPLN7vz2LTbrE7ZGRqDOwKnjT_O6TdTfsLBX1851nByVoJ8YwgItvZMlPRWJ5iSaIH0spHBcsVZhZgEYjhx-F9zoLLvE/s1600/DSC_1371.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgj_7v46LlaWNc8_Eknb69GHYG9PMQtRAILnTDSWGjNgSAGQYlfFPLN7vz2LTbrE7ZGRqDOwKnjT_O6TdTfsLBX1851nByVoJ8YwgItvZMlPRWJ5iSaIH0spHBcsVZhZgEYjhx-F9zoLLvE/s320/DSC_1371.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">There was a square hole made on the middle of the upper part perspex for easy wiring.</td></tr>
</tbody></table>
<br />
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="MsoNormal">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg34E-z9R9_bXdIK6gF6iKcRROP5Awqp1a6Grd3x9d5fUoabyTfDVZ1THdRxnaT2et_tzSjqXhclQ8QJ_7BOvQaxgDjAS2b178jJRoUCB8Ff_iA_h7FXc3SeAe63m7NOnmQcVvQnTlZywAN/s1600/DSC_1388.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg34E-z9R9_bXdIK6gF6iKcRROP5Awqp1a6Grd3x9d5fUoabyTfDVZ1THdRxnaT2et_tzSjqXhclQ8QJ_7BOvQaxgDjAS2b178jJRoUCB8Ff_iA_h7FXc3SeAe63m7NOnmQcVvQnTlZywAN/s320/DSC_1388.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">XBee Shield V1.4 & BlueBee Bluetooth module</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil8hxi6A-26cr9VJ4D3hIRqmpKBk__dGTXQSw__4aIZYOasVHT_wOQx0_VsB3N6u1EdjnsZ1F1dyc-C88h28lly26bwlpuu4bk9uyXu2-CyZDk9f_zguO9qGKZmfCdax905Ydrph3dlIPM/s1600/DSC_1385.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil8hxi6A-26cr9VJ4D3hIRqmpKBk__dGTXQSw__4aIZYOasVHT_wOQx0_VsB3N6u1EdjnsZ1F1dyc-C88h28lly26bwlpuu4bk9uyXu2-CyZDk9f_zguO9qGKZmfCdax905Ydrph3dlIPM/s320/DSC_1385.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bluetooth shield with module & Bluetooth dongle</td></tr>
</tbody></table>
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7dHRDatPYJppZc_L_C3-mAcnD7nI-Z0mAuG-apwv8z-J-F9cFoZIGWtRUDBQHkrFfN08oeO_lTXWqAs6XH8Ga9Po5btcIh_0VGnY_qBcZVmTt9OdsuWiCEPhkqLGPbh-sTOzvlSQ3LzeR/s1600/DSC_1382.jpg" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh7dHRDatPYJppZc_L_C3-mAcnD7nI-Z0mAuG-apwv8z-J-F9cFoZIGWtRUDBQHkrFfN08oeO_lTXWqAs6XH8Ga9Po5btcIh_0VGnY_qBcZVmTt9OdsuWiCEPhkqLGPbh-sTOzvlSQ3LzeR/s320/DSC_1382.jpg" width="320" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Bluetooth shield with module & Arduino Leonardo</td></tr>
</tbody></table>
<br />
<br />
<b>Below are the schematic diagram for the two wheels<span style="font-family: 'Times New Roman', serif; font-size: 12pt; line-height: 115%;"> robot:</span></b></div>
<div class="MsoNormal">
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><o:p></o:p></span></div>
<br />
<br /></div>
<div class="MsoNormal">
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRqWd5Z_x15wBmjzUctoLsNoB00EwAtFXaBP-AWVMaj6KJgcvZBwYLP7Su0LTuRHGKmczn8Pqm93DKizXYh8FR54trHcqoPrv_h7938nqUyRgCsNXLJYG-UGdCOkqvfjUzb6hvQ3x7tymk/s1600/Soccer+Robot+Schematics.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="314" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgRqWd5Z_x15wBmjzUctoLsNoB00EwAtFXaBP-AWVMaj6KJgcvZBwYLP7Su0LTuRHGKmczn8Pqm93DKizXYh8FR54trHcqoPrv_h7938nqUyRgCsNXLJYG-UGdCOkqvfjUzb6hvQ3x7tymk/s640/Soccer+Robot+Schematics.png" width="640" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;"><br />
<div style="text-align: right;">
Prototype making, Photo and Schematic diagram credits to<br />
Jayson Khoo Thiam Wee & Lee Kien Thiam</div>
</td></tr>
</tbody></table>
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%; mso-no-proof: yes;"><v:shape id="Picture_x0020_1" o:spid="_x0000_i1025" style="height: 362.25pt; mso-wrap-style: square; visibility: visible; width: 362.25pt;" type="#_x0000_t75">
<v:imagedata o:title="525093_10151317574966485_1888935542_n" src="file:///C:\Users\kit\AppData\Local\Temp\msohtmlclip1\01\clip_image005.jpg">
</v:imagedata></v:shape></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; line-height: 115%;"><o:p></o:p></span></div>
kithttp://www.blogger.com/profile/15380200496091540455noreply@blogger.com0