Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Akseli Uunila
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
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
Academany
Fab Academy
2023
Fab Academy 2023 Labs
Super Fab Lab Oulu
Super Fab Lab Oulu students
Akseli Uunila
Commits
f4fc39e9
Commit
f4fc39e9
authored
2 years ago
by
Akseli Uunila
Browse files
Options
Downloads
Patches
Plain Diff
Add checking of commands and acting on them
parent
0067a458
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
docs/source_files/week_4/first-program/first-program.ino
+15
-5
15 additions, 5 deletions
docs/source_files/week_4/first-program/first-program.ino
with
15 additions
and
5 deletions
docs/source_files/week_4/first-program/first-program.ino
+
15
−
5
View file @
f4fc39e9
...
...
@@ -30,11 +30,11 @@ void loop() {
// Blink the NeoPixel
pixels
.
clear
();
// Set all pixel colors to 'off'
// We only have one pixel, therefore the first argument (index) is 0
pixels
.
setPixelColor
(
0
,
pixels
.
Color
(
25
,
25
,
205
));
// Nice blue color
pixels
.
setPixelColor
(
0
,
pixels
.
Color
(
25
,
25
,
180
));
// Nice blue color
pixels
.
show
();
// Send the updated pixel colors to the hardware.
delay
(
DELAYVAL
);
// wait between
pixels
.
clear
();
pixels
.
setPixelColor
(
0
,
pixels
.
Color
(
1
8
0
,
1
8
0
,
25
));
// Nice yellow color
pixels
.
setPixelColor
(
0
,
pixels
.
Color
(
1
5
0
,
1
5
0
,
25
));
// Nice yellow color
pixels
.
show
();
}
else
{
...
...
@@ -49,10 +49,20 @@ void loop() {
delay
(
DELAYVAL
);
String
test_str
;
// Initialize the variable
if
(
Serial
.
available
()
>
0
)
{
// If there is incoming bytes in the serial:
test_str
=
Serial
.
readString
();
// This reads the serial buffer to a String
String
input_str
=
Serial
.
readString
();
// This reads the serial buffer to a String
input_str
.
trim
();
// remove any \r \n whitespace at the end of the String
Serial
.
print
(
"You wrote: "
);
Serial
.
println
(
test_str
);
// Send it back to see if this works
Serial
.
println
(
input_str
);
// Send it back to see if this works
// Set the boolean accordingly
if
(
input_str
==
"blink"
)
{
Serial
.
println
(
"Ok, blinking"
);
blinking
=
true
;
}
else
if
(
input_str
==
"stop"
)
{
Serial
.
println
(
"Ok, stopping"
);
blinking
=
false
;
}
}
}
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