Expand | ||
---|---|---|
| ||
|
Using this function
...
Purpose
Enables the use of a Digital IO Pin
...
by telling the program if
...
it should be considered as an Input or an Output.
When
...
to use
Once for each Digital IO Pin used on the board. If you connect anything to a digital pin, its mode should be set.
Where
...
to use
At the beginning of your code execution
...
,
...
in the void setup()
part of your .ino
file.
...
Info |
---|
Click here to learn more on the digital IOs of the 9880 board. |
Note |
---|
This function requires the use of the following functions at some point of your
|
Full Prototype
static void Crc::CrcLib::SetDigitalPinMode(unsigned char pin, unsigned char mode)
Returns
This function does not return a value once it has completed its tasks.
Parameters
The following parameters must be passed to the function for it to work properly:
pin
: The name of the digital pin you want to set. Must be of the typeunsigned char
.mode
: The mode you want to set the pin to. Must be of the typeunsigned char
. Needs to be one of the following:INPUT
, if you are using the digital pin as as input.OUTPUT
, if you are using the digital pin as as output.
Overloads
This function does not have any overloads.
Examples
We want to connect a digital sensor, like a limit switch, to DIO Port 5. Therefore, it should be set as an Input.
We want to connect a small light or a relay control signal, to DIO Port 9. Therefore, it should be set as an Output.
Code Block | ||
---|---|---|
| ||
#include <CrcLib.h> using namespace Crc; void setup() { CrcLib::Initialize(); //Set up DIO Port 5 as an Input CrcLib::SetDigitalPinMode(CRC_DIG_5, INPUT); //Set up DIO Port 9 as an Output CrcLib::SetDigitalPinMode(CRC_DIG_9, OUTPUT); /* The rest of your setup code ... */ } |
...
Instructions
...
void loop() {
CrcLib::Update();
/*
The rest of your looping code
...
*/
} |
More on this function
Info |
---|
Why not use the native Arduino function pinMode() instead of CrcLib::SetDigitalPinMode() ?We recommend using CrcLib::SetDigitalPinMode() because it adds a few layers of validation to make sure you don't assign a mode to an unsafe pin. |
Info |
---|
Click here to learn more about the different pin modes on an Arduino board. Note that a pull-up resistor is connected to all digital pins of the 9880 board, so using |
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Page Properties | ||
---|---|---|
| ||
|