
Make you ideal fun
35
int
sensorPin
=
A1
;
// distance value for danger close. Bigger values are greater distance and
smaller values are lower distance
int
dangerDistance
=
350
;
/* Setup function */
void
setup
()
{
// attach servos
frontServo
.
attach
(
12
);
rearServo
.
attach
(
13
);
// assign sensor
pinMode
(
sensorPin
,
INPUT
);
// center servos
frontServo
.
write
(
centerPos
);
rearServo
.
write
(
centerPos
);
// wait 3 seconds for start walking
delay
(
3000
);
//Serial.begin(9600); // serial data setup
}
/* distance check function */
void
scan
()
{
// read 5 distance values
for
(
i
=
0
;
i
<
5
;
i
=
i
+
1
)
{
distanceCheck
=
analogRead
(
sensorPin
);
collectDistance
[
i
]
=
distanceCheck
;
// serial output for testing
//Serial.print (i);
//Serial.print(" = ");
//Serial.println(collectDistance[i]);
}
// checksum of the 5 distance values for getting an average value.
This will prevent the robot to change behavior by reading one wrong value
Содержание Insect-Robot
Страница 1: ...Make you ideal fun 1 Insect Robot Instruction Manual...
Страница 9: ...Make you ideal fun 9 Figure 11 Bend the cutted paper into the shape as figure 12 Figure 12...
Страница 11: ...Make you ideal fun 11 Install the Nano board on the servo as figure 15 but don t fix Figure 15...
Страница 27: ...Make you ideal fun 27 Figure 43...
Страница 28: ...Make you ideal fun 28 After adjusting the angle you can completely fix the forefoot Figure 44...