Last active
December 11, 2018 23:05
Quand on appuie sur un bouton, un haut-parleur produit un son.
This file contains 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
/****************************************************** | |
* 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