Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Stepper.h>
- const int stepsPerRevolution = 100;
- const int buzzer = 2;
- int count = 0;
- int trip = 0;
- Stepper myStepper(stepsPerRevolution, 6, 7, 8, 9);
- void setup() {
- // initialize digital pin 13 as an output.
- pinMode(13, OUTPUT);
- pinMode(buzzer, OUTPUT);
- myStepper.setSpeed(90);
- Serial.begin(9600);
- }
- // the loop function runs over and over again forever
- void loop() {
- if (trip == 1) {
- myStepper.step(100);
- digitalWrite(13, HIGH);
- tone(buzzer, 2000);
- delay(250);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(250);
- digitalWrite(13, HIGH);
- tone(buzzer, 2000);
- delay(250);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(30000);
- loop();
- }
- if (count < 10) {
- count += 1;
- digitalWrite(13, HIGH);
- tone(buzzer, 2500);
- delay(100);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(900);
- loop();
- }
- if (count < 15) {
- count += 1;
- digitalWrite(13, HIGH);
- tone(buzzer, 2500);
- delay(50);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(50);
- digitalWrite(13, HIGH);
- tone(buzzer, 2500);
- delay(50);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(900);
- loop();
- }
- noTone(buzzer);
- delay(50);
- int sensorValue = analogRead(A0);
- if (sensorValue >500) {
- digitalWrite(13, HIGH);
- tone(buzzer, 2500);
- delay(35);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(35);
- digitalWrite(13, HIGH);
- tone(buzzer, 2500);
- delay(35);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(35);
- digitalWrite(13, HIGH);
- tone(buzzer, 2500);
- delay(35);
- digitalWrite(13, LOW);
- noTone(buzzer);
- delay(35);
- digitalWrite(13, HIGH);
- tone(buzzer, 2500);
- delay(3000);
- noTone(buzzer);
- digitalWrite(13, LOW);
- trip += 1;
- delay(300000);
- } else {
- digitalWrite(13, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment