Advertisement
ENDERFLAG3

Untitled

Nov 26th, 2024
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. int buzzerPin = 10;     //Outputs 5v to switch a relay or sound a DC powered buzzer. Change to desired pin.
  2. int extLED = 9;         //Outputs 5v for an external LED that turns on with the buzzer. Will require resistor. Change to desired pin.
  3. int toneGenOut = 8;     //Outputs a frequency to drive piezos or any buzzer that requires a frequency. Change to desired pin.
  4.  
  5. void setup() {
  6.   pinMode(buzzerPin, OUTPUT);     //Designates pins as outputs.
  7.   pinMode(extLED, OUTPUT);        //
  8.   pinMode(toneGenOut, OUTPUT);    //
  9.   pinMode(LED_BUILTIN, OUTPUT);   //
  10. }
  11.  
  12. void loop() {
  13.  
  14.   delay(20000);   //Waits 20sec. Can adust to prefered value. (20000 = 20 seconds)
  15.  
  16.   while(true) {
  17.  
  18.     digitalWrite(buzzerPin, HIGH);    //Brings outputs high after set time. Stays on forever until power is disconnected.
  19.     digitalWrite(extLED, HIGH);       //
  20.     digitalWrite(LED_BUILTIN, HIGH);  //
  21.     tone(toneGenOut, 800);            //Change this number to change the tone frequency. (800 = 800 hz)
  22.  
  23.   }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement