Hi all.
I require help on a build project im doing.
Its basically a copy of a clamshell observatory that someone made in Germany. He has been very helpful in sharing his files and software, but I have run into some issues and the translation process is quite hard between us, so i could use some assistance.
when i run the program it seems a little erratic and not doing what it should be doing.
I have included a picture. i have a video explaing everything, but unsure on how to upload it here to help.
the code is a direct copy from him and his dome works, so unsure where i have gone wrong. ![]()
This is the code iv got if it helps?
p.s. i know i wrote down and previously had the buttons on 5v, that has now been changed to GND.
Drop box link to the video
/*----------------------------------------------------
Dome Steurung via Button oder RCCIASCOM
Engelbert Vollmer
2025 02 02 nach Anschluss der Motoren
*/
String serialin; //incoming serial data
String str; //store the state of opened/closed/pins
//relays
#define close 2 // PIN_BUTTON_DOWN
#define open 3 // PIN_BUTTON_UP
//input sensors
#define openedUS 4 // roof open sensor UppSegOpened
#define closedUS 5 // roof closed sensor UppSegClosed
#define openedLS 7 // roof open sensor LowSegOpened
#define closedLS 6 // roof closed sensor LowSegClosed
int motor1pin1 = 10;
int motor1pin2 = 11;
int motor2pin1 = 12;
int motor2pin2 = 13;
String StatusUS;
String StatusLS;
void setup() {
//Begin Serial Comunication(configured for 9600baud)
Serial.begin(9600);
//pin relay as OUTPUT
pinMode(motor1pin1, OUTPUT);
pinMode(motor1pin2, OUTPUT);
pinMode(motor2pin1, OUTPUT);
pinMode(motor2pin2, OUTPUT);
//pins as INPUT
pinMode(open, INPUT_PULLUP);
pinMode(close, INPUT_PULLUP);
pinMode(closedUS, INPUT_PULLUP);
pinMode(openedUS, INPUT_PULLUP);
pinMode(closedLS, INPUT_PULLUP);
pinMode(openedLS, INPUT_PULLUP);
//Initialize Output states
digitalWrite(open, LOW);
digitalWrite(close, LOW);
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
Serial.write("RRCI#"); //init string
}
void loop() {
Operate_Dome_By_Button();
Operate_Dome_by_RCCI();
}
//---------------------------------------------------------------
// Operate by Button
//---------------------------------------------------------------
void Operate_Dome_By_Button() {
// --------------- Close Dome ----------------
if (digitalRead(close) == HIGH && digitalRead(open) == LOW) {
//Both Segments
while (digitalRead(close) == HIGH && digitalRead(closedUS) == LOW && digitalRead(closedLS) == LOW) {
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
}
Stopp_Motors();
//Upper Segment if Lower Segment is closed before
while (digitalRead(close) == HIGH && digitalRead(closedUS) == LOW) {
digitalWrite(motor1pin1, HIGH);
digitalWrite(motor1pin2, LOW);
}
Stopp_MotorsUS();
//Lower Segment if Upper Segment is closed before
while (digitalRead(close) == HIGH && digitalRead(closedLS) == LOW) {
digitalWrite(motor2pin1, HIGH);
digitalWrite(motor2pin2, LOW);
}
Stopp_MotorsLS();
}
// --------------- Open Dome --------------------------
if (digitalRead(open) == HIGH && digitalRead(close) == LOW) {
//Both Segments
while (digitalRead(open) == HIGH && digitalRead(openedUS) == HIGH && digitalRead(openedLS) == HIGH) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, HIGH);
}
Stopp_Motors();
//Upper Segment if Lower Segment is opened before
while (digitalRead(open) == HIGH && digitalRead(openedUS) == HIGH) {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, HIGH);
}
Stopp_MotorsUS();
//Lower Segment if Upper Segment is opened before
while (digitalRead(open) == HIGH && digitalRead(openedLS) == HIGH) {
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, HIGH);
}
Stopp_MotorsLS();
}
}
//----------------------------------------------------------------------------
// Operate via ASCOM
//----------------------------------------------------------------------------
void Operate_Dome_by_RCCI() {
//Verify connection by serial
while (Serial.available() > 0) {
//Read Serial data and alocate on serialin
serialin = Serial.readStringUntil('#');
if (serialin == "y") {
Stopp_Motors();
} else if (serialin == "open") {
digitalWrite(motor1pin1, LOW); //Upper Segment
digitalWrite(motor1pin2, HIGH);
digitalWrite(motor2pin1, LOW); // Lower Segmenet
digitalWrite(motor2pin2, HIGH);
StatusUS = "opening";
StatusLS = "opening";
}
if (serialin == "y") {
Stopp_Motors();
} else if (serialin == "close") {
digitalWrite(motor1pin1, HIGH); //Upper Segment
digitalWrite(motor1pin2, LOW);
digitalWrite(motor2pin1, HIGH); // Lower Segmene
digitalWrite(motor2pin2, LOW);
StatusUS = "closing";
StatusLS = "closing";
}
}
if (digitalRead(closedUS) == HIGH && StatusUS == "closing") { Stopp_MotorsUS(); }
if (digitalRead(closedLS) == HIGH && StatusLS == "closing") { Stopp_MotorsLS(); }
if (digitalRead(openedUS) == LOW && StatusUS == "opening") { Stopp_MotorsUS(); }
if (digitalRead(openedLS) == LOW && StatusLS == "opening") { Stopp_MotorsLS(); }
if (serialin == "Parkstatus") { // external query command to fetch RRCI data
Serial.println("0#");
serialin = "";
}
if (serialin == "get") { // external query command to fetch RRCI data - Two Pipelines(||) to make a boolean OR Comparission
if ((digitalRead(closedUS) == HIGH && digitalRead(openedUS) == HIGH) && (digitalRead(closedLS) == HIGH && digitalRead(openedLS) == HIGH)) { str += "closed,not_moving_o#"; }
if ((digitalRead(closedUS) == LOW && digitalRead(openedUS) == LOW) || (digitalRead(closedLS) == LOW && digitalRead(openedLS) == LOW)) { str += "opened,not_moving_c#"; }
//if ((digitalRead(openedUS) == LOW && digitalRead(closedUS) == LOW) && (digitalRead(openedLS) == LOW && digitalRead(closedLS) == LOW)) {str += "opened,not_moving_c#";}
// if ((digitalRead(closedUS) == HIGH && digitalRead(openedUS) == HIGH) || (digitalRead(closedLS) == HIGH && digitalRead(openedLS) == HIGH)) {}
Serial.println(str); //send serial data
serialin = "";
str = "";
}
if (serialin == "Status") { Serial.println("RoofOpen#"); }
serialin = "";
//str = "";
}
//--------------------------
// Motor stop
//--------------------------
void Stopp_Motors() {
Stopp_MotorsUS();
Stopp_MotorsLS();
}
void Stopp_MotorsUS() {
digitalWrite(motor1pin1, LOW);
digitalWrite(motor1pin2, LOW);
StatusUS = "";
}
void Stopp_MotorsLS() {
digitalWrite(motor2pin1, LOW);
digitalWrite(motor2pin2, LOW);
StatusLS = "";
}
//--------------------------
// Status of Button during tests
//--------------------------
void Print_Schalter_Status() {
Serial.print("UpSegCl UpSeg Op LoSegCl LoSegOp ButCl ButOp...");
Serial.print(digitalRead(closedUS));
Serial.print("..");
Serial.print(digitalRead(openedUS));
Serial.print("..");
Serial.print(digitalRead(closedLS));
Serial.print("..");
Serial.print(digitalRead(openedLS));
Serial.print("..");
Serial.print(digitalRead(close));
Serial.print("..");
Serial.println(digitalRead(open));
delay(5000);
}




