Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/LocalSettings.php on line 193

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/LocalSettings.php on line 197

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338

Warning: putenv() has been disabled for security reasons in /home/users4/d/debrouilloweb/www/wikidebrouillard/includes/parser/Parser.php on line 2338
[ Wikidébrouillard ] Détecteur capacitif

Détecteur capacitif

De Wikidebrouillard.

Ligne 35 : Ligne 35 :
=== '''Allons plus loin dans l'explication''' ===
=== '''Allons plus loin dans l'explication''' ===
En démarrant le montage, on charge électriquement la surface conductrice pour l'amener à un potentiel. Lorsqu'on touche la surface en question, le corps agit comme une capacité et décharge la plaque, ce qui réduit le potentiel sur la surface.
En démarrant le montage, on charge électriquement la surface conductrice pour l'amener à un potentiel. Lorsqu'on touche la surface en question, le corps agit comme une capacité et décharge la plaque, ce qui réduit le potentiel sur la surface.
-
 
-
=== '''Code de l'application''' ===
 
=== '''Code de l'application''' ===
=== '''Code de l'application''' ===

Version du 22 janvier 2013 à 16:50

Article incomplet en cours de rédaction
Modèle:Vidéo


Sommaire

Présentation de l'expérience

Un détecteur capacitif permet de détecter une pression sur une surface conductrice d'électricité.

Matériel

  • résistance de 1 MOhm
  • LED
  • Buzzer
  • Ordinateur
  • arduino
  • le logiciel Arduino
  • Feuille de papier
  • BreadBoard
  • crayon gris

L'expérience

La manipulation

Appuyer sur la surface conductrice avec le doigt

Que voit-on ?

Lorsqu'on appuie sur la surface conductrice utilisée dans le montage, on peut observer un allumage de la LED et un bruit de buzzer.

Explications

De manière simple

La pression du doigt fait varier la tension dans la surface conductrice. Cette variation est détectée par l'arduino, qui allume alors la LED et déclenche le buzzer.

Questions sans réponses

Ici je mets les questions soulevées par l'expérience, qui n'ont pas trouvé de réponses !!

Allons plus loin dans l'explication

En démarrant le montage, on charge électriquement la surface conductrice pour l'amener à un potentiel. Lorsqu'on touche la surface en question, le corps agit comme une capacité et décharge la plaque, ce qui réduit le potentiel sur la surface.

Code de l'application


// Pin a connecter a la LED
int LEDPin = 13;
// Pin a connecter a la feuille de papier
int capSensePin = 2;
// This is how high the sensor needs to read in order
//  to trigger a touch.  You'll find this number
//  by trial and error, or you could take readings at 
//  the start of the program to dynamically calculate this.
int touchedCutoff = 60;

void setup(){
  Serial.begin(9600);
  // Set up the LED
  pinMode(LEDPin, OUTPUT);
  digitalWrite(LEDPin, LOW);
}


void buzz(int targetPin, long frequency, long length) {
  long delayValue = 1000000/frequency/2;
  long numCycles = frequency * length/ 1000;
  for (long i=0; i < numCycles; i++)
  {
    digitalWrite(targetPin,HIGH);
    delayMicroseconds(delayValue);
    digitalWrite(targetPin,LOW);
    delayMicroseconds(delayValue);
  }
}


void loop(){
  
  // Si le capateur atteint un certain seuil de tension, la led s'allume
  
  if (readCapacitivePin(capSensePin) > touchedCutoff) {
    digitalWrite(LEDPin, HIGH);
    // utilisation
    buzz(4, 2500, 1000); // buzz sur pin 4 à 2500Hz
  }
  else {
    digitalWrite(LEDPin, LOW);
  }
  
  // Affiche toute les 500 millisecondes la valeur du capteur
  if ( (millis() % 500) == 0){
    Serial.print("Capacitive Sensor on Pin 2 reads: ");
    Serial.println(readCapacitivePin(capSensePin));
  }
}

// readCapacitivePin
//  Entrée: Arduino pin number
//  Sortie: Un nombA number, from 0 to 17 expressing
//          how much capacitance is on the pin
//  When you touch the pin, or whatever you have
//  attached to it, the number will get higher
//  In order for this to work now,
// The pin should have a 1+Megaohm resistor pulling
//  it up to +5v.
uint8_t readCapacitivePin(int pinToMeasure){
  // This is how you declare a variable which
  //  will hold the PORT, PIN, and DDR registers
  //  on an AVR
  volatile uint8_t* port;
  volatile uint8_t* ddr;
  volatile uint8_t* pin;
  // Here we translate the input pin number from
  //  Arduino pin number to the AVR PORT, PIN, DDR,
  //  and which bit of those registers we care about.
  byte bitmask;
  if ((pinToMeasure >= 0) && (pinToMeasure <= 7)){
    port = &PORTD;
    ddr = &DDRD;
    bitmask = 1 << pinToMeasure;
    pin = &PIND;
  }
  if ((pinToMeasure > 7) && (pinToMeasure <= 13)){
    port = &PORTB;
    ddr = &DDRB;
    bitmask = 1 << (pinToMeasure - 8);
    pin = &PINB;
  }
  if ((pinToMeasure > 13) && (pinToMeasure <= 19)){
    port = &PORTC;
    ddr = &DDRC;
    bitmask = 1 << (pinToMeasure - 13);
    pin = &PINC;
  }
  // Discharge the pin first by setting it low and output
  *port &= ~(bitmask);
  *ddr  |= bitmask;
  delay(1);
  // Make the pin an input WITHOUT the internal pull-up on
  *ddr &= ~(bitmask);
  // Now see how long the pin to get pulled up
  int cycles = 16000;
  for(int i = 0; i < cycles; i++){
    if (*pin & bitmask){
      cycles = i;
      break;
    }
  }
  // Discharge the pin again by setting it low and output
  //  It's important to leave the pins low if you want to 
  //  be able to touch more than 1 sensor at a time - if
  //  the sensor is left pulled high, when you touch
  //  two sensors, your body will transfer the charge between
  //  sensors.
  *port &= ~(bitmask);
  *ddr  |= bitmask;
  
  return cycles;
}

Portail des ExplorateursWikidébrouillardLéon DitFLOGPhoto mystèreJ'ai FaitPortraits
AR
CO

Détecteur capacitif

Rechercher

Page Discussion Historique
Powered by MediaWiki
Creative Commons - Paternite Partage a l

© Graphisme : Les Petits Débrouillards Grand Ouest (Patrice Guinche - Jessica Romero) | Développement web : Libre Informatique