Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentes Révision précédente Prochaine révision | Révision précédente | ||
wiki:tutoriels:arduino-capteurs:arduino-capteurs [2022/05/09 15:55] damien.muti [Capteur capacitif interne à la carte Arduino] |
wiki:tutoriels:arduino-capteurs:arduino-capteurs [2024/06/09 11:33] (Version actuelle) damien.muti [Microphone] |
||
---|---|---|---|
Ligne 898: | Ligne 898: | ||
- | | + | //Import a library from the Arduino folder |
- | #include < | + | #include < |
- | //Select the two pins that will act as a capacitor | + | //Select the two pins that will act as a capacitor |
- | CapacitiveSensor capSensor = CapacitiveSensor(4, | + | CapacitiveSensor capSensor = CapacitiveSensor(4, |
- | //Insert the minimum value provided by the sensor to detect the touch | + | //Insert the minimum value provided by the sensor to detect the touch |
- | int threshold = 1000; | + | int threshold = 1000; |
- | const int ledPin = 12; | + | const int ledPin = 12; |
- | | + | void setup() { |
- | Serial.begin(9600); | + | Serial.begin(9600); |
- | pinMode(ledPin, | + | pinMode(ledPin, |
- | } | + | } |
- | | + | void loop() { |
- | //Read the sensor value | + | //Read the sensor value |
- | long sensorValue = capSensor.capacitiveSensor(30); | + | long sensorValue = capSensor.capacitiveSensor(30); |
- | Serial.println(sensorValue); | + | Serial.println(sensorValue); |
- | //Touch detected | + | //Touch detected |
- | if (sensorValue > threshold) { | + | if (sensorValue > threshold) { |
//Turn on the led | //Turn on the led | ||
digitalWrite(ledPin, | digitalWrite(ledPin, | ||
- | | + | |
- | //Touch undetected | + | //Touch undetected |
- | else { | + | else { |
//Turn off the led | //Turn off the led | ||
digitalWrite(ledPin, | digitalWrite(ledPin, | ||
- | | + | |
- | delay(10); | + | delay(10); |
- | } | + | } |
Ligne 1168: | Ligne 1168: | ||
---- | ---- | ||
+ | ==== Microphone ==== | ||
+ | {{ : | ||
+ | |||
+ | |||
+ | Ce produit est proposé chez Adafruit : [[https:// | ||
+ | |||
+ | Ce module d' | ||
+ | |||
+ | Cet amplificateur est idéal lorsque vous souhaitez enregistrer ou détecter de l' | ||
+ | |||
+ | La puce au cœur de cet amplificateur est le MAX981. Elle offre quelques options que vous pouvez configurer avec la carte de dérivation. Le 'gain maximal' | ||
+ | |||
+ | Vous pouvez également changer le rapport d' | ||
+ | |||
+ | Il est nécessaire de souder les connecteurs avant utilisation.Le processus d' | ||
+ | |||
+ | **Après avoir branché la patte GND et VCC du Microphone au GND et VCC de la carte Arduino, Il faut brancher la sortie " | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Le programme permettant de mesurer le volume sonore à partir du micro est disponible sur ce lien suivant : [[https:// | ||
+ | |||
+ | < | ||
+ | / | ||
+ | Example Sound Level Sketch for the | ||
+ | Adafruit Microphone Amplifier | ||
+ | ****************************************/ | ||
+ | |||
+ | const int sampleWindow = 50; // Sample window width in mS (50 mS = 20Hz) | ||
+ | unsigned int sample; | ||
+ | |||
+ | void setup() | ||
+ | { | ||
+ | | ||
+ | } | ||
+ | |||
+ | |||
+ | void loop() | ||
+ | { | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | // collect data for 50 mS | ||
+ | while (millis() - startMillis < sampleWindow) | ||
+ | { | ||
+ | sample = analogRead(0); | ||
+ | if (sample < 1024) // toss out spurious readings | ||
+ | { | ||
+ | if (sample > signalMax) | ||
+ | { | ||
+ | signalMax = sample; | ||
+ | } | ||
+ | else if (sample < signalMin) | ||
+ | { | ||
+ | signalMin = sample; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
---- | ---- | ||
===== Actionneurs ===== | ===== Actionneurs ===== | ||
Ligne 1331: | Ligne 1404: | ||
Une autre version : {{ : | Une autre version : {{ : | ||
+ | |||
+ | === Références === | ||
+ | * https:// | ||
---- | ---- |