Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int dataPin = 8; // Pin DS
- int storePin = 9; // Pin STCP
- int shiftPin = 10; // Pin SHCP
- int tag_nacht = 7;
- int schalter_3 = 11;
- int schalter_2 = 12;
- int schalter_1 = 13;
- int ah_rot = 2;
- int ah_gelb = 3;
- int ah_gruen = 4;
- int fan_rot = 5;
- int fan_gruen = 6;
- // Q0=AN-rot
- // Q7=AN-gelb
- // Q6=AN-gruen
- // Q5=AL-rot
- // Q4=AL-gelb
- // Q3=AL-gruen
- // Q2=FAH-rot
- // Q1=FAH-gruen
- int phase_1_13[8] = {0,0,1,0,0,1,0,1};
- int phase_4[8] = {0,0,1,1,0,1,0,1};
- int phase_5[8] = {0,0,0,0,1,1,0,1};
- int phase_6[8] = {0,0,0,1,0,1,0,1};
- int phase_7[8] = {1,0,1,0,0,1,0,1};
- int phase_8_10[8] = {0,1,1,0,0,1,0,0};
- int phase_9[8] = {0,1,1,0,0,0,1,0};
- int phase_11[8] = {1,0,1,0,0,1,0,0};
- int phase_12[8] = {0,0,1,0,0,1,0,1};
- int nachtphase_1[8] = {0,0,1,0,0,1,0,1};
- void setup() {
- pinMode(ah_rot,OUTPUT); //AH-rot
- pinMode(ah_gelb,OUTPUT); //AH-gelb
- pinMode(ah_gruen,OUTPUT); //AH-gruen
- pinMode(fan_rot,OUTPUT); //FAN-rot
- pinMode(fan_gruen,OUTPUT); //FAN-gruen
- pinMode(tag_nacht,INPUT); //Tag-Nacht
- pinMode(schalter_3,INPUT); //S3
- pinMode(schalter_2,INPUT); //S2
- pinMode(schalter_1,INPUT); //S1
- pinMode(shiftPin,OUTPUT); //SHCP
- pinMode(storePin,OUTPUT); //STCP
- pinMode(dataPin,OUTPUT); //DS
- digitalWrite(shiftPin,LOW);
- digitalWrite(storePin,LOW);
- digitalWrite(dataPin,LOW);
- }
- void loop() {
- digitalWrite(ah_rot,LOW);
- digitalWrite(ah_gelb,LOW);
- digitalWrite(ah_gruen,HIGH);
- digitalWrite(fan_rot,LOW);
- digitalWrite(fan_gruen,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_1_13[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- boolean wechsel = false;
- boolean nachtwechsel = false;
- boolean nachtwechsel_2 = false;
- int vergleich_schalter_1 = 0;
- int vergleich_schalter_2 = 0;
- int vergleich_schalter_3 = 0;
- int state_tag_nacht = 0;
- for (int x = 0; x<400; x++) {
- vergleich_schalter_1 = digitalRead(schalter_1);
- vergleich_schalter_2 = digitalRead(schalter_2);
- vergleich_schalter_3 = digitalRead(schalter_3);
- if (vergleich_schalter_1 == HIGH || vergleich_schalter_2 == HIGH) { //Prüft, ob S1, S2 oder S3 waehrend dieser Zeit gedrueckt wurde. Return: wechsel = true
- wechsel = true;
- nachtwechsel = true;
- }
- if (vergleich_schalter_3 == HIGH){
- wechsel = true;
- nachtwechsel_2 = true;
- }
- delay(50);
- }
- state_tag_nacht = digitalRead(tag_nacht);
- if (state_tag_nacht == LOW && wechsel == false) { // Bei Nacht und falls wechsel auf false ist, wird der Ausdruck im Block ausgefuehrt
- while (wechsel == false) { // Solange wechsel auf false ist, wird der Block wiederholt ausgefuehrt, bis S1,S2 oder S3 gedrueckt wird
- vergleich_schalter_1 = digitalRead(schalter_1); // Beim Schalterdruck wird ein Status gesetzt
- if (vergleich_schalter_1 == HIGH) {
- wechsel = true;
- nachtwechsel = true;
- }
- vergleich_schalter_2 = digitalRead(schalter_2);
- if (vergleich_schalter_2 == HIGH){
- wechsel = true;
- nachtwechsel = true;
- }
- vergleich_schalter_3 = digitalRead(schalter_3);
- if (vergleich_schalter_3 == HIGH){
- wechsel = true;
- nachtwechsel_2 = true;
- }
- delay (50);
- } //End of while
- } //End of if
- if (state_tag_nacht == HIGH) { //Bei Tag wird dieser Block ausgefuehrt
- digitalWrite(fan_gruen,LOW);
- digitalWrite(fan_rot,HIGH);
- delay(5000); //P2-P3
- digitalWrite(ah_gruen,LOW);
- digitalWrite(ah_gelb,HIGH);
- delay(3500); //P3-P4
- digitalWrite(ah_gelb,LOW);
- digitalWrite(ah_rot,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_4[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1000); //P4-P5
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_5[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(7000); //P5-P6
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_6[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(3000); //P6-P7
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_7[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1000); //P7-P8
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_8_10[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1500); //P8-P9
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_9[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(7000); //P9-P10
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_8_10[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(3500); //P10-P11
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_11[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(3000); //P11-P12
- digitalWrite(ah_gelb,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_12[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1000); //P12-P13
- digitalWrite(ah_rot,LOW);
- digitalWrite(ah_gelb,LOW);
- digitalWrite(ah_gruen,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_1_13[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1500);
- } //End of Tagschaltung
- if (state_tag_nacht == LOW){ //Bei Nacht wird dieser Block ausgefuehrt
- digitalWrite(fan_gruen,LOW);
- digitalWrite(fan_rot,HIGH);
- for (int x=0; x<80; x++) { //Bei Tasterdruck wird der Status gespeichert und spaeter abgerufen
- vergleich_schalter_1 = digitalRead(schalter_1);
- vergleich_schalter_2 = digitalRead(schalter_2);
- vergleich_schalter_3 = digitalRead(schalter_3);
- if (vergleich_schalter_1 == HIGH || vergleich_schalter_2 == HIGH){ //S1 oder S2 gedrueckt: Status nachtwechsel auf true
- nachtwechsel = true;
- }
- if (vergleich_schalter_3 == HIGH){ //S3 gedrueckt: Status nachtwechsel_2 auf true
- nachtwechsel_2 = true;
- }
- delay(50);
- }
- digitalWrite(ah_gruen,LOW);
- digitalWrite(ah_gelb,HIGH);
- for (int x=0; x<70; x++) {
- vergleich_schalter_1 = digitalRead(schalter_1);
- vergleich_schalter_2 = digitalRead(schalter_2);
- vergleich_schalter_3 = digitalRead(schalter_3);
- if (vergleich_schalter_1 == HIGH || vergleich_schalter_2 == HIGH){
- nachtwechsel = true;
- }
- if (vergleich_schalter_3 == HIGH){
- nachtwechsel_2 = true;
- }
- delay(50);
- }
- digitalWrite(ah_gelb,LOW);
- digitalWrite(ah_rot,HIGH);
- if (nachtwechsel_2 == true){ // Pruefe nachtwechsel_2 (S3): Bei true wird der Block ausgefuehrt
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_4[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- for (int x=0; x<20; x++) {
- vergleich_schalter_1 = digitalRead(schalter_1);
- vergleich_schalter_2 = digitalRead(schalter_2);
- if (vergleich_schalter_1 == HIGH || vergleich_schalter_2 == HIGH){
- nachtwechsel = true;
- }
- delay(50);
- }
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_5[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- for (int x=0; x<140; x++) {
- vergleich_schalter_1 = digitalRead(schalter_1);
- vergleich_schalter_2 = digitalRead(schalter_2);
- if (vergleich_schalter_1 == HIGH || vergleich_schalter_2 == HIGH){
- nachtwechsel = true;
- }
- delay(50);
- }
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_6[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- for (int x=0; x<60; x++) {
- vergleich_schalter_1 = digitalRead(schalter_1);
- vergleich_schalter_2 = digitalRead(schalter_2);
- if (vergleich_schalter_1 == HIGH || vergleich_schalter_2 == HIGH){
- nachtwechsel = true;
- }
- delay (50);
- }
- if (nachtwechsel == true) { // Pruefe nachtwechsel: Bei true wird der Block auch ausgefuehrt
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_7[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1000);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_8_10[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1500);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_9[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(7000);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_8_10[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(3500);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_11[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(2500);
- digitalWrite(ah_gelb,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_12[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1000);
- digitalWrite(ah_rot,LOW);
- digitalWrite(ah_gelb,LOW);
- digitalWrite(ah_gruen,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_1_13[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1500);
- } //End of nachtwechsel(S1,S2)(true)
- else{ //nachtwechsel (S1,S2): Bei false wird dieser Block ausgefuehrt
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, nachtphase_1[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- digitalWrite(ah_gelb,HIGH);
- delay(1000);
- digitalWrite(ah_rot,LOW);
- digitalWrite(ah_gelb,LOW);
- digitalWrite(ah_gruen,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_1_13[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1500);
- } //End of else nachtwechsel (S1,S2)
- }
- else{ //nachtwechsel_2 (S3): Bei false wird dieser Block ausgefuehrt
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_7[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1000);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_8_10[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay (1500);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_9[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(7000);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_8_10[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(3500);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_11[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(3000);
- digitalWrite(ah_gelb,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_12[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1000);
- digitalWrite(ah_rot,LOW);
- digitalWrite(ah_gelb,LOW);
- digitalWrite(ah_gruen,HIGH);
- digitalWrite(storePin,LOW);
- for (int i=0; i<8; i++) {
- digitalWrite(shiftPin, LOW);
- digitalWrite(dataPin, phase_1_13[i]);
- digitalWrite(shiftPin, HIGH);
- }
- digitalWrite(storePin, HIGH);
- delay(1500);
- } //End of else nachtwechsel_2 (S3)
- } //End of Nachtschaltung
- } //End of void(loop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement