Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Fab Academy 2023 Site
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 Site
Commits
0e55667b
Commit
0e55667b
authored
2 years ago
by
Rodrigo Shiordia López
Browse files
Options
Downloads
Patches
Plain Diff
Update recitation/programming/slides.html
parent
20d70ba4
No related branches found
No related tags found
No related merge requests found
Pipeline
#376850
passed
2 years ago
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
recitation/programming/slides.html
+87
-0
87 additions, 0 deletions
recitation/programming/slides.html
with
87 additions
and
0 deletions
recitation/programming/slides.html
+
87
−
0
View file @
0e55667b
...
...
@@ -240,8 +240,95 @@ void loop() {
*
Functions
and
methods
are
ways
of
reusing
code.
*
Something
that
you
are
going
to
do
several
times
,
you
can
put
inside
a
function
and
use
it
again
and
again.
*
A
function
normally
has
a
return
value:
somehting
that
it
returns
back
to
you
after
you
call
or
invoke
it.
(
Some
functions
have
no
return
value
or
a
void
return
value.
)
*
It
'
s
important
to
distinguish
between
Built-in
functions
and
custom
functions.
---
#
Functions:
return
value
```
Arduino
//
Explaining
Functions
and
methods
//
Rodrigo
Shiordia
2023
void
setup
()
{
Serial.begin
(9600);
Serial.println
("
Temperature
Calculator
");
}
void
loop
()
{
Serial.print
("
Please
enter
temperature
in
Fahrenheit:
");
while
(Serial.available() =
=
0)
{
}
float
F =
Serial.parseFloat();
float
C =
fahrenheitToCelsius(F);
Serial.print
("
Temperature
in
Celsius:
");
Serial.println
(
C
);
}
float
fahrenheitToCelsius
(
float
theValue
)
{
return
(
theValue
-32
)
*0.5556
;
}
```
---
#
Functions:
void
return
```
Arduino
//
Explaining
Functions
and
methods
//
Rodrigo
Shiordia
2023
int
ledPin =
1;
void
setup
()
{
Serial.begin
(9600);
Serial.println
("
Function
based
LED
blinker
!
");
}
void
loop
()
{
Serial.print
("
How
Many
times
you
want
the
LED
to
blink:
");
while
(Serial.available() =
=
0)
{
}
int
T =
Serial.parseInt();
blinkLED
(
T
);
}
void
blinkLED
(
int
times
)
{
for
(
int
i =
0;
i
<
times
;
i
++)
{
digitalWrite
(
ledPin
,
HIGH
);
delay
(1000);
digitalWrite
(
ledPin
,
LOW
);
delay
(1000);
}
}
```
---
#
Debugging
*
Debugging
is
about
getting
your
code
to
do
what
you
want.
*
Syntax
errors
are
when
your
code
is
written
incorrectly
according
to
the
programming
language.
In
C
/
Arduino
,
the
most
common
is
missing
a
semicolon
or
a
bracket.
*
Use
checks
and
print
statements
to
know
exaclty
what
your
code
is
doing
at
any
time.
---
#
Libraries
*
Arduino
has
libraries
that
extend
its
capabilities.
*
Libraries
are
collections
of
code
that
you
can
use.
They
normally
provide
you
with
functions
and
methods
for
you
to
use.
---
#
Tips
for
writing
programs
*
Always
start
with
some
idea
of
what
you
want
to
do.
*
Write
pseudocode.
*
Write
small
blocks
of
code
and
run
and
upload
so
you
know
it
'
s
working
before
writing
more
code.
*
Read
as
much
code
as
you
can.
Writing
code
requires
you
to
understand
code.
*
Use
online
resources:
*
[
stackOverflow
](
https:
//
stackoverflow.com
/)
*
[
Arduino
Forums
](
https:
//
forum.arduino.cc
/)
---
</
textarea
>
...
...
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