74
3.2.4.5 Software Design
1.
Diagram of the program
2.
Introduction of the program
#include <Servo.h>
/* In this section, we use the steering gear, so we need to call the
steering gear library file. As for what is in the library file, we will not study it.
Interested friends can drive for research. We have put this library files on the CD-
ROM, we need to copy this folder to the Arduino IDE installation path "libraries"
folder, otherwise the program can not compile. * /
Servo head
;
int
E1
=
5
;
//PWMA
int
M1
=
9
;
//DIRA****************************************left
int
E2
=
6
;
//PWMB
int
M2
=
10
;
//DIRB****************************************right
/*
Define 4 motor control terminals, connected to IN1-IN4 on the motor drive board. * /
const
int
TrigPin
=
2
;
const
int
EchoPin
=
3
;
/* Define the sensor's 2 control pins to connect to pins 2 and 3
on the Arduino. * /
float
da
;
float
dl
;
float
dr
;
/ * Define three variables, used to store the servo at 0,90,180 degrees, the
value collected by the ultrasonic module, da is the value collected by the ultrasonic
90 degrees servo, dl is the steering servo 180 degrees ultrasonic acquisition To the
value, at this point the steering gear has turned to the left of the car. da for the
servo 0 degrees ultrasonic collected value, then the steering gear has turned to the
right side of the car. * /
void
setup
()
{
Serial
.
begin
(
9600
);
/ * Set the baud rate to 9600, use "Serial Monitor" to check the
data during debugging * /
head
.
attach
(
13
);
/ * Define the control pin of the servo as pin 13* /
pinMode
(
E2
,
OUTPUT
);
pinMode
(
E1
,
OUTPUT
);
pinMode
(
M1
,
OUTPUT
);
pinMode
(
M2
,
OUTPUT
);
pinMode
(
TrigPin
,
OUTPUT
);
pinMode
(
EchoPin
,
INPUT
);
/ * Define two ultrasonic working mode. * /
Summary of Contents for Hummer-Bot
Page 1: ...Hummer Bot Instruction Manual Github https github com keywish keywish hummer bot...
Page 7: ...4...
Page 8: ...5...
Page 9: ...6...
Page 10: ...7...
Page 13: ...10 Fig 2 2 Several commonly usedArduino...
Page 15: ...12 After the completion as shown...
Page 16: ...13 The second step is to Welding wire on the motor...
Page 17: ...14 After the completion as shown...
Page 19: ...16 Fig 3 1 3 Diagram of Aluminum Alloy Bracket Installation...
Page 20: ...17 Fig 3 1 4 Diagram of Motor Installation Fig 3 1 5 Fixing Screw for Motor...
Page 24: ...21 Fig 3 1 10 Diagram of Wheel Installation Fig 3 1 10 Diagram of Wheel Screw Fixation...
Page 29: ...26 Fig 3 1 15 Diagram of Tracing Module Installation...
Page 30: ...27 Fig 3 1 16 Diagram of Screw Brackets Fig 3 1 17 The Back of Complete Installation...
Page 32: ...29 First install the screws on the UNO After the completion as shown...
Page 43: ...40 Fig 3 1 33 Diagram of Wires Arrangement Fig3 1 34 the Effect of Whole Assembly...
Page 56: ...53 Fig 3 2 11 Diagram of Data with Obstacles Fig 3 2 12 Diagram of Data without Obstacles...
Page 69: ...66 Fig 3 2 22 Diagram of Steering Gear Fig 3 2 23 Composition of Steering Gear...
Page 93: ...90 Fig 3 2 42 Receiving Head Position Fig 2 3 43 Installation of Receiving Head...