Advertisement
nRikee

Buzzer 3 pins example 2

Nov 22nd, 2013
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.59 KB | None | 0 0
  1. const int buzzerPin =  3;       // Número del pin donde está el buzzer       
  2. long tono = 250;            // Tono 1
  3.  
  4. // Se ejecuta al principio, prepara el programa
  5. void setup() {
  6.   pinMode(buzzerPin, OUTPUT);       // Marca el buzzerPin como pin de salida.
  7. }
  8.  
  9. // Este método se ejecuta en bucle
  10. void loop()
  11. {
  12.    tone(3,tono,500);        // emite el tono con el número "tono" durante medio segundo   
  13.    delay(1000);         // para el programa durante 1 segundo
  14.    
  15.    if ( tono > 50 )     // si tono es mayor que 50:
  16.     tono -= 10;     // restale 10
  17.    else if (tono < 230 )    // si no:
  18.     tono +=5;       // súmale 5
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement