-
Notifications
You must be signed in to change notification settings - Fork 0
/
Car Model.html
1119 lines (788 loc) · 47.3 KB
/
Car Model.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<meta name="description" content="Affordable and professional web design">
<meta name="keywords" content="web design, affordable web design, professional web design">
<meta name="author" content="Brad Traversy">
<title>RCar | Car Model</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Raleway">
<style>
body,pre{
font-family: "Raleway", sans-serif;
}
.container2 {
width:80%;
margin:auto;
padding: 0;
overflow:hidden;
text-align: center;
}
footer{
padding:1px;
margin-top:0;
color:#ffffff;
background-color: #000000;
text-align: center;
}
footer p{
float: left;
width: 50%;
margin-left: 25%;
}
.grid-container2 {
display: grid;
grid-template-columns: 300px 300px;
grid-gap: 15px;
background-color: white;
height: 250px;
margin-left: 200px;
}
.grid-container22 {
display: grid;
grid-template-columns: auto auto;
grid-gap: 20px;
background-color: white;
height: 650px;
}
.grid-container3 {
display: grid;
grid-template-columns: auto auto auto;
grid-gap: 15px;
background-color: white;
height: 192px;
}
.grid-container33 {
display: grid;
grid-template-columns: 200px 200px 200px;
grid-gap: 15px;
background-color: white;
height: 500px;
}
.a {
grid-column-start: 1;
grid-column-end: 3;
grid-row-start: 3;
grid-row-end: 3;
}
.a2 {
grid-column-start: 1;
grid-column-end: 3;
grid-row-start: 2;
grid-row-end: 2;
}
.grid-container3 > div, .grid-container2 > div, .grid-container22 > div, .grid-container33 > div {
height: auto;
width: auto;
background-size: cover;
background-repeat: no-repeat;
}
.hiddenn{
display: none;
position: absolute;
color: black;
text-align: center;
font-size: 25px;
background-color: transparent;
}
.image:hover > .hiddenn{
display: block;
width: 30%;
}
.image2:hover > .hiddenn{
display: block;
width: 50%;
}
.image3:hover > .hiddenn{
display: block;
width: 20%;
}
article > p, ol{
line-height: 35px; text-align: justify;
}
figure{
line-height: 30px;
text-align: justify;
font-size: 15px;
}
figcaption{
margin-top: 10px;
text-align: center;
}
a {
text-decoration: none;
color: red;
}
</style>
</head>
<body onscroll="myFunction()" onload="resize()" onresize="resize()" style="min-width: 1690px; margin: auto; position: relative">
<header>
<div style="height: 90px; margin-top:0; background-color: black; text-align: center;color: red;font-size: 80px"> <a href="index.html">RCar</a> <span style="color: white">|</span> <span style="font-size: 35px;color: white;"> Car </span> </div>
</header>
<div style="width: 1000px; margin:auto;">
<article class = "pageHeight" style="position:relative; height: 9900px;">
<div id = "indexxx" style="background-color: black;color: white;position: fixed;left:5%; top: 175px;width: 100px;text-align: center;font-size: 20px;display: none;">Index</div>
<ul id = "indexx" style="position:fixed; left:0.125%; top: 195px; list-style-type: none;line-height: 40px; display: none;">
<li style="color: black;padding: 0 10px; border-left: solid black;">Introduction
<ul style="cursor: pointer; color: black;padding: 0 10px;margin-top: 10px;list-style-type: none;">
<li id = "first" onclick="topFunction(150)" style="cursor: pointer; color: black;padding: 0 10px;"> Remote-Controlled Cars </li>
<li id = "second" onclick="topFunction(880)" style="cursor: pointer; color: black;padding: 0 10px;"> Arduino </li>
</ul>
</li>
<li style="color: black;border-left: solid black;padding: 0 10px;margin-top: 10px;">Prototype
<ul style="cursor: pointer; color: black;padding: 0 10px;margin-top: 10px;list-style-type: none;">
<li id = "third" onclick="topFunction(1930)" style="cursor: pointer; color: black;padding: 0 10px;"> Electronics </li>
<li id = "fourth" onclick="topFunction2(3520+690+130)" style="cursor: pointer; color: black;padding: 0 10px;"> Design </li>
<li id = "fifth" onclick="topFunction2(9100)" style="cursor: pointer; color: black;padding: 0 10px;"> Download Files </li>
<li id = "sixth" onclick="topFunction2(9100)" style="cursor: pointer; color: black;padding: 0 10px;"> Future Improvements </li>
</ul>
</li>
</ul>
<script>
function resize() {
let index = document.getElementById("indexx");
let indexx = document.getElementById("indexxx");
if (index.style.display === "block" && window.innerWidth < 1540) {
index.style.display = "none";
indexx.style.display = "none";
}
if (index.style.display === "none" && window.innerWidth > 1540) {
index.style.display = "block";
indexx.style.display = "block";
}
}
function topFunction(distance) {
document.body.scrollTop = distance;
document.documentElement.scrollTop = distance;
}
function topFunction2(distance) {
if(document.getElementsByClassName("dropdown")[0].nextElementSibling.style.display==="block"){
document.documentElement.scrollTop = distance+4720;
}else{
document.documentElement.scrollTop = distance;
}
}
function myFunction() {
if (document.getElementsByClassName("dropdown")[0].nextElementSibling.style.display === "block") {
if (document.documentElement.scrollTop < 150) {
document.getElementById("first").style.color = "black";
document.getElementById("second").style.color = "black";
document.getElementById("third").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 880) && (document.documentElement.scrollTop >= 150)) {
document.getElementById("first").style.color = "red";
document.getElementById("second").style.color = "black";
document.getElementById("third").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 1930) && (document.documentElement.scrollTop >= 880)) {
document.getElementById("second").style.color = "red";
document.getElementById("first").style.color = "black";
document.getElementById("third").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 3520+820+4720) && (document.documentElement.scrollTop >= 1930)) {
document.getElementById("third").style.color = "red";
document.getElementById("second").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("first").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 6891+820+1385+4720) && (document.documentElement.scrollTop >= 3520+820+4720)) {
document.getElementById("fourth").style.color = "red";
document.getElementById("third").style.color = "black";
document.getElementById("second").style.color = "black";
document.getElementById("first").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 6891+820+1385+50+4720) && (document.documentElement.scrollTop >= 6891+820+1385+4720)) {
document.getElementById("fifth").style.color = "red";
document.getElementById("third").style.color = "black";
document.getElementById("second").style.color = "black";
document.getElementById("first").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "red";
}
} else {
if (document.documentElement.scrollTop < 150) {
document.getElementById("first").style.color = "black";
document.getElementById("second").style.color = "black";
document.getElementById("third").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 880) && (document.documentElement.scrollTop >= 150)) {
document.getElementById("first").style.color = "red";
document.getElementById("second").style.color = "black";
document.getElementById("third").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 1930) && (document.documentElement.scrollTop >= 880)) {
document.getElementById("second").style.color = "red";
document.getElementById("first").style.color = "black";
document.getElementById("third").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 3520+820) && (document.documentElement.scrollTop >= 1930)) {
document.getElementById("third").style.color = "red";
document.getElementById("second").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("first").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 6891+820+1385) && (document.documentElement.scrollTop >= 3520+820)) {
document.getElementById("fourth").style.color = "red";
document.getElementById("third").style.color = "black";
document.getElementById("second").style.color = "black";
document.getElementById("first").style.color = "black";
document.getElementById("sixth").style.color = "black";
document.getElementById("fifth").style.color = "black";
} else if ((document.documentElement.scrollTop < 6891+820+1385+50) && (document.documentElement.scrollTop >= 6891+820+1385)) {
document.getElementById("fifth").style.color = "red";
document.getElementById("third").style.color = "black";
document.getElementById("second").style.color = "black";
document.getElementById("first").style.color = "black";
document.getElementById("fourth").style.color = "black";
document.getElementById("sixth").style.color = "red";
}
}
}
</script>
<h1 style="text-align: center;font-size: 30px;font-weight: lighter;">Introduction</h1>
<h3>Remote-Controlled Cars</h3>
<p>
This kind of robots has a broad range of uses in our society. Army applications, toys for kids, automation projects and
professional competitions are some scenarios we may find such a device.
They can be controlled using many technologies, like: wires, Bluetooth, Wi-Fi or 4G/3G
signals are some of the most well-known.
Generally, they can be powered by oil or electricity.
Based on their size, a scale factor is usually attributed. This is done by comparing them with their analogous real models.
They can be found in many categories: Street, Drift, Buggy, Truggy and Trucks (hover each figure
with the cursor and find out a complete correspondence).
</p>
<div class="grid-container3">
<div class="image" style="background-image: url('./img/model1.png');">
<div class = "hiddenn">Buggy</div>
</div>
<div class="image" style="background-image: url('./img/model2.png');">
<div class = "hiddenn">Street</div>
</div>
<div class="image" style="background-image: url('./img/model3.png');">
<div class = "hiddenn">Drift</div>
</div>
</div>
<div class="grid-container2">
<div class="image" style="background-image: url('./img/model4.png');">
<div class = "hiddenn">Truck</div>
</div>
<div class="image" style="background-image: url('./img/model5.png');">
<div class = "hiddenn">Truggy</div>
</div>
</div>
<div style="margin-top: 10px; text-align: center;font-size: 15px;"><b>Fig. 1 </b> - 5 standard remote-controlled car categories commercially available. </div>
<h3>Arduino</h3>
<p>
Arduino is an open-source electronic platform based on flexible and reliable hardware and software. It was
created in 2003 by a group of students from Interaction Design Institute Ivrea, in Ivrea, Italy. The name
Arduino comes from a bar’s name located in its native city where the creators used to meet. Its purpose is
to create objects or environments. Arduino can sense the environment by receiving input from a variety of
sensors and can affect its surroundings by controlling lights, motors and other actuators. The
microcontroller on the board is programmed using the Arduino language, which is based on C++,
and the Arduino Integrated Development Environment (IDE), based on Processing. Most boards consist of an
Atmel 8-bit AVR microcontroller with different number of pins, ROM and RAM memory (among others). These
pins are organized in 2 rows of male headers, in order to easily connect and integrate it with external circuits. The
Arduino microcontroller also has an integrated timer based on an oscillating crystal at 16 MHz. Arduino projects
can be stand-alone, or they can communicate with software running on a computer, such as MATLAB.<br/>
</p>
<figure style="float: right;display: inline">
<img src="./img/nano.png" style="width: 300px;">
<figcaption> <b>Fig. 2 </b> - Arduino Nano.</figcaption>
</figure>
<p>
  1 of the relevances of this hardware is its ability to convert analog signals into digital ones,
which can be saved, modified and analyzed in a computer (or other digital device), using specific software. This data
processing could be essential in a medical diagnostic center, where the least variation in the
physiological signal could be crucial for the correct diagnosis of certain pathology.<br/>
  Any program written in Arduino is commonly called a sketch. These files are intended to be saved in the
owner’s PC with the following extension: .ino. In order to be executed, it only requires 2 basic functions:
setup and a loop. The 1st one is only executed once (after powering up or resetting the board).
Information like setting output/input pins; bit rate (baud); variables (…) can be given in this section of
the program. Libraries can also be initialized in this section. These play an important role in Arduino
programming, since a limited number of functions are available to be promptly used. Most of the times, it
is an advantage to use them since functions may often be more efficient from an Arduino’s scope (very
important due to its limited computational power). On the other side, the loop will be executed cyclically
with/without interruptions depending on the existence of interrupts or functions that deliberately pause
the execution (delay, delayMicroseconds).<br/>
  Many prototypes can be projected using Arduino: ECGs, EMGs, EEGs, Pletismography devices, automatized dispensers,
games, printers and, of course, robotic cars.
</p>
<h1 style="text-align: center;font-size: 30px;font-weight: lighter;">Prototype</h1>
<h3>Electronics</h3>
<p>
In order the car to perform some of the features we were interested in, we had to include several devices.
Here is a complete list of the components present in the prototype:
</p>
<div class="grid-container33" style="float: right;">
<div class="image3" style="background-image: url('./img/motor.jpg');">
<div class = "hiddenn">1</div>
</div>
<div class="image3" style="background-image: url('./img/servo.png');">
<div class = "hiddenn">2</div>
</div>
<div class="image3" style="background-image: url('./img/leds.jpg');">
<div class = "hiddenn">3</div>
</div>
<div class="image3" style="background-image: url('./img/resistances.jpg');">
<div class = "hiddenn">4</div>
</div>
<div class="image3" style="background-image: url('./img/bluetooth.jpg');">
<div class = "hiddenn">5</div>
</div>
<div class="image3" style="background-image: url('./img/driver.jpg');">
<div class = "hiddenn">6</div>
</div>
<div class="image3" style="background-image: url('./img/gps.jpg');">
<div class = "hiddenn">7</div>
</div>
<div class="image a" style="position: relative;">
<div style="text-align: center;position: absolute; bottom: 35%;font-size: 15px;width: 450px;"><b>Fig. 3 </b> - List of electric components present in the prototype.</div>
</div>
</div>
<ol style="line-height: 35px; display: inline-block;">
<li>DC 3V Motor;</li>
<li>Micro Servo SG90;</li>
<li>LEDs (Red, Yellow and White);</li>
<li>Resistances;</li>
<li>Bluetooth HC-05 Module;</li>
<li>L298N Driver;</li>
<li>GPS Module (NEO-6M-0-001).</li>
</ol>
<p>
All connections among the previous components were reverseably performed in a breadboard using
male-male, male-female and female-female jumper wires. <br/>
  Using Arduino Nano, we were able to decrease energy consumption and increase the portability of the
final project. This was done at the expense of some computational power. Since this Arduino's model only has
2 serial connections (RX and TX – which were used to transfer data between the Bluetooth module and
the android app), we needed to include an extra serial port to receive the location values from the GPS
module in the smartphone.<br/>
  Regarding the lights present in the vehicle, we always included a resistance in order
to limit the intensity of the current going through the diodes. This was done in the (2) front, (2) back
and (2) turn signal lights. These lights are totally controlled using the RCar app, except the ones in the
back that automatically turn on when the car accelerates backwards.<br/>
  A similar approach was followed with the Bluetooth module. Although, in this case, we included a voltage divider in
the circuit, such that the HC-05 receives half of the voltage (in the RX port) coming from the 5V Arduino
port (TX). Nevertheless, this was dispensable. Thus, it was not included in the electric circuit diagram (Fig. 5). <br/>
  Servo's rotation was lower and upper limited in the Arduino script to 45 and 135 degrees. Avoiding an excessive rotation
of the wheels of the car. We first used an old servo in our project but, due to bad oiled gears, this was substituted by a
new one. This way, we eliminated jittering and greatly increased angle precision.<br/>
  We also decided to include an extra feature in the car - GPS. This detects location with a remarkable accuracy
(considering the price) lower than 3 meters (radius). Then, a map with a red dot is
shown in the app, correctly positioned. Note that, due to GPS module limitations, it is not possible to get
car's position indoors.<br/>
  A speaker was also added to the circuit. A sound signal is emitted every time one clicks in the
corresponding button of the app. Both the duration and frequency of the wave were defined in the Arduino
IDE.<br/>
</p>
<figure style="float: left;">
<img src="./img/hBridge.png" style="width: 300px;">
<figcaption> <b>Fig. 4 </b> - H-Bridge Logic Circuit.</figcaption>
</figure>
<p>
  The L298N Driver is an electric compound that behaves similarly to a H-Bridge. Depending on the
interrupters that are closed, the current will flow in 2 different directions across the DC motor. This
allows the motor to rotate clockwise or counter-clockwise by always applying a positive voltage
with the Arduino (v<sub>in</sub>). Furthermore, it also controls the velocity at which the axles rotate.
These 2 sets of interrupters are controlled by the IN1 and IN2 pins present in the
driver.<br/>
  Motor has 2 axles (1 pointing to
the right and another to the left, moving synchronously).<br/>
  The car is powered by a 9V battery along with its adapter (on/off button incorporated to be easier to cut off circuit's power), which is connected to the L298N Driver. This is both
feeding the motor and the Arduino (consequently, all the remaining circuitry).
</p>
<div>
<figure style="margin-left: -5px">
<img src="./img/circuit.png" style="width: 1000px;">
<figcaption> <b>Fig. 5 </b> - Circuit representation of the car. Note that L298N Motor
Driver has a slightly different wiring than the one in the figure. And the DC 3V Motor has an
extra axis pointing in the opposite direction (both moving synchronously).</figcaption>
</figure>
</div>
<div class = "dropdown" style="background-color: black; cursor:pointer;border-style: dashed; position: relative;height: 25px;">
<div style=" color: white;position: absolute;left: 40px;top: 3px;">Arduino Code</div>
<div id = "plusMinus" style="color: white;position: absolute;right: 40px;bottom: -9px;font-size: 35px;">+</div>
</div>
<pre style="display: none; border-style: solid;">
<code>
// ------------------------------------------------ Including Libraries ------------------------------------------------
#include <NeoSWSerial.h> // Extra serial communication port
#include <TinyGPS++.h> // GPS module
#include <Servo.h> // Servo
// GPS Parameters
static const int RXPin = 12;
static const uint32_t GPSBaud = 9600;
// The serial connection to the GPS device
NeoSWSerial ss (RXPin,13);
// Creating Instances
Servo servo;
TinyGPSPlus gps;
// --------------------------------------------------- Defining Pins ---------------------------------------------------
int ledPin1 = 2;
int ledPin2 = 3;
int headLights = 5;
int backLights = 7;
boolean ledPin1State = LOW;
boolean ledPin2State = LOW;
int buzzer = 4;
int motorVelocityControl = 11;
int motorFrontDirectionControl = 9;
int motorBackDirectionControl = 10;
double aux;
int state;
int state2 = 4;
int x, y = 0;
int xAxis, yAxis;
unsigned long previousMillis = 0;
const long interval = 200;
// ------------------------------------------------------- Setup -------------------------------------------------------
void setup() {
// --------------------------------------------------------------- Pin Mode (Input/Output)
pinMode(ledPin1, OUTPUT); // Side Light
pinMode(ledPin2, OUTPUT); // Side Light
pinMode(backLights, OUTPUT); // Back Lights
pinMode(headLights, OUTPUT); // Front Lights
pinMode(motorVelocityControl, OUTPUT);
pinMode(motorFrontDirectionControl, OUTPUT);
pinMode(motorBackDirectionControl, OUTPUT);
servo.attach (6);
Serial.begin(38400);
ss.begin(GPSBaud);
}
// ------------------------------------------------------------ Loop ---------------------------------------------------
void loop() {
unsigned long currentMillis = millis();
// --------------------------------------------------------------- GPS Module
while (ss.available() > 0)
if (gps.encode(ss.read()))
if (gps.location.isValid())
{
Serial.print(gps.location.lat(), 6);
Serial.print("|");
Serial.println(gps.location.lng(), 6);
}
// --------------------------------------------------------------- Bluetooth Module
while (Serial.available() >= 2) {
x = Serial.read();
delay(10);
y = Serial.read();
};
delay(10);
// --------------------------------------------------------------- Head Lights
if (x == 1) {
digitalWrite(headLights, HIGH);
}
if (x == 0) {
digitalWrite(headLights, LOW);
}
// --------------------------------------------------------------- Back Lights
if (motorBackDirectionControl == HIGH) {
digitalWrite(backLights, HIGH);
} else {
digitalWrite(backLights, LOW);
}
// --------------------------------------------------------------- Buzzer
if (x == 2) {
tone(buzzer, 200, 80);
} else if (x == 3) {
digitalWrite(buzzer, LOW);
}
// --------------------------------------------------------------- Left Light
if (x == 5) {
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledPin1State == LOW) {
digitalWrite(ledPin1, HIGH);
ledPin1State = HIGH;
} else {
digitalWrite(ledPin1, LOW);
ledPin1State = LOW;
}
}
} else if (x == 4) {
digitalWrite(ledPin1, LOW);
}
// --------------------------------------------------------------- Right Light
if (x == 6) {
if (currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledPin2State == LOW) {
digitalWrite(ledPin2, HIGH);
ledPin2State = HIGH;
} else {
digitalWrite(ledPin2, LOW);
ledPin2State = LOW;
}
}
} else if (x == 7) {
digitalWrite(ledPin2, LOW);
}
// --------------------------------------------------------------- Servo Motor
if ((x == 255 && y == 255) || x == 153) {
servo.write(90 - 15);
delay(10);
} else if (x > 153 & y < 153) {
servo.write((180 / PI)*asin((153 - y) / (pow(pow(x - 153, 2) + pow(153 - y, 2), 0.5))) * 0.5 + 45 - 15);
delay(10);
} else if (x < 153 & y < 153 & x > 10 & y > 10) {
servo.write(160 - ((180 / PI)*asin((153 - y) / (pow(pow(x - 153, 2) + pow(153 - y, 2), 0.5))) * 0.5 + 45 - 15));
delay(10);
} else if (x > 153 & y > 153) {
servo.write((180 / PI)*abs(asin((153 - y) / (pow(pow(x - 153, 2) + pow(153 - y, 2), 0.5)))) * 0.5 + 45 - 15);
delay(10);
} else if (x < 153 & y > 153) {
servo.write(160 - ((180 / PI)*asin(abs(153 - y) / (pow(pow(x - 153, 2) + pow(153 - y, 2), 0.5))) * 0.5 + 45 - 15));
delay(10);
}
// --------------------------------------------------------------- DC Motor
aux = pow(pow(x - 153, 2) + pow(153 - y, 2), 0.5);
if (x == 255 || y == 255) {
analogWrite(motorVelocityControl, 0);
} else if (y < 153 && aux < 120 && y > 10) {
analogWrite(motorVelocityControl, 0.7 * aux * 255 / 120);
digitalWrite(motorFrontDirectionControl, HIGH);
digitalWrite(motorBackDirectionControl, LOW);
delay(20);
} else if (y > 153 && aux < 120) {
digitalWrite(motorFrontDirectionControl, LOW);
digitalWrite(motorBackDirectionControl, HIGH);
analogWrite(motorVelocityControl, 0.7 * aux * 255 / 120);
digitalWrite(backLights, HIGH);
delay(20);
} else if (y > 153 && aux < 120) {
digitalWrite(motorFrontDirectionControl, LOW);
digitalWrite(motorBackDirectionControl, HIGH);
analogWrite(motorVelocityControl, 0.7 * aux * 255 / 120);
digitalWrite(backLights, HIGH);
delay(20);
} else if (y < 153 && aux < 120 && y > 10) {
digitalWrite(motorFrontDirectionControl, HIGH);
digitalWrite(motorBackDirectionControl, LOW);
analogWrite(motorVelocityControl, 0.7 * aux * 255 / 120);
delay(20);
}
}
</code>
</pre>
<script>
let acc = document.getElementsByClassName("dropdown");
let acc2 = document.getElementsByClassName("pageHeight");
let acc3 = document.getElementById("plusMinus");
let i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
let panel = this.nextElementSibling;
let panel2 = acc2[0];
let panel3 = acc3;
if (panel.style.display === "block") {
panel.style.display = "none";
panel2.style.height = "9900px";
panel3.innerHTML = "+";
panel3.style.bottom = "-9px";
} else {
panel.style.display = "block";
panel2.style.height = "14620px";
panel3.innerHTML = "-";
panel3.style.bottom = "-6px";
}
});
}
</script>
<h3 style="margin-top: 25px;">Design</h3>
<p>
All the parts of the remote-controlled car were modelled using the CAD software SolidWorks.
The complete model (Fig. 6) was divided in several parts (which were meant to be 3D printed separately): wheels,
chassis, L-shape axles, connecting bar and the body of the car. The shape of the last component resulted from a funny
try to roughly resemble <a target="_blank" rel="noopener noreferrer" href="https://www.google.com/url?sa=i&rct=j&q=&esrc=s&source=images&cd=&cad=rja&uact=8&ved=2ahUKEwiJ1aXD07rdAhUBtRoKHRJCBtoQjRx6BAgBEAU&url=http%3A%2F%2Frentapolicecar.com%2Four-cars&psig=AOvVaw3E0nFzeMX9BPpbG4nP_7Dt&ust=1537019805284361">FBI vehicles</a>.
<figure style="float: right;">
<img src="./img/car1.png">
<figcaption> <b>Fig. 6 </b> - Isometric view of the remote-controlled car model.</figcaption>
</figure>
</p>
<p>
  At the beginning, the first parts to be modelled were the back wheels. An <a target="_blank" rel="noopener noreferrer" href="https://grabcad.com/library/rc-drift-wheel-1-10-1">initial design</a> was obtained from
GrabCad. However, some changes had to be made in order to fit our model. Since these wheels were meant to be attached
to the motor (with a double axis, 1 pointing to the right and another to the left), a cylindrical axle with an appropriate length and internal radius had to be built. Instead of
having the hexagonal cavity that was present in the original design, the shape of the hollow inner cylinder was
changed to match the shape of the motor's axle, as we can see in Fig. 7.
<figure style="float: left;">
<img src="./img/car2.png">
<figcaption> <b>Fig. 7 </b> - Back wheel design.</figcaption>
</figure>
</p>
<p>
  Special attention should be given to the fact the wheels were fixed to this double axle, consequently, these
2 move along at the motor speed. This is not the case for the 2 front wheels. <br/>
The same original design was used
in the front wheels. However, the axles modelled were completely different, as these were meant to rotate
around a vertical imaginary axle, synchronously with the servo's paddle. This movement was limited to 45º rotation to each side. Both wheels’ axles
were designed in an L-shape, with a cylindrical and a rectangular end. The latter is always parallel to the
servo’s paddle and has a cut where an elastic is to be wrapped around and connected to the paddle (Fig. 8).
<figure style="float: right;">
<img src="./img/car3.png">
<figcaption style="width: 400px;"> <b>Fig. 8 </b> - Cut view of 1 of the front
wheels. 2 features of the L-shaped axle are visible here: the cut where the
elastic is to be wrapped and the connection between the axle and the wheel.</figcaption>
</figure>
</p>
<p>
  Both ends of each axle were connected by a bar to guarantee the wheels move simultaneously to the sides. Furthermore, to
assure the wheels rotate at the same angle as the servo’s paddle, the distance between the centre of
the hinge of the axle and the centre of the cut was equal to the length of the paddle (Fig. 9).
<figure style="float: left;">
<img src="./img/car4.png">
<figcaption style="width: 500px;"> <b>Fig. 9 </b> - Bottom view of the chassis. It is visible the connection between
both front wheels’ axles.</figcaption>
</figure>
</p>
<p>
  To guarantee the rotation of the wheels, a revolved cut was added to the cylindrical end of the axle and a
complementary boss was designed in the wheel (Fig. 8). In order the joint to be detachable, a difference of 0.3mm between
the internal and external radius was guaranteed. The same principle was applied to the hinges in both axles. Thus, 2 cylindrical
structures were built on the bottom surface of the chassis, each with a revolved cut at the
end. A complementary structure was built in each axle corner, again with the 0.3mm difference.
<figure style="float: right;">
<img src="./img/car5.png">
<figcaption style="width: 400px;"> <b>Fig. 10 </b> - Isometric view of the chassis, wheels, axles and servo.</figcaption>
</figure>
</p>
<p>
  As for the chassis of the car, besides the structures already referred, there are 2 other features worth
mentioning. First, a cut in the chassis was made in order to fit the servo, as the paddle must be at the same
height as the axles. Second, it had to be cut at the front in order the wheels to turn (Fig. 10). <br/>
  Finally, although this part was not printed due to its dimension and accessory nature, the body of the
car was also designed. We made sure to include the cuts for the respective lighting system, place for (back and front)
registration plates and 4 complementary supports to the ones present on the top surface of the chassis - tightly connecting both parts. <br/>
  It is shown below the side, front and back views of the completely assembled model (Fig.11).
</p>
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
<div class="grid-container22" style="padding-left: 90px;padding-right: 90px;">
<div class="image2" style="background-image: url('./img/car7.png');background-size: 350px">
<div class = "hiddenn" style="background-color: white;width: 400px">Front View</div>
</div>
<div class="image2" style="background-image: url('./img/car8.png');background-size: 350px">
<div class = "hiddenn" style="background-color: white;width: 400px">Back View</div>
</div>
<div class="image2 a2" style="background-image: url('./img/car6.png');background-size: 450px; margin-left: 160px;">
<div class = "hiddenn" style="background-color: white;">Side View</div>
</div>
</div>
<div style="margin-top: -50px; text-align: center;font-size: 15px;"><b>Fig. 11 </b>- Different views of the car prototype modeled using SoliWorks.</div>
<p>
The biggest challenge faced in this part of the project was the design of the front wheels' rotation system.
This had to be redone several times in order to allow the proper movement imposed by the servo. However, this was never tested, as the
axles were meant to be connected to the servo’s paddle by an elastic, and this could only be done after printing. <br/>
  Furthermore, it is important to mention that in order to achieve the final design, all components had to be
redone several times, particularly, the cuts and extrudes responsible for the connections between
parts. This assured the pieces were aligned and had appropriate dimensions. <br/>
  After modelling, the main goal, in terms of design, was to 3D print (using Ultimaker 2+ Extended printer
- Fig. 12) the several parts and use them to build the model. Finally, all the electric components were displaced in the car.
</p>
<figure style="float: left;">
<img src="./img/printer.png">
<figcaption style="width: 300px;"> <b>Fig. 12 </b> - Ultimaker 2+ Extended, at iStartLab (IST, University of Lisbon).</figcaption>
</figure>
<p>
  It is important to mention there was a dimension limitation associated with the printer, which did not
allow us to print the body of the car. The printing required the use of
a 2.85mm PLA filament. Although some smaller details of the model were not perfectly reproduced, printing
was well succeeded. <br/>
   Regarding the 2 cylindrical structures designed on the bottom of the chassis (to fit the L-shape axles),
they ended up slightly prone to break. This was fixed by wrapping some resistant tap glue. Moreover, still
to secure the axles to the chassis, 2 elastics were wrapped around on each side, which helped keeping the
car stable and all parts in place. In other words, they pushed both parts against each other. 1 way to