RUI3 (RAK Unified Interface 3) - RAK4631
DigitalIO

Functions

void pinMode (uint8_t pin, uint8_t mode)
 
void digitalWrite (uint8_t pin, uint8_t value)
 
int digitalRead (uint8_t pin)
 

Detailed Description

Function Documentation

◆ pinMode()

void pinMode ( uint8_t  pin,
uint8_t  mode 
)
Description
Configures the specified pin to behave either as an input or an output
Syntax
pinMode(pin, mode);
Parameters
pinthe pin which you want to set
modeINPUT, OUTPUT, or INPUT_PULLUP
Returns
void
Example
uint8_t ledPin = 36;   // LED connected to digital pin 36
uint8_t inputPin = 13; // input connected to digital pin 13 

void setup()
{
    pinMode(ledPin, OUTPUT);         // sets the digital pin 36 as output  
    pinMode(inputPin, INPUT_PULLUP); // sets the digital pin 13 as input
}

void loop()
{
    int val = digitalRead(inputPin); // read the input pin
    if (val == LOW) 
        digitalWrite(ledPin, HIGH); // enable led if input is LOW
    else 
        digitalWrite(ledPin, LOW); // disable led if input is HIGH
} 
Examples:
RAK_Thread/src/app.cpp.

◆ digitalWrite()

void digitalWrite ( uint8_t  pin,
uint8_t  value 
)
Description
Write a HIGH or a LOW value to a digital pin.
Syntax
digitalWrite(pin, value);
Parameters
pinthe pin which you want to write
valueHIGH or LOW
Returns
void
Example
uint8_t ledPin = 36;   // LED connected to digital pin 36
uint8_t inputPin = 13; // input connected to digital pin 13

void setup()
{
    pinMode(ledPin, OUTPUT);         // sets the digital pin 36 as output
    pinMode(inputPin, INPUT_PULLUP); // sets the digital pin 13 as input
}

void loop()
{
    int val = digitalRead(inputPin); // read the input pin
    if (val == LOW)
        digitalWrite(ledPin, HIGH); // enable led if input is LOW
    else
        digitalWrite(ledPin, LOW); // disable led if input is HIGH
}
Examples:
RAK_Thread/src/app.cpp.

◆ digitalRead()

int digitalRead ( uint8_t  pin)
Description
Reads the value from a specified digital pin, either HIGH or LOW
Syntax
digitalRead(pin);
Parameters
pinthe pin which you want to read
Returns
HIGH or LOW(Type: int)
Example
uint8_t ledPin = 36;   // LED connected to digital pin 36
uint8_t inputPin = 13; // input connected to digital pin 13

void setup()
{
    pinMode(ledPin, OUTPUT);         // sets the digital pin 36 as output
    pinMode(inputPin, INPUT_PULLUP); // sets the digital pin 13 as input
}

void loop()
{
    int val = digitalRead(inputPin); // read the input pin
    if (val == LOW)
        digitalWrite(ledPin, HIGH); // enable led if input is LOW
    else
        digitalWrite(ledPin, LOW); // disable led if input is HIGH
}
Examples:
RAK_Thread/src/app.cpp.