Greetings All!
I posted on this a long time ago but never got the issue resolved. I’m retired now (disability
) so needless to say, I have the time to finish it now.
PROJECT:
I designed and built a circuit board, namely the MASTER, which has a battery backup, three (3) relays, and an RGB LED to show the status of the door. It communicates via Bluetooth (HC05 Modules), Two (2) ports to plug super bright external LED’s into (to illuminate the garage), and a port for a reed switch.
The second circuit board, the SLAVE, has the push button that sends the signal to the master. The garage door then opens (or closes) based on the button press. Everything on the master side is working just fine. When I press the button at the slave, the signal is received by the master, then the relay closes for as long as the button is pressed, then opens again. When the relay closes, it jumps two wires which control an old wireless opener that I found. Yes, I’m replacing this as we speak. Instead, the relay will jump 2 wires together at the main garage door opener switch, eliminating the need for the wireless opener.
PROBLEM:
When the garage door is closed, the LED’s on both the master and slave should be green. This is true at the master. When the button at the slave is pressed, the LED’s should turn blue for as long as the button is pressed, once the button is released, the LED’s turn red indicating that the garage door is open. The problem is at the slave, the LED is always red unless I press the button, at which time it turns blue. But when I release the button the LED stays red, which I guess is what it’s supposed to do. But when the garage door closes (the reed switch comes together), the LED at the slave stays red. Thank you all!!! ![]()
MASTER CODE:
// MASTER
#include <TimerOne.h>
#include <SoftwareSerial.h>
#define pirPin 3
#define redLed 6
#define greenLed 9
#define blueLed 10
#define GarSwitch 4
#define GarRelay1 5
#define GarRelay2 11
#define Fan 12
#define ldrPin A0
#define tempPin A1
int garageState = 0;
int lastGarageState = 0;
int pirVal;
int LDRValue = 0;
int Vo;
float R1 = 100000;
float logR2, R2, Tk, Tc, Tf;
float c1 = 6.66082410500E-004, c2 = 2.23928204100E-004, c3 = 7.19951882000E-008;
// float c1 = -43.59859009, c2 = 216.0129802, c3 = -2282.277160;
char ch;
String HC05_Awake = "ON";
SoftwareSerial mySerial(7, 8); // Rx | Tx
void setup() {
Timer1.initialize(40000000);
Timer1.attachInterrupt(KeepAlive);
Serial.begin(115200);
mySerial.begin(38400);
mySerial.print('a');
pinMode(GarSwitch, INPUT_PULLUP);
lastGarageState = digitalRead(GarSwitch);
pinMode(GarRelay1, OUTPUT);
pinMode(GarRelay2, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
pinMode(Fan, OUTPUT);
pinMode(ldrPin, INPUT);
pinMode(pirPin, INPUT);
pinMode(tempPin, INPUT);
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, HIGH);
digitalWrite(blueLed, HIGH);
digitalWrite(GarRelay1, LOW);
digitalWrite(GarRelay2, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(Fan, LOW);
}
int counter;
void loop() {
// Sending
// read input once
garageState = digitalRead(GarSwitch); // LOW = pressed
if (garageState != lastGarageState) {
mySerial.print('a');
if (garageState == LOW) { // switch got pressed
Serial.print(counter);
counter++;
Serial.println(" Print an 'a'");
mySerial.print('a');
digitalWrite(blueLed, HIGH);
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
} else { // switch got released
Serial.print(counter);
counter++;
Serial.println(" Print a 'c'");
mySerial.print('c');
digitalWrite(blueLed, HIGH);
digitalWrite(greenLed, HIGH);
digitalWrite(redLed, LOW);
}
}
MotionDetection();
Temperature();
// LDR();
// Receiving
if (mySerial.available()) {
char ch = mySerial.read();
Serial.write(ch);
if (ch == 'b') {
Serial.print(counter);
counter++;
Serial.println(" Print a 'b'");
mySerial.print('b');
digitalWrite(GarRelay1, LOW);
digitalWrite(blueLed, LOW);
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, HIGH);
delay(1000);
} else if (ch == 'd') {
Serial.print(counter);
counter++;
Serial.println(" Print a 'd'");
mySerial.print('d');
digitalWrite(blueLed, HIGH);
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(GarRelay1, HIGH);
}
}
lastGarageState = garageState;
delay(20); // poor man's debouncing
}
void KeepAlive() {
if (HC05_Awake = "ON") {
mySerial.print('m');
Serial.print('m');
}
}
// void LDR() {
// LDRValue = analogRead(ldrPin);
// Serial.print("Light Value - ");
// Serial.println(LDRValue);
// // delay(1000;)
// }
void MotionDetection() {
pirVal = digitalRead(pirPin);
if (pirVal == LOW) {
//Serial.println("No Motion");
digitalWrite(GarRelay1, LOW);
digitalWrite(GarRelay2, LOW);
} else {
digitalWrite(GarRelay1, HIGH);
digitalWrite(GarRelay2, HIGH);
//Serial.println("MOTION!!");
}
}
void Temperature() {
Vo = analogRead(tempPin);
// NTC THERMISTOR
R2 = R1 / (1023.0 / (float)Vo - 1.0);
// PTC THERMISTOR
// R2 = R1 * (1023.0 / (float)Vo - 1.0);
logR2 = log(R2);
Tk = (1.0 / (c1 + c2 * logR2 + c3 * logR2 * logR2 * logR2));
Tc = Tk - 273.15;
Tf = (Tc * 9.0) / 5.0 + 32.0;
if (Tf >= 100.0) {
digitalWrite(Fan, HIGH);
} else {
digitalWrite(Fan, LOW);
}
// Serial.print("Temperature: ");
// Serial.print(Tf);
// Serial.println(" F");
// delay(1000);
}
//delay(1000);
SLAVE CODE:
// SLAVE
# include <SoftwareSerial.h>
SoftwareSerial mySerial(7, 8); // Rx | Tx
# define redLed 6
# define greenLed 5
# define blueLed 10
# define Button 3
// # define pwrLed 9
char ch;
int buttonState = 0;
int lastButtonState = 0;
int counter;
void setup() {
Serial.begin(115200);
mySerial.begin(38400);
// pinMode(pwrLed, OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(blueLed, OUTPUT);
pinMode(Button, INPUT_PULLUP);
// digitalWrite(greenLed, LOW);
// digitalWrite(redLed, LOW);
// digitalWrite(blueLed, LOW);
// analogWrite(pwrLed, 3);
}
void loop() {
// read input once
buttonState = digitalRead(Button); // LOW = pressed
if (buttonState != lastButtonState) {
mySerial.print('a');
if (buttonState == LOW) { // switch got pressed
Serial.print(counter);
counter++;
Serial.println(" Print a 'b'");
mySerial.print('b');
digitalWrite(blueLed, LOW);
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, HIGH);
} else { // switch got released
Serial.print(counter);
counter++;
Serial.print(" Print a 'd'");
mySerial.print('d');
digitalWrite(blueLed, HIGH);
digitalWrite(greenLed, LOW);
digitalWrite(redLed, HIGH);
}
} //...
// Receiving
if (mySerial.available()) {
char ch = mySerial.read();
Serial.write(ch);
if (ch == 'a') {
Serial.print(counter);
counter++;
Serial.println(" Print an 'a'");
digitalWrite(redLed, LOW);
digitalWrite(greenLed, HIGH);
digitalWrite(blueLed, HIGH);
}
else if (ch == 'c') {
Serial.print(counter);
counter++;
Serial.println(" Print a 'c'");
mySerial.print('c');
digitalWrite(redLed, HIGH);
digitalWrite(greenLed, LOW);
digitalWrite(blueLed, HIGH);
}
}
lastButtonState = buttonState;
delay(20); // poor man's debouncing
}
I’ve also attached schematics for both. Please forgive me for my messy schematic but I’m still in the process of learning this. Thanks again.
Glenn
SCH_Garage-Door-Master-V-2.3.1_2025-10-21.json (91.6 KB)
SCH_Garage-Door-Opener-SLAVE-V-1.6.1_2025-10-21.json (45.1 KB)

