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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
André Langsam Gonzalez
Praktika GruLaIT
Commits
30240ca6
Commit
30240ca6
authored
4 years ago
by
André Langsam Gonzalez
Browse files
Options
Downloads
Patches
Plain Diff
Version 2
parent
f6b36fff
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Uebung_3/src/main.cpp
+7
-11
7 additions, 11 deletions
Uebung_3/src/main.cpp
with
7 additions
and
11 deletions
Uebung_3/src/main.cpp
+
7
−
11
View file @
30240ca6
#include
<Arduino.h>
#include
<SoftwareSerial.h>
static
int
en1
=
9
;
// Enable Pin 1 des L293D
static
int
in1
=
7
;
// Input Pin 1 des L293D
...
...
@@ -8,9 +7,6 @@ static int in2 = 6; // Input pin 2 des L293D
static
int
button
=
4
;
static
int
potentiometer
=
A0
;
// Für den Serial Monitor:
SoftwareSerial
mySerial
(
10
,
11
);
// RX, TX
// 0 = DC-Motor steht, 5 = DC-Motor dreht mit voller Drehzahl
float
sollSpeed
=
0
;
//true = Uhrzeigersinn, false = Gegenuhrzeigersinn
...
...
@@ -66,16 +62,16 @@ void setNewTask()
sollSpeed
=
5
/
12.0
*
(
random
(
0
,
1200
)
/
100
);
sollDirection
=
random
(
100
)
>
50
;
my
Serial
.
print
(
"Soll-Geschwindigkeit: "
);
my
Serial
.
println
(
sollSpeed
);
my
Serial
.
print
(
"Soll-Drehrichtung: "
);
Serial
.
print
(
"Soll-Geschwindigkeit: "
);
Serial
.
println
(
sollSpeed
);
Serial
.
print
(
"Soll-Drehrichtung: "
);
if
(
sollDirection
)
{
my
Serial
.
println
(
"Uhrzeigersinn"
);
Serial
.
println
(
"Uhrzeigersinn"
);
}
else
{
my
Serial
.
println
(
"Gegenuhrzeigersinn"
);
Serial
.
println
(
"Gegenuhrzeigersinn"
);
}
}
...
...
@@ -89,7 +85,7 @@ float roundFloat(float floatingNumber)
// Diese Funktion wird vom Arduino beim Start als erstes ausgeführt.
void
setup
()
{
my
Serial
.
begin
(
9600
);
Serial
.
begin
(
9600
);
pinMode
(
en1
,
OUTPUT
);
pinMode
(
in1
,
OUTPUT
);
pinMode
(
in2
,
OUTPUT
);
...
...
@@ -113,7 +109,7 @@ void loop()
// kleine Abweichungen zu erlauben, können die Geschwindigkeits-Werte vor dem
// Vergleich mit der Funktion roundFloat() einzel gerundet werden.
// Stimmen die Drehrichtungen sowie die Geschwindigkeiten überein, soll dies mittels
//
my
Serial.println()
// Serial.println()
// (https://www.arduino.cc/reference/de/language/functions/communication/serial/println/)
// über den Serial Monitor ausgegeben werden und einen neuen Task erstellt werden.
}
\ No newline at end of file
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