Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Purpose

Get the value of a Digital Input (DI) of the board.

When to use

Whenever you need to use the state of a DI.

Where to use

Most probably in the void loop() part of your .ino file, since we’d usually want to actively monitor the value.

Info

Click here to learn more on the DIOs of the 9880 board.

Note

This function requires the use of the following CrcLib functions at some point of your .ino file in order to work properly:

Returns

This function returns state of the DI mentioned as the function’s argument as an unsigned char type. The value returned will be either one of these two possible values:

  • HIGH, if voltage is applied to the SIG pin of the digital port.

  • LOW, if no voltage is applied to the SIG pin of the digital port.

Main prototype and parameters

Objectif

Obtenir l'état d’une entrée digitale (DIO) sur le CRCduino.

Quand l’utiliser

Après un appel à SetDigitalPinMode() {FR} pour la broche correspondante, lorsque vous souhaitez obtenir l'état de l’entrée

Où l’utiliser

Typiquement dans la section void loop(), afin de pouvoir réagir à un changement.

Info

Cliquez ici pour en apprendre plus sur les entrées/sorties (DIO) du CRCduino.

Note

C’est fonction requiert l’utilisation des fonctions suivantes dans votre programme:

Valeur de retour

Cette fonction retourne l'état d’une entrée digitale spécifiée par l’argument pin. Cet état sera l’un ou l’autre des états suivants:

  • HIGH, si une tension est présente sur le port digital (broche SIG)

  • LOW, si une tension n'est pas présente sur le port digital

Prototype principal

static unsigned char CrcLib::GetDigitalInput(unsigned char pin)

The following parameters must be passed to the function for it to work properly:

pin: The name of the digital pin you want to read the state of. Must be of the

Les paramètres suivants sont requis par la fonction:

  • pin: Le nom de la broche à vérifier, de type unsigned char.

Overloads

This function does not have any overloads. It can only be used as described by the main prototype.

Examples

Cette fonction n’a pas d’overloads, elle ne peut être utilisée qu’avec le prototype principal.

Exemples

Expand
title#1: We want to put the state of a button, connected to DIO Port 5, into a variable, to be used eslewhere in the program.Nous souhaitons enrgistrer dans une variable l'état du port digital (DIO) 5
Code Block
languagecpp
#include <CrcLib.h>

// Variable declaration
bool ButtonState;

void setup() {
    CrcLib::Initialize();

    // Configurer le port DIO 5 comme entrée
    CrcLib::SetDigitalPinMode(CRC_DIG_5, INPUT); //Set up DIO Port 5 as an Input

    /* 
    TheLe restreste ofdu yourcode setupd'initialisation
code     ...
     */
}
void loop() {
    CrcLib::Update();

    //The La variable ButtonState will have the same value as DIO Port 5etatBouton conservera la valeur du port DIO 5 tel que mesuré à ce moment
    bool ButtonStateetatBouton = CrcLib::GetDigitalInput(CRC_DIG_5);
    
    /* 
    TheReste restde ofla yourboucle loopingprincipale
code     ...
    */
}
More on this function

En apprendre plus

Info
Why does this function return
Pourquoi est-ce que cette fonction retourne HIGH/ LOW,
instead of
au lieu true / false?

The Arduino environment, when speaking of voltage, uses the constant HIGH to represent its presence and LOW to represent its absence. In electronics, a voltage presence (or when is is greater than a certain value) is usually represented by true, while an absence of voltage (or when it is lower than a certain value) is usually represented by false.

More on this here.

Related articles

L’environnement Arduino utilise les constantes HIGH / LOW pour représenter de manière plus claire si une tension est présente ou non. Cependant, en général, en électronique, une tension positive est représentée par un true, tandis que l’absence de tension est représentée par un false.

Plus d'information disponible ici (en anglais).

Articles reliés

Filter by label (Content by label)
sorttitle
excerptTyperich content
cqllabel = "ar-digital_io"