1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115
| /* // Système de minuterie, inventé pour desactiver des changements de file
sur slot pour éviter des accidents. les bp sont en réalité des interrupteurs ILS REED.
*/
// constants won't change. They're used here to set pin numbers:
const int bpPin5 = 3; // the number of the pushbutton pin
const int relayPin5 = 9; // the number of the relay pin
const int bpPin4 = 4;// the number of the pushbutton pin
const int relayPin4 = 10; // the number of the relay pin
const int bpPin3 = 5; // the number of the pushbutton pin
const int relayPin3 = 11; // the number of the relay pin
const int bpPin2 = 6; // the number of the pushbutton pin
const int relayPin2 = 12; // the number of the relay pin
const int bpPin1 = 7;// the number of the pushbutton pin
const int relayPin1 = 13; // the number of the relay pin
// variables will change:
int bp1 = 0; // variable for reading the pushbutton status
long int topDepart1=0;
int bp2 = 0; // variable for reading the pushbutton status
long int topDepart2=0;
int bp3 = 0; // variable for reading the pushbutton status
long int topDepart3=0;
int bp4 = 0; // variable for reading the pushbutton status
long int topDepart4=0;
int bp5 = 0; // variable for reading the pushbutton status
long int topDepart5=0;
void setup() {
// sortie relay:
pinMode(relayPin1, OUTPUT);
// entrée bp:
pinMode(bpPin1, INPUT);
// sortie relay:
pinMode(relayPin2, OUTPUT);
// entrée bp:
pinMode(bpPin2, INPUT);
// sortie relay:
pinMode(relayPin3, OUTPUT);
// entrée bp:
pinMode(bpPin3, INPUT);
// sortie relay:
pinMode(relayPin4, OUTPUT);
// entrée bp:
pinMode(bpPin4, INPUT);
// sortie relay:
pinMode(relayPin5, OUTPUT);
// entrée bp:
pinMode(bpPin5, INPUT);
}
void loop() {
bp1 = digitalRead(bpPin1);
if (bp1){ // si bouton appuyé
digitalWrite(relayPin1, HIGH); // activer le relais
topDepart1=millis();
}
if ((millis()-topDepart1)>=2000 && digitalRead(relayPin1)){ // si temps écoulé et relais actif
digitalWrite(relayPin1, LOW);
}
bp2 = digitalRead(bpPin2);
if (bp2){ // si bouton appuyé
digitalWrite(relayPin2, HIGH); // activer le relais
topDepart2=millis();
}
if ((millis()-topDepart2)>=800 && digitalRead(relayPin2)){ // si temps écoulé et relais actif
digitalWrite(relayPin2, LOW);
}
bp3 = digitalRead(bpPin3);
if (bp3){ // si bouton appuyé
digitalWrite(relayPin3, HIGH); // activer le relais
topDepart3=millis();
}
if ((millis()-topDepart3)>=800 && digitalRead(relayPin3)){ // si temps écoulé et relais actif
digitalWrite(relayPin3, LOW);
}
bp4 = digitalRead(bpPin4);
if (bp4){ // si bouton appuyé
digitalWrite(relayPin4, HIGH); // activer le relais
topDepart4=millis();
}
if ((millis()-topDepart4)>=800 && digitalRead(relayPin4)){ // si temps écoulé et relais actif
digitalWrite(relayPin4, LOW);
}
bp5 = digitalRead(bpPin5);
if (bp5){ // si bouton appuyé
digitalWrite(relayPin5, HIGH); // activer le relais
topDepart5=millis();
}
if ((millis()-topDepart5)>=800 && digitalRead(relayPin5)){ // si temps écoulé et relais actif
digitalWrite(relayPin5, LOW);
}
} |