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
7097c0fb
Commit
7097c0fb
authored
2 years ago
by
Stefan Gehr
Browse files
Options
Downloads
Patches
Plain Diff
code improvements
parent
8c74e55b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
solarpump/mp3.ino
+2
-1
2 additions, 1 deletion
solarpump/mp3.ino
solarpump/solarpump.ino
+44
-40
44 additions, 40 deletions
solarpump/solarpump.ino
solarpump/temperature.ino
+0
-1
0 additions, 1 deletion
solarpump/temperature.ino
with
46 additions
and
42 deletions
solarpump/mp3.ino
+
2
−
1
View file @
7097c0fb
#include
<Arduino.h>
#include
"pins.h"
#include
"pins.h"
#include
<SoftwareSerial.h>
#include
<SoftwareSerial.h>
...
@@ -17,7 +18,7 @@ void mp3Setup(void) {
...
@@ -17,7 +18,7 @@ void mp3Setup(void) {
// immediately play a file
// immediately play a file
void
playFile
(
uint8_t
fileNumber
,
bool
respectBusyPin
)
{
void
playFile
(
uint8_t
fileNumber
,
bool
respectBusyPin
)
{
// do nothing if we want to wait for the BUSY pin
// do nothing if we want to wait for the BUSY pin
if
(
respectBusyPin
&&
digitalRead
(
MP3BUSY
))
{
if
(
respectBusyPin
&&
digitalRead
(
MP3BUSY
)
==
LOW
)
{
return
;
return
;
}
}
mp3
.
write
(
fileNumber
);
mp3
.
write
(
fileNumber
);
...
...
This diff is collapsed.
Click to expand it.
solarpump/solarpump.ino
+
44
−
40
View file @
7097c0fb
#include
<
std
in
t
.h>
#include
<
Ardu
in
o
.h>
#include
"pins.h"
#include
"pins.h"
#include
"temperature.h"
#include
"temperature.h"
#include
"mp3.h"
#include
"mp3.h"
...
@@ -154,29 +154,33 @@ void displayLight(bool turnOn) {
...
@@ -154,29 +154,33 @@ void displayLight(bool turnOn) {
/*
/*
* main setup function
* main setup function
* initiali
z
e every electronic component
* initiali
s
e every electronic component
*/
*/
// main setup function
void
setup
(
void
)
{
void
setup
(
void
)
{
lcd
.
init
();
lcd
.
init
();
Serial
.
begin
(
9600
);
// for debugging
// start the relevant libraries used by temperature.cpp
// start the relevant libraries used by temperature.cpp
temperatureBegin
();
temperatureBegin
();
// start the mp3 library
mp3Setup
();
mp3Setup
();
// the pumps
pinMode
(
PUMP1
,
OUTPUT
);
pinMode
(
PUMP1
,
OUTPUT
);
pinMode
(
PUMP2
,
OUTPUT
);
pinMode
(
PUMP2
,
OUTPUT
);
// the button
pinMode
(
BUTTON
,
INPUT_PULLUP
);
pinMode
(
BUTTON
,
INPUT_PULLUP
);
}
}
// say out all the relevant infos via the loudspeaker
// say out all the relevant infos via the loudspeaker
void
sayInfos
(
float
temp1up
,
float
temp1down
,
float
temp2up
,
float
temp2down
)
void
sayInfos
(
float
temp1up
,
float
temp1down
,
float
temp2up
,
float
temp2down
)
{
{
const
uint8_t
decimals
=
0
;
const
uint8_t
decimals
=
0
;
// system 1
playFileQueue
(
SOUND_EINS
);
playFileQueue
(
SOUND_EINS
);
// up temperature
playFileQueue
(
SOUND_OBEN
);
playFileQueue
(
SOUND_OBEN
);
// say the number
sayNumber
(
temp1up
,
decimals
);
sayNumber
(
temp1up
,
decimals
);
// wait a bit
playFileQueue
(
SOUND_STILLE
);
playFileQueue
(
SOUND_STILLE
);
playFileQueue
(
SOUND_EINS
);
playFileQueue
(
SOUND_EINS
);
...
@@ -184,6 +188,15 @@ void sayInfos(float temp1up, float temp1down, float temp2up, float temp2down)
...
@@ -184,6 +188,15 @@ void sayInfos(float temp1up, float temp1down, float temp2up, float temp2down)
sayNumber
(
temp1down
,
decimals
);
sayNumber
(
temp1down
,
decimals
);
playFileQueue
(
SOUND_STILLE
);
playFileQueue
(
SOUND_STILLE
);
playFileQueue
(
SOUND_PUMPE
);
playFileQueue
(
SOUND_EINS
);
if
(
digitalRead
(
PUMP1
))
{
playFileQueue
(
SOUND_AN
);
}
else
{
playFileQueue
(
SOUND_AUS
);
}
playFileQueue
(
SOUND_STILLE
);
playFileQueue
(
SOUND_ZWEI
);
playFileQueue
(
SOUND_ZWEI
);
playFileQueue
(
SOUND_OBEN
);
playFileQueue
(
SOUND_OBEN
);
sayNumber
(
temp2up
,
decimals
);
sayNumber
(
temp2up
,
decimals
);
...
@@ -194,34 +207,12 @@ void sayInfos(float temp1up, float temp1down, float temp2up, float temp2down)
...
@@ -194,34 +207,12 @@ void sayInfos(float temp1up, float temp1down, float temp2up, float temp2down)
sayNumber
(
temp2down
,
decimals
);
sayNumber
(
temp2down
,
decimals
);
playFileQueue
(
SOUND_STILLE
);
playFileQueue
(
SOUND_STILLE
);
if
(
digitalRead
(
PUMP1
))
{
playFileQueue
(
SOUND_PUMPE
);
playFileQueue
(
SOUND_EINS
);
playFileQueue
(
SOUND_AN
);
playFileQueue
(
SOUND_STILLE
);
}
else
{
playFileQueue
(
SOUND_PUMPE
);
playFileQueue
(
SOUND_EINS
);
playFileQueue
(
SOUND_AUS
);
playFileQueue
(
SOUND_STILLE
);
}
if
(
digitalRead
(
PUMP2
))
{
playFileQueue
(
SOUND_PUMPE
);
playFileQueue
(
SOUND_PUMPE
);
playFileQueue
(
SOUND_ZWEI
);
playFileQueue
(
SOUND_ZWEI
);
if
(
digitalRead
(
PUMP2
))
{
playFileQueue
(
SOUND_AN
);
playFileQueue
(
SOUND_AN
);
playFileQueue
(
SOUND_STILLE
);
}
else
{
}
else
{
playFileQueue
(
SOUND_PUMPE
);
playFileQueue
(
SOUND_ZWEI
);
playFileQueue
(
SOUND_AUS
);
playFileQueue
(
SOUND_AUS
);
playFileQueue
(
SOUND_STILLE
);
}
}
}
}
...
@@ -247,21 +238,34 @@ void loop(void) {
...
@@ -247,21 +238,34 @@ void loop(void) {
displayLight
(
false
);
displayLight
(
false
);
}
}
if
(
t1up
(
&
t1up_C
)
==
LONG_TIME_ERROR
||
t1down
(
&
t1down_C
)
==
LONG_TIME_ERROR
)
{
// update the temperatures
// TODO: Warning sound
UPDATESTATE
t1upState
=
t1up
(
&
t1up_C
);
UPDATESTATE
t1downState
=
t1down
(
&
t1down_C
);
UPDATESTATE
t2upState
=
t2up
(
&
t2up_C
);
UPDATESTATE
t2downState
=
t2down
(
&
t2down_C
);
if
(
t1upState
==
LONG_TIME_ERROR
||
t1downState
==
LONG_TIME_ERROR
||
t2upState
==
LONG_TIME_ERROR
||
t2downState
==
LONG_TIME_ERROR
)
{
// continuously say that there is an error
playFile
(
SOUND_FEHLER
,
true
);
}
// control pump of system 1
if
(
t1upState
==
LONG_TIME_ERROR
||
t1downState
==
LONG_TIME_ERROR
)
{
// Turn pump on to be safe
// Turn pump on to be safe
digitalWrite
(
PUMP1
,
HIGH
);
digitalWrite
(
PUMP1
,
HIGH
);
}
else
{
}
else
{
// no errors => control pump according to the temperatures
controlPump
(
PUMP1
,
t1up_C
,
t1down_C
);
controlPump
(
PUMP1
,
t1up_C
,
t1down_C
);
}
}
if
(
t2up
(
&
t2up_C
)
==
LONG_TIME_ERROR
||
t2down
(
&
t2down_C
)
==
LONG_TIME_ERROR
)
{
//
TODO: Warning sound
//
same for system 2
// Turn pump on to be safe
if
(
t2upState
==
LONG_TIME_ERROR
||
t2downState
==
LONG_TIME_ERROR
)
{
digitalWrite
(
PUMP2
,
HIGH
);
digitalWrite
(
PUMP2
,
HIGH
);
}
else
{
}
else
{
controlPump
(
PUMP2
,
t2up_C
,
t2down_C
);
controlPump
(
PUMP2
,
t2up_C
,
t2down_C
);
}
}
displayText
(
t1up_C
,
t1down_C
,
digitalRead
(
PUMP1
),
t1up_C
,
t2down_C
,
digitalRead
(
PUMP2
),
// write the infos to the display
t1up
(
&
t1up_C
),
t1down
(
&
t1down_C
),
t2up
(
&
t2up_C
),
t2down
(
&
t2down_C
));
displayText
(
t1up_C
,
t1down_C
,
digitalRead
(
PUMP1
),
t2up_C
,
t2down_C
,
digitalRead
(
PUMP2
),
t1upState
,
t1downState
,
t2upState
,
t2downState
);
}
}
This diff is collapsed.
Click to expand it.
solarpump/temperature.ino
+
0
−
1
View file @
7097c0fb
#include
<stdint.h>
#include
"pins.h"
#include
"pins.h"
#include
<OneWire.h>
#include
<OneWire.h>
#include
<DallasTemperature.h>
#include
<DallasTemperature.h>
...
...
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