Bi-monthly release with minor bug fixes and improvements
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
/*Program to open the roof of my Observatory.
With 2 buttons Open,Close and an Emergency Stop.
With realy supply power
There are also 2 limit switches and a control as the telescope and of course the park position.*/
const int ledRepos = 3; // LedWaiting
const int RelaisOuverture1 = 4; // Open relay1
const int RelaisOuverture2 = 5; // Open relay2
const int RelaisFermeture1 = 6; // Close relay1
const int RelaisFermeture2 = 7; // Close relay2
const int BoutonOpen = A0; // Open button
const int BoutonClose = A1; // Close button
const int BoutonStop = A2; // Stop button
const int FinOuverture = 12; // limit switche Open
const int FinFermeture = 10; // limit switche Close
const int Telescope_Parc =2; // park position switche
const int BoutonRelais =A3; // Power supply control
const int pinRelais =8; // Power supply relay
int BoutonOpenState = 0;
int BoutonCloseState = 0;
int FinOuvertureState = 0;
int FinFermetureState = 0;
int Telescope_ParcState = 0;
int BoutonStopState = 0;
bool BoutonRelaisState = LOW;
//les états possible
enum {Repos, Ouverture, Ouvert, Fermeture, Fermer};
int etat = Repos;
bool estAlimente = false;
// le N° des connection et fonction
void setup() {
pinMode(ledRepos, OUTPUT); // LedWaiting
pinMode(RelaisOuverture1, OUTPUT);
pinMode(RelaisOuverture2, OUTPUT);
pinMode(RelaisFermeture1, OUTPUT);
pinMode(RelaisFermeture2, OUTPUT);
pinMode(BoutonOpen, INPUT_PULLUP);
pinMode(BoutonClose, INPUT_PULLUP);
pinMode(BoutonStop, INPUT_PULLUP);
pinMode(FinOuverture, INPUT_PULLUP);
pinMode(FinFermeture, INPUT_PULLUP);
pinMode(Telescope_Parc, INPUT_PULLUP);
}// fin setup
void position_toit () { // début des statuts pour le loop
switch (etat) { // début du switch avec les possibilté
case Repos:
digitalWrite(ledRepos, HIGH); // LedWaiting
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, LOW);
if (BoutonOpenState == LOW && Telescope_ParcState == LOW ) {
etat = Ouverture;
delay(30);
}
else if(BoutonCloseState == LOW && FinFermetureState == HIGH ){
etat = Fermeture;
delay(30);
}
break;
case Ouverture:
digitalWrite(ledRepos, LOW); // LedWaiting
digitalWrite(RelaisOuverture1, HIGH);
digitalWrite(RelaisOuverture2, HIGH);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, LOW);
if (FinOuvertureState == LOW) {
etat = Ouvert;
delay(30);
}
else if(Telescope_ParcState == HIGH || BoutonStopState == LOW) {
etat = Repos;
delay(30);
}
break;
case Ouvert:
digitalWrite(ledRepos, HIGH); // LedWaiting
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, LOW);
if (BoutonCloseState == LOW && Telescope_ParcState == LOW ) {
etat = Fermeture;
delay(30);
}
break;
case Fermeture:
digitalWrite(ledRepos, LOW); // LedWaiting
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, HIGH);
digitalWrite(RelaisFermeture2, HIGH);
if (FinFermetureState == LOW) {
etat = Fermer;
delay(30);
}
else if(Telescope_ParcState == HIGH || BoutonStopState == LOW) {
etat = Repos;
delay(30);
}
break;
case Fermer:
digitalWrite(ledRepos, LOW); // LedWaiting
digitalWrite(RelaisOuverture1, LOW);
digitalWrite(RelaisOuverture2, LOW);
digitalWrite(RelaisFermeture1, LOW);
digitalWrite(RelaisFermeture2, HIGH);
etat = Repos;
break;
} //fin switch
}// fin void
void loop() {
BoutonRelaisState = digitalRead (BoutonRelais) ;
if (BoutonRelaisState == HIGH) {
estAlimente = !estAlimente;
delay (30);
}
if (estAlimente) {
digitalWrite (pinRelais, HIGH);
// début du programme des fonctions
BoutonOpenState = digitalRead (BoutonOpen) ;
BoutonCloseState = digitalRead (BoutonClose) ;
FinOuvertureState = digitalRead (FinOuverture) ;
FinFermetureState = digitalRead (FinFermeture) ;
Telescope_ParcState = digitalRead (Telescope_Parc);
BoutonStopState = digitalRead (BoutonStop);
position_toit() ;
} else digitalWrite (pinRelais, LOW);
} // fin loop ou programme
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.