Initial commit
Should work just fine. Program was tested at the site, some code cleanup was done and some comments were added.
This commit is contained in:
commit
d710d92afe
3 changed files with 101 additions and 0 deletions
20
LICENSE
Normal file
20
LICENSE
Normal file
|
@ -0,0 +1,20 @@
|
|||
Copyright 2025 Dominic Reich <quick.hat4396@qtztsjosmprqmgtunjyf.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the “Software”), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||
of the Software, and to permit persons to whom the Software is furnished to do
|
||||
so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
8
README.md
Normal file
8
README.md
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Türkontrolle
|
||||
|
||||
This program will "convert" switches that press "buttons" for a
|
||||
second or longer into a switch that only presses a button for
|
||||
200ms long.
|
||||
|
||||
This was required for an bluetooth switch that did not like
|
||||
external switches pressing longer that neccessary.
|
73
tuerkontrolle.ino
Normal file
73
tuerkontrolle.ino
Normal file
|
@ -0,0 +1,73 @@
|
|||
/*******************************************************************************
|
||||
* Türkontrolle
|
||||
*
|
||||
* 2025-01-15 Reich D.
|
||||
*
|
||||
* Eingänge werden gegen GND gezogen
|
||||
* PIN GND
|
||||
* ├─ PIN 7 : AUF, PIN 3 wird auf 5V gesetzt (Relais 1 wird angezogen)
|
||||
* └─ PIN 8 : ZU, PIN 4 wird auf 5V gesetzt (Relais 2 wird angezogen)
|
||||
*
|
||||
* Die Relaisplatine wird konstant mit 12V versorgt (und auch der Arduino).
|
||||
* Die Eingänge IN1 und IN2 werden vom Arduino jeweils nach Abfrage der
|
||||
* Eingänge auf 5V gesetzt. Das jeweilige Relais schaltet den Bluetooth-
|
||||
* schalter für 200ms. Danach wird 5 Sekunden gewartet, damit der Bluetooth-
|
||||
* schalter nicht unnötig "gedrückt" wird.
|
||||
*
|
||||
*/
|
||||
|
||||
// Eingänge
|
||||
const int BUTTON_AUF_PIN = 7;
|
||||
const int BUTTON_ZU_PIN = 8;
|
||||
// Ausgänge
|
||||
const int RELAY_AUF_PIN = 3;
|
||||
const int RELAY_ZU_PIN = 4;
|
||||
|
||||
// Standardwerte
|
||||
const int BEGIN_DELAY = 100;
|
||||
const int BUTTON_DELAY = 200;
|
||||
const int DELAY = 4900;
|
||||
const int BAUD = 9600;
|
||||
|
||||
// Wir geben das Kompilierdatum auf der seriellen Schnittstelle beim Programmstart
|
||||
// aus. Damit kann man später besser einschätzen, welche Programmversion auf dem
|
||||
// Mikroprozessor läuft.
|
||||
const char compile_date[] = __DATE__ " " __TIME__;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(BAUD);
|
||||
delay(1000);
|
||||
Serial.print("Compiled on ");
|
||||
Serial.println(compile_date);
|
||||
pinMode(BUTTON_AUF_PIN, INPUT_PULLUP);
|
||||
pinMode(BUTTON_ZU_PIN, INPUT_PULLUP);
|
||||
pinMode(RELAY_AUF_PIN, OUTPUT);
|
||||
pinMode(RELAY_ZU_PIN, OUTPUT);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// 100ms warten damit wir keine falsche Eingabe an den
|
||||
// Eingängen erhalten
|
||||
delay(BEGIN_DELAY);
|
||||
|
||||
// Abfrage, ob ein "Knopf" gedrückt ist (am Türcodeschloss)
|
||||
int buttonAufState = digitalRead(BUTTON_AUF_PIN);
|
||||
int buttonZuState = digitalRead(BUTTON_ZU_PIN);
|
||||
|
||||
if(buttonZuState == LOW) {
|
||||
Serial.println("SCHLIESSEN AKTIVIERT");
|
||||
digitalWrite(RELAY_ZU_PIN, HIGH);
|
||||
delay(BUTTON_DELAY);
|
||||
digitalWrite(RELAY_ZU_PIN, LOW);
|
||||
Serial.println("SCHLIESSEN BEENDET - warte 5 Sekunden");
|
||||
delay(DELAY);
|
||||
} else
|
||||
if(buttonAufState == LOW) {
|
||||
Serial.println("OEFFNEN AKTIVIERT");
|
||||
digitalWrite(RELAY_AUF_PIN, HIGH);
|
||||
delay(BUTTON_DELAY);
|
||||
digitalWrite(RELAY_AUF_PIN, LOW);
|
||||
Serial.println("OEFFNEN BEENDET - warte 5 Sekunden");
|
||||
delay(DELAY);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue