Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ingeniarius_public
robotcraft_maze
Commits
d456b951
Commit
d456b951
authored
Oct 14, 2021
by
Micael Couceiro
Browse files
Central sensor is now being used in the main code.
parent
94291cc7
Changes
1
Hide whitespace changes
Inline
Side-by-side
robotcraft_bot/robotcraft_bot.ino
View file @
d456b951
...
...
@@ -9,11 +9,12 @@ long int myrate = 500;
void
setup
()
{
// start serial port for debugging
Serial
.
begin
(
9600
);
}
void
loop
()
{
// main loop goes here
while
(
loop_rate
()){
switch
(
state
){
...
...
@@ -39,7 +40,7 @@ void loop() {
int
LOST
(){
float
*
range
=
myrobot
.
getIRranges
();
if
((
range
[
0
]
>=
20
)
&&
(
range
[
2
]
>=
20
)){
if
((
range
[
0
]
>=
20
)
&&
(
range
[
1
]
>=
20
)
&&
(
range
[
2
]
>=
20
)){
int
pwm
[
2
]
=
{
150
,
150
};
myrobot
.
moveRobot
(
pwm
);
}
...
...
@@ -50,7 +51,7 @@ int LOST(){
int
CCW
(){
float
*
range
=
myrobot
.
getIRranges
();
if
((
range
[
0
]
<
20
)
||
(
range
[
2
]
<
20
)){
if
((
range
[
0
]
<
20
)
||
(
range
[
1
]
<
20
)
||
(
range
[
2
]
<
20
)){
int
pwm
[
2
]
=
{
-
150
,
150
};
myrobot
.
moveRobot
(
pwm
);
}
...
...
@@ -61,7 +62,7 @@ int CCW(){
int
WALL1
(){
float
*
range
=
myrobot
.
getIRranges
();
if
(
range
[
2
]
>=
20
){
if
((
range
[
1
]
>=
20
)
&&
(
range
[
2
]
>=
20
)
)
{
int
pwm1
[
2
]
=
{
150
,
150
};
myrobot
.
moveRobot
(
pwm1
);
delay
(
myrate
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment