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:50] damien.muti [Capteur capacitif interne à la carte Arduino] |
wiki:tutoriels:arduino-capteurs:arduino-capteurs [2022/06/22 15:12] (Version actuelle) damien.muti [Allumer aléatoirement une chaine de LED] |
||
---|---|---|---|
Ligne 892: | Ligne 892: | ||
Montage : | Montage : | ||
{{ : | {{ : | ||
+ | |||
+ | Programme : | ||
+ | |||
+ | < | ||
+ | |||
+ | |||
+ | //Import a library from the Arduino folder | ||
+ | #include < | ||
+ | //Select the two pins that will act as a capacitor | ||
+ | CapacitiveSensor capSensor = CapacitiveSensor(4, | ||
+ | //Insert the minimum value provided by the sensor to detect the touch | ||
+ | int threshold = 1000; | ||
+ | const int ledPin = 12; | ||
+ | |||
+ | void setup() { | ||
+ | Serial.begin(9600); | ||
+ | pinMode(ledPin, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | //Read the sensor value | ||
+ | long sensorValue = capSensor.capacitiveSensor(30); | ||
+ | Serial.println(sensorValue); | ||
+ | //Touch detected | ||
+ | if (sensorValue > threshold) { | ||
+ | //Turn on the led | ||
+ | digitalWrite(ledPin, | ||
+ | } | ||
+ | //Touch undetected | ||
+ | else { | ||
+ | //Turn off the led | ||
+ | digitalWrite(ledPin, | ||
+ | } | ||
+ | delay(10); | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
=== Plusieurs capteurs capacitifs === | === Plusieurs capteurs capacitifs === | ||
Ligne 1293: | Ligne 1331: | ||
Une autre version : {{ : | Une autre version : {{ : | ||
+ | |||
+ | === Références === | ||
+ | * https:// | ||
---- | ---- |