Created
          November 25, 2017 20:14 
        
      - 
      
 - 
        
Save heltonbiker/3e946b0ef7515de7a18a06e6073b2501 to your computer and use it in GitHub Desktop.  
    Gera o som de um grilo - Generates the sound of a cricket
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | const int pulsos = 7; | |
| const int duracaoPulso = 17; | |
| const int pausa = 360; | |
| const int frequencia = 4000; | |
| const int pinoFalante = 8; // 8 ohm speaker in series with potentiometer | |
| void setup() { | |
| pinMode(pinoFalante, OUTPUT); | |
| } | |
| void loop() { | |
| cantar(); | |
| } | |
| void cantar() { | |
| for (int i = 0; i < pulsos; i++) { | |
| tone(pinoFalante, frequencia, duracaoPulso); | |
| delay(duracaoPulso*2); | |
| } | |
| delay(pausa); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment