XOIIO

Untitled

Apr 18th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. #include <Stepper.h>
  2.  
  3. const int stepsPerRevolution = 100;
  4. const int buzzer = 2;
  5. int count = 0;
  6. int trip = 0;
  7.  
  8.  
  9. Stepper myStepper(stepsPerRevolution, 6, 7, 8, 9);
  10.  
  11. void setup() {
  12. // initialize digital pin 13 as an output.
  13. pinMode(13, OUTPUT);
  14. pinMode(buzzer, OUTPUT);
  15. myStepper.setSpeed(90);
  16. Serial.begin(9600);
  17.  
  18. }
  19.  
  20. // the loop function runs over and over again forever
  21. void loop() {
  22.  
  23. if (trip == 1) {
  24. myStepper.step(100);
  25. digitalWrite(13, HIGH);
  26. tone(buzzer, 2000);
  27. delay(250);
  28. digitalWrite(13, LOW);
  29. noTone(buzzer);
  30. delay(250);
  31. digitalWrite(13, HIGH);
  32. tone(buzzer, 2000);
  33. delay(250);
  34. digitalWrite(13, LOW);
  35. noTone(buzzer);
  36. delay(30000);
  37. loop();
  38. }
  39.  
  40.  
  41. if (count < 10) {
  42. count += 1;
  43. digitalWrite(13, HIGH);
  44. tone(buzzer, 2500);
  45. delay(100);
  46. digitalWrite(13, LOW);
  47. noTone(buzzer);
  48. delay(900);
  49. loop();
  50. }
  51. if (count < 15) {
  52. count += 1;
  53. digitalWrite(13, HIGH);
  54. tone(buzzer, 2500);
  55. delay(50);
  56. digitalWrite(13, LOW);
  57. noTone(buzzer);
  58. delay(50);
  59. digitalWrite(13, HIGH);
  60. tone(buzzer, 2500);
  61. delay(50);
  62. digitalWrite(13, LOW);
  63. noTone(buzzer);
  64. delay(900);
  65. loop();
  66. }
  67.  
  68. noTone(buzzer);
  69. delay(50);
  70. int sensorValue = analogRead(A0);
  71. if (sensorValue >500) {
  72. digitalWrite(13, HIGH);
  73. tone(buzzer, 2500);
  74. delay(35);
  75. digitalWrite(13, LOW);
  76. noTone(buzzer);
  77. delay(35);
  78. digitalWrite(13, HIGH);
  79. tone(buzzer, 2500);
  80. delay(35);
  81. digitalWrite(13, LOW);
  82. noTone(buzzer);
  83. delay(35);
  84. digitalWrite(13, HIGH);
  85. tone(buzzer, 2500);
  86. delay(35);
  87. digitalWrite(13, LOW);
  88. noTone(buzzer);
  89. delay(35);
  90. digitalWrite(13, HIGH);
  91. tone(buzzer, 2500);
  92. delay(3000);
  93. noTone(buzzer);
  94. digitalWrite(13, LOW);
  95. trip += 1;
  96. delay(300000);
  97.  
  98. } else {
  99. digitalWrite(13, LOW);
  100. }
  101. }
Advertisement
Add Comment
Please, Sign In to add comment