DigitalRead() | Référence Du Langage Arduino En Français

  • TUTORIALS
  • HARDWARE & TOOLS
  • REFERENCES
  • FAQs
  • ABOUT US
Home References Language References
  • English
  • |
  • Deutsch
  • |
  • Português
  • |
  • 한국어
  • |
  • Français
  • |
  • Español

Sketch

  • loop()
  • setup()

Control Structure

  • break
  • continue
  • Boucle do - while
  • if / else
  • Boucle for
  • goto
  • if (condition)
  • return
  • switch / case
  • Boucle while

Further Syntax

  • // et /* */ Commentaires
  • {} Accolades
  • #define
  • #include
  • ; point virgule

Data Types

  • Tableaux de variables
  • boolean
  • byte
  • char
  • double
  • float
  • int
  • long
  • Les chaînes de caractères
  • String()
  • unsigned int
  • unsigned long
  • void
  • word

Constants

  • Les constantes Arduino prédéfinies: INPUT, INPUT_PULLUP, OUTPUT, HIGH, LOW, LED_BUILTIN, true, false.
  • Floating Point Constants
  • Les expressions numériques entières

Variable Scope & Qualifiers

  • const
  • La portée des variables
  • static
  • volatile

Digital IO

  • digitalRead()
  • digitalWrite()
  • pinMode()

Analog IO

  • analogRead()
  • analogReference(type)
  • analogWrite()

Advanced IO

  • noTone()
  • pulseIn()
  • shiftOut()
  • tone()

Serial

  • Librairie Serial pour la communication série
  • Serial.available()
  • Serial.begin()
  • Serial.find()
  • Serial.findUntil()
  • Serial.flush()
  • Serial.parseFloat()
  • Serial.parseInt()
  • Serial.peek()
  • Serial.print()
  • Serial.println()
  • Serial.read()
  • Serial.readBytes()
  • Serial.readBytesUntil()
  • Serial.setTimeout()
  • Serial.write()

Stream

  • Librairie Stream
  • Stream.available()
  • Stream.find()
  • Stream.findUntil()
  • Stream.flush()
  • Stream.parseFloat()
  • Stream.parseInt()
  • Stream.peek()
  • Stream.read()
  • Stream.readBytes()
  • Stream.readBytesUntil()
  • Stream.setTimeout()

String Functions

  • String.charAt()
  • String.compareTo()
  • String.concat()
  • String.endsWith()
  • String.equals()
  • String.equalsIgnoreCase()
  • String.getBytes()
  • String.indexOf()
  • String.lastIndexOf()
  • String.length()
  • String.replace()
  • String.setCharAt()
  • String.startsWith()
  • String.substring()
  • String.toCharArray()
  • String.toLowerCase()
  • String.toUpperCase()
  • String.trim()

String Operators

  • String opérateur +=
  • String.opérateur ==
  • String opérateur +
  • String [] (accès à un élément)

Time

  • delay()
  • delayMicroseconds()
  • micros()
  • millis()

Math

  • abs()
  • constrain()
  • map()
  • max()
  • min()
  • pow()
  • sq()
  • sqrt()

Bits and Bytes

  • bit()
  • bitClear()
  • bitRead()
  • bitSet()
  • bitWrite()
  • highByte()
  • lowByte()

Arithmetic Operators

  • + Addition
  • = opérateur d'assignement
  • / Division
  • * Multiplication
  • % (modulo)
  • - Soustraction

Bitwise Operators

  • << (Décalage des bits vers la gauche)
  • >> (Décalage des bits vers la droite)
  • & (Opérateur "bit à bit" ET)
  • ~ (Opérateur "bit à bit" NON)
  • | (Opérateur bit à bit OU)
  • ^ (Opérateur "bit à bit" OU EXCLUSIF)

Boolean Operators

  • && (ET logique)
  • ! (NON logique)
  • || ( OU logique)

Compound Operators

  • += (addition composée)
  • &= (ET bit à bit composé)
  • |= (OU bit à bit composé)
  • /= (division composée)
  • *= (multiplication composée)
  • -= (soustraction composée)
  • -- (décrément)
  • ++ (incrément)

Conversion

  • byte()
  • char()
  • float()
  • int()
  • long()

Random Numbers

  • random()
  • randomSeed()

Trigonometry

  • cos()
  • sin()
  • tan()

External Interrupts

  • attachInterrupt (interruption, fonction, mode)
  • detachInterrupt(interruption)

Interrupts

  • interrupts()
  • noInterrupts()

Utilities

  • PROGMEM
  • sizeof

Pointer Access Operators

  • Les pointeurs : & (référence) et * (déréférence)
digitalRead()

Description

Lit l"état (= le niveau logique) d'une broche précise en entrée numérique, et renvoie la valeur HIGH (HAUT en anglais) ou LOW (BAS en anglais).

Syntaxe

digitalRead(broche)

Paramètres

  • broche: le numéro de la broche numérique que vous voulez lire. (int)

Valeurs Renvoyées

  • Renvoie la valeur HIGH (HAUT en anglais) ou LOW (BAS en anglais)

Exemple

int ledPin = 13; // LED connectée à la broche n°13 int inPin = 7; // un bouton poussoir connecté à la broche 7 // avec une résistance de pulldown int val = 0; // variable pour mémoriser la valeur lue void setup() { pinMode(ledPin, OUTPUT); // configure la broche 13 en SORTIE pinMode(inPin, INPUT); // configure la broche 7 en ENTREE digitalWrite(inPin, HIGH); // écrit la valeur HIGH (=1) sur la broche en entrée // ce qui active la résistance de "rappel au +" (pullup) au plus de la broche } void loop() { val = digitalRead(inPin); // lit l'état de la broche en entrée // et met le résultat dans la variable digitalWrite(ledPin, val); // met la LED dans l'état du BP // (càd allumée si appuyé et inversement) }

Dans ce programme, la broche 13 reflète fidèlement l'état de la broche 7 qui est une entrée numérique.

※ Remarque:

  • Si la broche numérique en entrée n'est connectée à rien, l'instruction digitalRead() peut retourner aussi bien la valeur HIGH (HAUT en anglais) ou LOW (BAS en anglais) ( et cette valeur peut changer de façon aléatoire)
  • Les broches analogiques peuvent être utilisées en entrée et sont désignées par les numéro 14 (entrée analogique 0) à 19 (entrée analogique 5).
int ledPin = A5; // LED connected to digital pin A5 int inPin = A0; // pushbutton connected to digital pin A0 int val = 0; // variable to store the read value void setup() { pinMode(ledPin, OUTPUT); // sets the digital pin A5 as output pinMode(inPin, INPUT); // sets the digital pin A0 as input } void loop() { val = digitalRead(inPin); // read the input pin digitalWrite(ledPin, val); // sets the LED to the button's value }
  • La broche numérique 13 est plus difficile à utiliser que les autres en tant qu'entrée numérique car elle est associée à une résistance et sa LED soudées sur le circuit imprimé de la carte sur la plupart des cartes. Si vous activez la résistance interne de rappel au plus de 20K, cela mettra la borche à 1,7V au lieu des 5V théoriques car la LED et la résistance associées à la broche abaisse la tension, qui est toujours considérée au niveau BAS (LOW). Ainsi, si vous devez utiliser la broche 13 en tant qu'entrée numérique, utiliser une résistance de rappel au plus externe.

ARDUINO BUY RECOMMENDATION

Arduino UNO R3
Arduino Starter Kit
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.Additionally, some links direct to products from our own brand, DIYables .

※ OUR MESSAGES

  • We are AVAILABLE for HIRE. See how to hire us to build your project
PREVIOUS NEXT DISCLOSURE ArduinoGetStarted.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com, Amazon.it, Amazon.fr, Amazon.co.uk, Amazon.ca, Amazon.de, Amazon.es, Amazon.nl, Amazon.pl and Amazon.se The Arduino Reference text is licensed under a Creative Commons Attribution-Share Alike 3.0 License. The content is modified based on Official Arduino References by: adding more example codes and output, adding more notes and warning, rewriting some parts, and re-formating Email: [email protected] ×

Tag » Arduino If Statement Digital Read