Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arduino-block-course
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
Service Desk
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
Stefan Gehr
arduino-block-course
Commits
566c89cc
Commit
566c89cc
authored
2 years ago
by
Stefan Gehr
Browse files
Options
Downloads
Patches
Plain Diff
saying numbers
parent
e2a95b98
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
report/src/report.tex
+62
-1
62 additions, 1 deletion
report/src/report.tex
with
62 additions
and
1 deletion
report/src/report.tex
+
62
−
1
View file @
566c89cc
...
@@ -9,8 +9,12 @@
...
@@ -9,8 +9,12 @@
\usepackage
{
siunitx
}
\usepackage
{
siunitx
}
\usepackage
{
ragged2e
}
\usepackage
{
ragged2e
}
\usepackage
{
booktabs
}
\usepackage
{
booktabs
}
\usepackage
{
algorithm
}
\usepackage
{
algpseudocodex
}
\usepackage
{
hyperref
}
\usepackage
{
hyperref
}
\newcommand
{
\algorithmautorefname
}{
Algorithm
}
\title
{
Solar Pump Control
}
\title
{
Solar Pump Control
}
\subtitle
{
Arduino Project for the Arduino Block Course 2022
}
\subtitle
{
Arduino Project for the Arduino Block Course 2022
}
\author
{
Engelmann, Mario
\and
Gehr, Stefan
}
\author
{
Engelmann, Mario
\and
Gehr, Stefan
}
...
@@ -94,7 +98,64 @@ and increments the queue.
...
@@ -94,7 +98,64 @@ and increments the queue.
Both index variables get set back to zero in case they reach the the end of the queue.
Both index variables get set back to zero in case they reach the the end of the queue.
\section
{
Saying Numbers
}
\section
{
Saying Numbers
}
As our ``client'' only speaks German, we needed to implement the way numbers are read in that language.
First we implemented a function sayDigit(
\(
d
\)
) that plays the corresponding sound of the digit
\(
d
\)
.
So ``eins'' for
\(
d
=
1
\)
, ``zwei'' for
\(
d
=
2
\)
, and so on.
Then for a few special cases we needed to create the function
sayPreNumber(
\(
n
\)
) that only says ``ein'' instead of ``eins'' for
\(
n
=
1
\)
and just calls our normal sayNumber(
\(
n
\)
) function otherwise.
This is necessary for cases like
\(
n
=
31
\)
which is read as ``EINunddreißig'' instead of ``EINSunddreißig''.
Another special fucntion is sayAftNumber(
\(
n
\)
) which only our normal sayNumber(
\(
\n
\)
) function if
\(
n
\ne
0
\)
.
It is necessary for numbers like 100, 200, 300,
\dots
,
as we want to say ``zweihundert'' for
\(
n
=
200
\)
and not ``zweihundertnull''.
\begin{algorithm}
\caption
{
Pseudocode implementation of the sayNumber function
}
\label
{
alg:saynumber
}
\begin{algorithmic}
[1]
\Function
{
sayNumber
}{\(
n
\)}
\If
{\(
n<
0
\)}
\Comment
{
negative number
}
\State
say(minus)
\State
sayNumber(
\(
-
n
\)
)
\ElsIf
{\(
n <
10
\)}
\Comment
{
1-digit number
}
\State
sayDigit(
\(
n
\)
)
\ElsIf
{\(
n <
100
\)}
\Comment
{
2-digit number
}
\If
{\(
n
=
11
\)}
\Comment
{
special case ELF
}
\State
say(elf)
\ElsIf
{\(
n
=
12
\)}
\Comment
{
special case ZWÖLF
}
\State
say(zwölf)
\Else
\State
tens
\(
\gets
\lfloor
n
/
10
\rfloor
\)
\State
ones
\(
\gets
n
-
10
\times
\text
{
tens
}\)
\If
{\(
\text
{
ones
}
\ne
0
\)}
\Comment
{
say the 1-digit first
}
\State
sayPreNumber(ones)
\If
{\(
\text
{
tens
}
\ge
2
\)}
\Comment
{
UND only for numbers
\(
>
20
\)}
\State
say(und)
\EndIf
\EndIf
\If
{\(
\text
{
tens
}
=
1
\)}
\State
say(zehn)
\ElsIf
{\(
\text
{
tens
}
=
2
\)}
\State
say(zwanzig)
\ElsIf
{\(
\hdots
\)}
\State
\(
\vdots
\)
\EndIf
\EndIf
\Else
\Comment
{
3-digit number
}
\State
hundreds
\(
\gets
\lfloor
n
/
100
\rfloor
\)
\State
sayPreNumber(hundreds)
\State
sayAftNumber(
\(
n
-
100
\times
\text
{
hundreds
}\)
\EndIf
\end{algorithmic}
\end{algorithm}
Finally our main function sayNumber(
\(
n
\)
) goes thorugh all the possible cases.
A peudocode implementation of it can be seen in
\autoref
{
alg:saynumber
}
.
\section
{
Temperature
}
\section
{
Temperature
}
%\listoffigures
%\listoffigures
...
...
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