Skip to content

Instantly share code, notes, and snippets.

@ypelletier
Last active December 11, 2018 23:05
Quand on appuie sur un bouton, un haut-parleur produit un son.
/******************************************************
* Quand on appuie sur un bouton, un haut-parleur
* produit un son.
https://electroniqueamateur.blogspot.com/2017/02/bip-bip-5-circuits-qui-produisent-un-son.html
******************************************************/
const int buttonPin = 7;
const int speakerPin = 8;
void setup() {
pinMode(buttonPin, INPUT);
pinMode(speakerPin, OUTPUT);
}
void loop() {
if (digitalRead(buttonPin)){
tone(speakerPin, 220);
}
else
noTone(speakerPin);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment