/*
Arduino Beeper Factory Sketch
This sketch simulates a factory environment where a beeper is controlled by an Arduino board.
The beeper will beep at regular intervals
pause for a specified duration
and then repeat the cycle.
Components Required:
- Arduino board (e.g. Arduino Uno)
- Passive Buzzer
- Jumper wires
Circuit Connections:
- Connect the positive pin of the buzzer to digital pin 8 on the Arduino.
- Connect the negative pin of the buzzer to GND on the Arduino.
Author: Your Name
Date: Today's Date
*/
// Define the digital pin where the buzzer is connected
#define BUZZER_PIN 8
// Define the interval in milliseconds between each beep
#define BEEP_INTERVAL 1000
// Define the duration in milliseconds to pause between beeps
#define PAUSE_DURATION 500
void setup() {
// Set the buzzer pin as an output
pinMode(BUZZER_PIN
OUTPUT);
}
void loop() {
// Beep the buzzer
tone(BUZZER_PIN
1000);
delay(BEEP_INTERVAL);
// Pause for the specified duration
noTone(BUZZER_PIN);
delay(PAUSE_DURATION);
}
/*
Explanation:
- We start by defining the digital pin where the buzzer is connected (in this case
pin 8).
- We also define the interval between each beep and the pause duration.
- In the setup function
we set the buzzer pin as an output so that we can control it.
- In the loop function
we start the beep by using the tone function with a frequency of 1000 Hz.
- We then delay for the specified interval before stopping the beep with the noTone function.
- Finally
we delay for the pause duration before repeating the cycle.
You can adjust the beep interval and pause duration to customize the beeping pattern as needed.
*/