Using this function
Purpose of this function:
Enables the use of a Digital IO Pin. This function tells the program if a given Digital IO Pin should be considered as an Input or an Output.
When this function should be used:
This function should be used once for each Digital IO Pin used on the board. If you connect anything to a digital pin, its mode should be set.
Where this function should be called:
This function should be called only once for each Digital IO Pins on the board, determining its behavior, at the beginning of your code execution. Therefore, it should be called in the
void setup()
part of your.ino
file.
Prerequisites. This function requires the use of the following functions at some point of your
.ino
file in order to work properly:CrcLib::Initialize()
CrcLib::Update()
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.
#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 code */ }
Instructions
Related articles
Filter by label
There are no items with the selected labels at this time.
0 Comments