Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int buzzerPin = 10; //Outputs 5v to switch a relay or sound a DC powered buzzer. Change to desired pin.
- int extLED = 9; //Outputs 5v for an external LED that turns on with the buzzer. Will require resistor. Change to desired pin.
- int toneGenOut = 8; //Outputs a frequency to drive piezos or any buzzer that requires a frequency. Change to desired pin.
- void setup() {
- pinMode(buzzerPin, OUTPUT); //Designates pins as outputs.
- pinMode(extLED, OUTPUT); //
- pinMode(toneGenOut, OUTPUT); //
- pinMode(LED_BUILTIN, OUTPUT); //
- }
- void loop() {
- delay(20000); //Waits 20sec. Can adust to prefered value. (20000 = 20 seconds)
- while(true) {
- digitalWrite(buzzerPin, HIGH); //Brings outputs high after set time. Stays on forever until power is disconnected.
- digitalWrite(extLED, HIGH); //
- digitalWrite(LED_BUILTIN, HIGH); //
- tone(toneGenOut, 800); //Change this number to change the tone frequency. (800 = 800 hz)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement