FAQ
| This is a
LIVE
service |
Changelog
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IDP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ayush Agarwal
IDP
Commits
a40d31cb
Commit
a40d31cb
authored
3 years ago
by
ayush1301
Browse files
Options
Downloads
Patches
Plain Diff
added push button code
parent
dbacf3c5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main/main.ino
+24
-14
24 additions, 14 deletions
main/main.ino
with
24 additions
and
14 deletions
main/main.ino
+
24
−
14
View file @
a40d31cb
...
...
@@ -5,6 +5,8 @@ uint8_t regions[2] = {BACKWARD, FORWARD};
uint8_t
regions_opposite
[
2
]
=
{
FORWARD
,
BACKWARD
};
int
region
=
1
;
#define floating_avg_num 1
int
button_val
=
0
;
int
button_port
=
0
;
//Motors
Adafruit_MotorShield
AFMS
=
Adafruit_MotorShield
();
...
...
@@ -37,6 +39,7 @@ void setup() {
for
(
int
i
=
0
;
i
<
num_IR
;
i
++
)
{
pinMode
(
IR_locns
[
i
],
INPUT
);
}
pinMode
(
button_port
,
INPUT
);
}
void
loop
()
{
...
...
@@ -48,22 +51,29 @@ void loop() {
motors
[
j
]
->
run
(
regions
[
region
]);
}
while
(
true
)
{
update_IR_vals
();
int
IR_check_val
=
IR_check
(
IR_colours
);
if
(
IR_check_val
==
0
)
{
move_both
(
motors
,
255
);
Serial
.
println
(
"FORWARD"
);
}
else
if
(
IR_check_val
==
1
)
{
move_one_motor
(
motors
,
200
,
left
);
Serial
.
println
(
"TURN LEFT"
);
}
else
if
(
IR_check_val
==
2
)
{
move_one_motor
(
motors
,
200
,
right
);
Serial
.
println
(
"TURN RIGHT"
);
if
(
button_val
==
0
)
{
update_IR_vals
();
int
IR_check_val
=
IR_check
(
IR_colours
);
if
(
IR_check_val
==
0
)
{
move_both
(
motors
,
255
);
Serial
.
println
(
"FORWARD"
);
}
else
if
(
IR_check_val
==
1
)
{
move_one_motor
(
motors
,
200
,
left
);
Serial
.
println
(
"TURN LEFT"
);
}
else
if
(
IR_check_val
==
2
)
{
move_one_motor
(
motors
,
200
,
right
);
Serial
.
println
(
"TURN RIGHT"
);
}
else
{
Serial
.
println
(
"Else block fml"
);
}
button_val
=
digitalRead
(
button_port
);
}
else
{
Serial
.
println
(
"Else block fml"
);
Serial
.
println
(
"Button pushed. Exiting"
);
while
(
1
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment