Skip to content
Snippets Groups Projects
Commit f74f66a2 authored by Pico3's avatar Pico3
Browse files

Shutterschulter made to work.

parent dbf4532c
Branches Sprint/2020-12
Tags
1 merge request!2Shutter rework
......@@ -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(shutterFundamentalPin, OUTPUT);
pinMode(LEDFundamentalPin, OUTPUT);
pinMode(shutterSHGPin, OUTPUT);
pinMode(LEDSHGPin, OUTPUT);
pinMode(fundamentalShutterPin, OUTPUT);
pinMode(fundamentalLedPin, OUTPUT);
pinMode(shgShutterPin, OUTPUT);
pinMode(shgLedPin, OUTPUT);
lcd.begin(16, 2);
//lcd.noCursor(); // hide the cursor
lcd.print("Fundamental CLOSE");
lcd.print("Fund CLOSED");
lcd.setCursor(0, 1);
lcd.print("SHG CLOSE");
lcd.print("SHG CLOSED");
}
......@@ -57,18 +61,24 @@ void loop(){
break;
case 's': // Read the shutters
Serial.print("FUND ");
if ( shutterFundamental == HIGH)
if ( fundamentalShutter == HIGH)
Serial.print("1");
else
Serial.print("0");
Serial.print("\t");
Serial.print("SHG ");
if ( shutterSHG == HIGH)
if ( shgShutter == 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(shutterFundamentalPin);
if (voltage > HighLimit && shutterFundamental == LOW){
shutterFundamental = HIGH;
digitalWrite(shutterFundamentalPin, HIGH);
lcd.setCursor(0, 11);
fundamentalSwitch = analogRead(fundamentalSwitchPin);
if (fundamentalSwitch > HighLimit && fundamentalShutter == LOW){
fundamentalShutter = HIGH;
digitalWrite(fundamentalShutterPin, HIGH);
lcd.setCursor(5, 0);
lcd.print("OPEN ");
}
else if (voltage < HighLimit && shutterFundamental == HIGH){
shutterFundamental = LOW;
digitalWrite(shutterFundamentalPin, LOW);
lcd.setCursor(0, 11);
lcd.print("CLOSE");
else if (fundamentalSwitch < HighLimit && fundamentalShutter == HIGH){
fundamentalShutter = LOW;
digitalWrite(fundamentalShutterPin, LOW);
lcd.setCursor(5, 0);
lcd.print("CLOSED");
}
// Do shutter control SHG
voltage = analogRead(shutterSHGPin);
if (voltage > HighLimit && shutterSHG == LOW){
shutterSHG = HIGH;
digitalWrite(shutterSHGPin, HIGH);
lcd.setCursor(1, 11);
shgSwitch = analogRead(shgSwitchPin);
if (shgSwitch > HighLimit && shgShutter == LOW){
shgShutter = HIGH;
digitalWrite(shgShutterPin, HIGH);
lcd.setCursor(5, 1);
lcd.print("OPEN ");
}
else if (voltage < HighLimit && shutterSHG == HIGH){
shutterSHG = LOW;
digitalWrite(shutterSHGPin, LOW);
lcd.setCursor(1, 11);
lcd.print("CLOSE");
else if (shgSwitch < HighLimit && shgShutter == HIGH){
shgShutter = LOW;
digitalWrite(shgShutterPin, LOW);
lcd.setCursor(5, 1);
lcd.print("CLOSED");
}
// 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 ");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment