Skip to content

Instantly share code, notes, and snippets.

@heltonbiker
Created November 25, 2017 20:14
Show Gist options
  • Save heltonbiker/3e946b0ef7515de7a18a06e6073b2501 to your computer and use it in GitHub Desktop.
Save heltonbiker/3e946b0ef7515de7a18a06e6073b2501 to your computer and use it in GitHub Desktop.
Gera o som de um grilo - Generates the sound of a cricket
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