Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define nextDiaPin 8
- #define shootCameraPin 9
- #define button36Pin 10
- #define button50Pin 11
- #define reedContactPin 12
- int iMagazin = 0;
- int iPushDelay = 500;
- int iShootDelay = 1000;
- int iStatus = 0;
- void setup() {
- // put your setup code here, to run once:
- pinMode(nextDiaPin, OUTPUT);
- pinMode(shootCameraPin, OUTPUT);
- pinMode(button36Pin, INPUT);
- pinMode(button50Pin, INPUT);
- pinMode(reedContactPin, INPUT);
- pinMode(LED_BUILTIN, OUTPUT);
- digitalWrite(nextDiaPin, HIGH);
- digitalWrite(shootCameraPin, HIGH);
- }
- void loop() {
- while (iMagazin == 0) {
- iStatus = 1;
- displayStatus();
- if (digitalRead(button36Pin) == HIGH) {
- iMagazin = 37;
- }
- if (digitalRead(button50Pin) == HIGH) {
- iMagazin = 51;
- }
- }
- for (int i = 0; i <= iMagazin; i++) {
- iStatus = 2;
- displayStatus();
- nextDia();
- while (digitalRead(reedContactPin) == HIGH) {
- delay(iPushDelay); // Do Nothing
- }
- while (digitalRead(reedContactPin) == LOW) {
- delay(iPushDelay); // Do Nothing
- }
- if (digitalRead(reedContactPin) == HIGH) {
- shootCamera();
- }
- }
- iMagazin = 0;
- }
- void nextDia() {
- digitalWrite(nextDiaPin, LOW);
- delay(iPushDelay);
- digitalWrite(nextDiaPin, HIGH);
- }
- void shootCamera() {
- delay(iShootDelay);
- digitalWrite(shootCameraPin, LOW);
- delay(iPushDelay);
- digitalWrite(shootCameraPin, HIGH);
- delay(iShootDelay);
- }
- void displayStatus() {
- switch (iStatus){
- case 0:
- digitalWrite(LED_BUILTIN,LOW);
- break;
- case 1:
- digitalWrite(LED_BUILTIN,HIGH);
- delay(200);
- digitalWrite(LED_BUILTIN,LOW);
- delay(200);
- break;
- case 2:
- digitalWrite(LED_BUILTIN,HIGH);
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement