Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 KB | None | 0 0
  1. #define nextDiaPin 8
  2. #define shootCameraPin 9
  3. #define button36Pin 10
  4. #define button50Pin 11
  5. #define reedContactPin 12
  6.  
  7. int iMagazin = 0;
  8. int iPushDelay = 500;
  9. int iShootDelay = 1000;
  10. int iStatus = 0;
  11.  
  12. void setup() {
  13.     // put your setup code here, to run once:
  14.     pinMode(nextDiaPin, OUTPUT);
  15.     pinMode(shootCameraPin, OUTPUT);
  16.     pinMode(button36Pin, INPUT);
  17.     pinMode(button50Pin, INPUT);
  18.     pinMode(reedContactPin, INPUT);
  19.     pinMode(LED_BUILTIN, OUTPUT);
  20.   digitalWrite(nextDiaPin, HIGH);
  21.   digitalWrite(shootCameraPin, HIGH);
  22.  
  23. }
  24.  
  25. void loop() {
  26.    
  27.     while (iMagazin == 0) {
  28.     iStatus = 1;
  29.     displayStatus();
  30.         if (digitalRead(button36Pin) == HIGH) {
  31.             iMagazin = 37;
  32.         }
  33.         if (digitalRead(button50Pin) == HIGH) {
  34.             iMagazin = 51;
  35.         }
  36.     }
  37.  
  38.  
  39.     for (int i = 0; i <= iMagazin; i++) {
  40.     iStatus = 2;
  41.     displayStatus();
  42.         nextDia();
  43.         while (digitalRead(reedContactPin) == HIGH) {
  44.             delay(iPushDelay); // Do Nothing
  45.         }
  46.         while (digitalRead(reedContactPin) == LOW) {
  47.             delay(iPushDelay); // Do Nothing
  48.         }
  49.         if (digitalRead(reedContactPin) == HIGH) {
  50.             shootCamera();
  51.         }
  52.     }
  53.     iMagazin = 0;
  54. }
  55.  
  56. void nextDia() {
  57.     digitalWrite(nextDiaPin, LOW);
  58.     delay(iPushDelay);
  59.     digitalWrite(nextDiaPin, HIGH);
  60. }
  61.  
  62. void shootCamera() {
  63.     delay(iShootDelay);
  64.     digitalWrite(shootCameraPin, LOW);
  65.     delay(iPushDelay);
  66.     digitalWrite(shootCameraPin, HIGH);
  67.     delay(iShootDelay);
  68. }
  69.  
  70.  
  71. void displayStatus() {
  72.     switch (iStatus){
  73.     case 0:
  74.       digitalWrite(LED_BUILTIN,LOW);
  75.     break;
  76.     case 1:
  77.       digitalWrite(LED_BUILTIN,HIGH);
  78.       delay(200);
  79.       digitalWrite(LED_BUILTIN,LOW);
  80.       delay(200);
  81.     break;
  82.     case 2:
  83.       digitalWrite(LED_BUILTIN,HIGH);
  84.     break;
  85.   }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement