daily pastebin goal
63%
SHARE
TWEET

JOZa

a guest Feb 17th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int a1 = 0;
  2. int a2 = 0;
  3. int a3 = 0;
  4. int a4 = HIGH;
  5. int ts = 0;
  6. const int t1 = 2;
  7. const int t2 = 3;
  8. const int t3 = 4;
  9. const int t4 = 5;
  10. const int led1 = 6;
  11. const int led2 = 7;
  12. const int led3 = 8;
  13. const int led4 = 9;
  14. const int led5 = 10;
  15. const int led6 = 11;
  16. const int led7 = 12;
  17. const int led8 = 0;
  18. const int led9 = 1;
  19. const int led10 = 2;
  20. int t1state = 0;
  21. int t2state = 0;
  22. int t3state = 0;
  23. int t4state = 0;
  24. int startmillis = 0;
  25. void setup() {
  26.   // put your setup code here, to run once:
  27.   pinMode(2, INPUT_PULLUP);
  28.   pinMode(3, INPUT_PULLUP);
  29.   pinMode(4, INPUT_PULLUP);
  30.   pinMode(5, INPUT_PULLUP);
  31.   pinMode(6, OUTPUT);
  32.   pinMode(7, OUTPUT);
  33.   pinMode(8, OUTPUT);
  34.   pinMode(9, OUTPUT);
  35.   pinMode(10, OUTPUT);
  36.   pinMode(11, OUTPUT);
  37.   pinMode(12, OUTPUT);
  38.   pinMode(A0, OUTPUT);
  39.   pinMode(A1, OUTPUT);
  40.   pinMode(A2, OUTPUT);
  41.   digitalWrite(6, LOW);
  42.   digitalWrite(7, LOW);
  43.   digitalWrite(8, LOW);
  44.   digitalWrite(9, LOW);
  45.   digitalWrite(10, LOW);
  46.   digitalWrite(11, LOW);
  47.   digitalWrite(12, LOW);
  48.   analogWrite(0, 0);
  49.   analogWrite(1, 0);
  50.   analogWrite(2, 0);
  51.   Serial.begin(9600);
  52. }
  53. void loop() {
  54.   // put your main code here, to run repeatedly:
  55.   a1 = digitalRead(led1);
  56.   a2 = digitalRead(led5);
  57.   a3 = digitalRead(led6);
  58.   if (digitalRead(t1) == HIGH) {
  59.     if (t1state != 1) {
  60.       if (a1 == HIGH) {
  61.         digitalWrite(led1, LOW);
  62.         digitalWrite(led2, LOW);
  63.         digitalWrite(led3, LOW);
  64.         digitalWrite(led4, LOW);
  65.        }
  66.       else if (a1 == LOW) {
  67.        digitalWrite(led1, HIGH);
  68.        digitalWrite(led2, HIGH);
  69.        digitalWrite(led3, HIGH);
  70.        digitalWrite(led4, HIGH);
  71.       }
  72.     t1state = 1;
  73.     }
  74.   }
  75.   if (digitalRead(t1) == LOW) {
  76.     t1state = 0;
  77.   }
  78.   // tipkalo 2
  79.   if (digitalRead(t2) == HIGH) {
  80.     if (t2state != 1) {
  81.       if (a2 == HIGH) {
  82.         digitalWrite(led5, LOW);
  83.        }
  84.       else if (a2 == LOW) {
  85.        digitalWrite(led5, HIGH);
  86.       }
  87.     t2state = 1;
  88.     }
  89.   }
  90.   if (digitalRead(t2) == LOW) {
  91.     t2state = 0;
  92.   }
  93.   // tipkalo 3
  94.   if (digitalRead(t3) == HIGH) {
  95.     if (t3state != 1) {
  96.       if (a3 == HIGH) {
  97.         digitalWrite(led6, LOW);
  98.        }
  99.       else if (a3 == LOW) {
  100.        digitalWrite(led6, HIGH);
  101.       }
  102.     t3state = 1;
  103.     }
  104.   }
  105.   if (digitalRead(t3) == LOW) {
  106.     t3state = 0;
  107.   }
  108.   // tipkalo 4
  109.   if (digitalRead(t4) == HIGH) {
  110.     if (t4state != 1) {
  111.       if (a4 == HIGH) {
  112.         digitalWrite(led7, LOW);
  113.         digitalWrite(led8, LOW);
  114.         digitalWrite(led9, LOW);
  115.         digitalWrite(led10, LOW);
  116.         ts = 0;
  117.         a4 = LOW;
  118.        }
  119.       else if (a4 == LOW) {
  120.         startmillis = millis();
  121.         ts = 1;
  122.         a4 = HIGH;
  123.       }
  124.   if (ts == 1) {
  125.       Serial.print((millis() - startmillis));
  126.     if ((millis() - startmillis) > 0 and (millis() - startmillis) < 601) {
  127.       digitalWrite(led7, HIGH);
  128.       analogWrite(led8, 0);
  129.       analogWrite(led9, 0);
  130.       analogWrite(led10, 0);
  131.     }
  132.     if ((millis() - startmillis) > 600 and (millis() - startmillis) < 1201) {
  133.       digitalWrite(led7, LOW);
  134.       analogWrite(led8, 255);
  135.       analogWrite(led9, 0);
  136.       analogWrite(led10, 0);
  137.     }
  138.     if ((millis() - startmillis) > 1200 and (millis() - startmillis) < 1801) {
  139.       digitalWrite(led7, LOW);
  140.       analogWrite(led8, 0);
  141.       analogWrite(led9, 255);
  142.       analogWrite(led10, 0);
  143.     }
  144.     if ((millis() - startmillis) > 1800 and (millis() - startmillis) < 2401) {
  145.       digitalWrite(led7, LOW);
  146.       analogWrite(led8, 0);
  147.       analogWrite(led9, 0);
  148.       analogWrite(led10, 255);
  149.     }
  150.     if ((millis() - startmillis) > 2400 and (millis() - startmillis) < 3001) {
  151.       digitalWrite(led7, LOW);
  152.       analogWrite(led8, 0);
  153.       analogWrite(led9, 255);
  154.       analogWrite(led10, 0);
  155.     }
  156.     if ((millis() - startmillis) > 3000 and (millis() - startmillis) < 3600) {
  157.       digitalWrite(led7, LOW);
  158.       analogWrite(led8, 255);
  159.       analogWrite(led9, 0);
  160.       analogWrite(led10, 0);
  161.     }
  162.     Serial.print((millis() - startmillis));
  163.     if ((millis() - startmillis) > 3600 ) {
  164.       startmillis = millis();
  165.     }
  166.   }
  167.     t4state = 1;
  168.     }
  169.   }
  170.   if (digitalRead(t4) == LOW) {
  171.     t4state = 0;
  172.   }
  173.   Serial.print(a1);
  174.   Serial.print(a2);
  175.   Serial.print(a3);
  176.   Serial.println(ts);
  177. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top