Outils pour utilisateurs

Outils du site


wiki:tutoriels:arduino-capteurs:arduino-capteurs

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

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 [2022/06/22 15:12] (Version actuelle)
damien.muti [Allumer aléatoirement une chaine de LED]
Ligne 898: Ligne 898:
  
  
-    //Import a library from the Arduino folder +//Import a library from the Arduino folder 
-    #include <CapacitiveSensor.h> +#include <CapacitiveSensor.h> 
-    //Select the two pins that will act as a capacitor +//Select the two pins that will act as a capacitor 
-    CapacitiveSensor capSensor = CapacitiveSensor(4,2); +CapacitiveSensor capSensor = CapacitiveSensor(4, 2); 
-    //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() { +void setup() { 
-    Serial.begin(9600); +  Serial.begin(9600); 
-    pinMode(ledPin, OUTPUT); +  pinMode(ledPin, OUTPUT); 
-    }+}
  
-    void loop() { +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, HIGH);     digitalWrite(ledPin, HIGH);
-    +  
-    //Touch undetected +  //Touch undetected 
-    else {+  else {
     //Turn off the led     //Turn off the led
     digitalWrite(ledPin, LOW);     digitalWrite(ledPin, LOW);
-    +  
-    delay(10); +  delay(10); 
-    }+}
  
  
Ligne 1331: Ligne 1331:
  
 Une autre version : {{ :wiki:tutoriels:arduino-capteurs:chaine_de_led_alumer_led_aleatoire_3.zip |}} Une autre version : {{ :wiki:tutoriels:arduino-capteurs:chaine_de_led_alumer_led_aleatoire_3.zip |}}
 +
 +=== Références ===
 +  * https://www.tubefr.com/scintillement-jusqu-a-6-leds-avec-arduino_4.html
  
 ---- ----
wiki/tutoriels/arduino-capteurs/arduino-capteurs.1652104551.txt.gz · Dernière modification: 2022/05/09 15:55 de damien.muti