Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Praktika GruLaIT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Toni Ruoss
Praktika GruLaIT
Commits
b572fad0
Commit
b572fad0
authored
4 years ago
by
Toni Ruoss
Browse files
Options
Downloads
Patches
Plain Diff
Uebung_5_ueberarbeitet
parent
2e1bdea9
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Uebung_5/src/main.cpp
+42
-7
42 additions, 7 deletions
Uebung_5/src/main.cpp
with
42 additions
and
7 deletions
Uebung_5/src/main.cpp
+
42
−
7
View file @
b572fad0
...
...
@@ -23,6 +23,7 @@ const int BUTTONPIN{7};
const
int
OPENPOS
{
180
};
const
int
CLOSEPOS
{
90
};
const
int
OPENPOS2
{
0
};
//Aussen geöffnet
int
state
{
S_CLOSED
};
int
position
{
CLOSEPOS
};
...
...
@@ -37,6 +38,7 @@ void setup() {
}
void
loop
()
{
int
i
=
0
;
switch
(
state
)
{
case
S_OPEN
:
if
(
digitalRead
(
BUTTONPIN
)
==
LOW
)
{
...
...
@@ -44,27 +46,60 @@ void loop() {
Serial
.
println
(
"Entered Transition Closeing"
);
}
break
;
case
T_OPENING
:
position
++
;
if
(
position
>=
OPENPOS
)
{
if
(
i
==
0
)
{
position
++
;
}
else
{
position
--
;
}
if
(
position
>=
OPENPOS
||
position
<=
OPENPOS2
)
{
state
=
S_OPEN
;
Serial
.
println
(
"Entered State OPEN"
);
}
if
(
position
>=
OPENPOS
)
{
i
=
1
;
}
if
(
position
<=
OPENPOS2
)
{
i
=
0
;
}
break
;
case
S_CLOSED
:
if
(
digitalRead
(
BUTTONPIN
)
==
HIGH
)
{
state
=
T_OPENING
;
Serial
.
println
(
"Entered Transition Opening"
);
state
=
T_OPENING
;
Serial
.
println
(
"Entered Transition Opening"
);
}
break
;
case
T_CLOSEING
:
position
--
;
if
(
position
<=
CLOSEPOS
)
{
if
(
i
==
1
)
{
position
--
;
if
(
position
<=
CLOSEPOS
)
{
state
=
S_CLOSED
;
Serial
.
println
(
"Entered State CLOSE"
);
}
if
(
i
==
0
)
{
position
++
;
if
(
position
>=
CLOSEPOS
)
{
state
=
S_CLOSED
;
Serial
.
println
(
"Entered State CLOSE"
);
}
}
break
;
}
myDoorDrive
.
write
(
position
);
delay
(
10
);
}
}
}
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