ReadDigitalChannel() {FR}

Purpose

Get the value of a Digital Channel (button) on a remote controller connected to the CrcDuino via a CrcConnect module.

When to use

Whenever you need to use the state of a remote controller button.

Where to use

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

Click here to learn more on the CrcConnect system, that allows to control a CrcDuino using popular off-the-shelf remote controllers.

If not connection is established with a remote controller via a CrcConnect module, ReadDigitalChannel() returns a value of LOW. Depending on the application, it might be useful to validate the status of the connection using IsCommValid().

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 the value of the analog channel mentioned as the function’s argument as a booltype.

  • LOW, if the button is not pressed, or if no connection is established between a remote controller and the CrcDuino (via a CrcConnect Module)

  • HIGH, if the button is pressed

Main prototype and parameters

static bool CrcLib::ReadDigitalChannel(BUTTON channel)

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

  • channel: The name of the button channel you want to read the value of. Must be of the type BUTTON.

Overloads

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

Examples

#include <CrcLib.h> bool btnValue; void setup() { CrcLib::Initialize(); Serial.begin(2000000); //Open the serial Monitor at a 2000000 baud rate /* The rest of your setup code ... */ } void loop() { CrcLib::Update(); btnValue = CrcLib::ReadDigitalChannel(BUTTON::COLORS_LEFT); Serial.println(btnValue); /* The rest of your looping code ... */ }

More on this function

There is sadly nothing more to be said about this function…

Related articles