Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
3
3D_Interfaces_Recitation
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
Model registry
Operate
Environments
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Amira Abdel-Rahman
3D_Interfaces_Recitation
Commits
0920918c
Commit
0920918c
authored
2 years ago
by
Amira Abdel-Rahman
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
5c063c92
Branches
master
No related tags found
No related merge requests found
Pipeline
#23256
passed
2 years ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Scripts by Iulian/htmaa_serial_arduinoA0withLED.ino
+42
-0
42 additions, 0 deletions
Scripts by Iulian/htmaa_serial_arduinoA0withLED.ino
with
42 additions
and
0 deletions
Scripts by Iulian/htmaa_serial_arduinoA0withLED.ino
0 → 100644
+
42
−
0
View file @
0920918c
// Sends 3 numerical values to the serial port, and reads one numerical value (then turns onboard LED if that value is >0)
void
setup
()
{
// put your setup code here, to run once:
Serial
.
begin
(
9600
);
pinMode
(
A0
,
INPUT
);
pinMode
(
13
,
OUTPUT
);
}
void
loop
()
{
// SEND TO COMPUTER 3 integer values separated by comma
int
data0
=
analogRead
(
A0
);
int
data1
=
123
;
int
data2
=
456
;
Serial
.
print
(
data0
);
Serial
.
print
(
","
);
Serial
.
print
(
data1
);
Serial
.
print
(
","
);
Serial
.
print
(
data2
);
Serial
.
println
();
delay
(
100
);
// a bit of delay so the communication buffer doesn't get overloaded
// RECEIVE FROM COMPUTER a text value that gets converted into int
while
(
Serial
.
available
())
{
String
s
=
Serial
.
readStringUntil
(
'\n'
);
// TURN ON LED if the value from computer is >0
int
x
=
s
.
toInt
();
if
(
x
>
0
)
{
digitalWrite
(
13
,
HIGH
);
}
else
{
digitalWrite
(
13
,
LOW
);
}
}
}
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