Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Arduino Sketches
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
NLOQO
Arduino Sketches
Commits
f74f66a2
Commit
f74f66a2
authored
2 years ago
by
Pico3
Browse files
Options
Downloads
Patches
Plain Diff
Shutterschulter made to work.
parent
dbf4532c
Branches
Sprint/2020-12
Branches containing commit
Tags
Tags containing commit
1 merge request
!2
Shutter rework
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
Shutterschalter/Shutterschalter.ino
+62
-37
62 additions, 37 deletions
Shutterschalter/Shutterschalter.ino
with
62 additions
and
37 deletions
Shutterschalter/Shutterschalter.ino
+
62
−
37
View file @
f74f66a2
...
...
@@ -11,19 +11,23 @@ const String version = "Shutterschalter 0.1"; // Version of this script
LiquidCrystal
lcd
(
2
,
3
,
4
,
5
,
6
,
7
);
//Initialize LCD Lib for our application //the numbers are the Digital Pins, which are used for the LCD
// PINs
const
int
shutterFundamentalPin
=
A0
;
const
int
LEDFundamentalPin
=
A1
;
const
int
shutterSHGPin
=
9
;
const
int
LEDSHGPin
=
8
;
const
int
fundamentalSwitchPin
=
6
;
const
int
fundamentalShutterPin
=
A0
;
const
int
fundamentalLedPin
=
A1
;
const
int
shgSwitchPin
=
7
;
const
int
shgShutterPin
=
9
;
const
int
shgLedPin
=
8
;
// Constants
const
int
HighLimit
=
850
;
// State variables
int
shutterFundamental
=
LOW
;
int
shutterSHG
=
LOW
;
int
fundamentalShutter
=
LOW
;
int
shgShutter
=
LOW
;
bool
emergency
=
false
;
int
voltage
;
// temporal readout
int
fundamentalSwitch
=
LOW
;
int
shgSwitch
=
LOW
;
void
setup
(){
...
...
@@ -31,16 +35,16 @@ void setup(){
Serial
.
begin
(
9600
);
// Setup pins
pinMode
(
shutterF
undamentalPin
,
OUTPUT
);
pinMode
(
LEDF
undamentalPin
,
OUTPUT
);
pinMode
(
shutter
SHG
Pin
,
OUTPUT
);
pinMode
(
LEDSHG
Pin
,
OUTPUT
);
pinMode
(
f
undamental
Shutter
Pin
,
OUTPUT
);
pinMode
(
f
undamental
Led
Pin
,
OUTPUT
);
pinMode
(
sh
gSh
utterPin
,
OUTPUT
);
pinMode
(
shgLed
Pin
,
OUTPUT
);
lcd
.
begin
(
16
,
2
);
//lcd.noCursor(); // hide the cursor
lcd
.
print
(
"Fund
amental
CLOSE"
);
lcd
.
print
(
"Fund CLOSE
D
"
);
lcd
.
setCursor
(
0
,
1
);
lcd
.
print
(
"SHG
CLOSE"
);
lcd
.
print
(
"SHG CLOSE
D
"
);
}
...
...
@@ -57,18 +61,24 @@ void loop(){
break
;
case
's'
:
// Read the shutters
Serial
.
print
(
"FUND "
);
if
(
shutterF
undamental
==
HIGH
)
if
(
f
undamental
Shutter
==
HIGH
)
Serial
.
print
(
"1"
);
else
Serial
.
print
(
"0"
);
Serial
.
print
(
"
\t
"
);
Serial
.
print
(
"SHG "
);
if
(
shutter
SHG
==
HIGH
)
if
(
sh
gSh
utter
==
HIGH
)
Serial
.
print
(
"1"
);
else
Serial
.
print
(
"0"
);
Serial
.
println
();
break
;
case
'l'
:
// list valaues
Serial
.
print
(
fundamentalSwitch
);
Serial
.
print
(
"
\t
"
);
Serial
.
print
(
shgSwitch
);
Serial
.
println
();
break
;
case
'd'
:
// debug
Serial
.
println
(
"Debug"
);
break
;
...
...
@@ -79,33 +89,48 @@ void loop(){
}
// Do shutter control Fundamental
voltage
=
analogRead
(
shutterF
undamentalPin
);
if
(
voltage
>
HighLimit
&&
shutterF
undamental
==
LOW
){
shutterF
undamental
=
HIGH
;
digitalWrite
(
shutterF
undamentalPin
,
HIGH
);
lcd
.
setCursor
(
0
,
11
);
fundamentalSwitch
=
analogRead
(
f
undamental
Switch
Pin
);
if
(
fundamentalSwitch
>
HighLimit
&&
f
undamental
Shutter
==
LOW
){
f
undamental
Shutter
=
HIGH
;
digitalWrite
(
f
undamental
Shutter
Pin
,
HIGH
);
lcd
.
setCursor
(
5
,
0
);
lcd
.
print
(
"OPEN "
);
}
else
if
(
voltage
<
HighLimit
&&
shutterF
undamental
==
HIGH
){
shutterF
undamental
=
LOW
;
digitalWrite
(
shutterF
undamentalPin
,
LOW
);
lcd
.
setCursor
(
0
,
11
);
lcd
.
print
(
"CLOSE"
);
else
if
(
fundamentalSwitch
<
HighLimit
&&
f
undamental
Shutter
==
HIGH
){
f
undamental
Shutter
=
LOW
;
digitalWrite
(
f
undamental
Shutter
Pin
,
LOW
);
lcd
.
setCursor
(
5
,
0
);
lcd
.
print
(
"CLOSE
D
"
);
}
// Do shutter control SHG
voltage
=
analogRead
(
sh
utterSHG
Pin
);
if
(
voltage
>
HighLimit
&&
shutter
SHG
==
LOW
){
shutter
SHG
=
HIGH
;
digitalWrite
(
shutter
SHG
Pin
,
HIGH
);
lcd
.
setCursor
(
1
,
1
1
);
shgSwitch
=
analogRead
(
sh
gSwitch
Pin
);
if
(
shgSwitch
>
HighLimit
&&
sh
gSh
utter
==
LOW
){
sh
gSh
utter
=
HIGH
;
digitalWrite
(
sh
gSh
utterPin
,
HIGH
);
lcd
.
setCursor
(
5
,
1
);
lcd
.
print
(
"OPEN "
);
}
else
if
(
voltage
<
HighLimit
&&
shutter
SHG
==
HIGH
){
shutter
SHG
=
LOW
;
digitalWrite
(
shutter
SHG
Pin
,
LOW
);
lcd
.
setCursor
(
1
,
1
1
);
lcd
.
print
(
"CLOSE"
);
else
if
(
shgSwitch
<
HighLimit
&&
sh
gSh
utter
==
HIGH
){
sh
gSh
utter
=
LOW
;
digitalWrite
(
sh
gSh
utterPin
,
LOW
);
lcd
.
setCursor
(
5
,
1
);
lcd
.
print
(
"CLOSE
D
"
);
}
// Show emergency off
if
(
shgSwitch
<
10
and
!
emergency
){
emergency
=
true
;
lcd
.
setCursor
(
5
,
0
);
lcd
.
print
(
"EMERGENCY"
);
lcd
.
setCursor
(
5
,
1
);
lcd
.
print
(
"EMERGENCY"
);
}
else
if
(
shgSwitch
>
10
and
emergency
){
emergency
=
false
;
lcd
.
setCursor
(
5
,
0
);
lcd
.
print
(
"CLOSED "
);
lcd
.
setCursor
(
5
,
1
);
lcd
.
print
(
"CLOSED "
);
}
}
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